-
-
September 11, 2024 at 2:03 amJason SumSubscriber
Dear all,Â
I am now working on the shape optimisation of a Tesla Valve (as shown below). The optimised target is to maximise foward flow (blue arrow), and minimise backward flow (red arrow).Â
I have explored several methods for doing the optimisation:
(a) Parametric Design (DoE) on Design Exploration as shown below - it is quite computational demanding and the optimisation is limited to the manually set parameters.
(b) Adjoint Solver with Mesh Morphing - I am looking for optimisaiton through morphing but I am not sure if adjoint solver method allows the sensitivity data from two solving cases (foward & backward flow scenarios) to be integrated together and optimise.Â
I saw from the tutorial (https://ansyshelp.ansys.com/public/account/secured?returnurl=/Views/Secured/corp/v242/en/flu_tg/flu_adj_tutorial.html), sensitivity data from one case can be exported and loaded to the design tool, I am thinking can the sensitivity data from foward flow case exported and loaded into the design tool interface of backward flow case, so that the morphing can be able to consider the both sensitivity information.
(c) Optislang - Could you guide me on the differences between Optislang and Design Exploration, are they both using DoE and find out the optimised solution? Is Optislang required to pay the license?
Finally, from your experience, which methods (or other methods you could think of) do you suggest for my case?Â
Thanks for the help and it will be important to my project!
-
September 15, 2024 at 4:05 amJason SumSubscriber
Could anyone share me some advise please!
-
September 16, 2024 at 12:49 pmMarkusAnsys Employee
Hello Jason Sum,
let me try to answer c). optiSLang is since 24R2 part of the Student Package: Download Ansys Student | Workbench-based Simulation Tools
 An overview about differences of optiSLang and DesignXplorer is given here: Optislang and designXplorer (ansys.com)
 I hope this helps you.Â
Best regards,
Markus
-
September 16, 2024 at 1:02 pmAkram RadwanAnsys Employee
Dear Jason,
I'm only referring to part (b) of your questions.
Â
Everything you need for this scenario exists in Fluent, but it might not be obvious how to use it for this specific use case.
There are three workflows: one manual and two variations with the gradient-based optimizer.
All three use the same underlying technology by combining multiple sensitivity fields. Therefore, the challenges are also comparable:
- Optimizations with multiple conditions are stiff and there might not be one obvious solution.
- You might need to experiment with different weightings by setting target changes for the objectives (e.g., -5%/-5% vs. -0.5%/10% for the target changes for a single design change). It is not possible to know in advance how to set these objectives.
- The used observable (cost function / objective function) plays an important role. It must be valid for both flow directions. Observables with comparable expected outcome can result in different sensitivity fields. For example, optimizing for uniformity or variance should both give the same end result. But since the mathematical formulation of both are quite different, there can be two (or more) possible optimization results. Likewise, optimizing for abs(pressure drop) and (pressure drop)^2 should be comparable (to minimize regardless of flow direction), but only the second is differentiable and should therefore be more stable during the optimization. I strongly recommend thinking about possible objective functions for your problem statement because one might work, a slightly different formulation might not.
Â
Manual workflow
You found the correct source for the manual workflow already. You calculate the two sensitivity fields separately, load both of them, and define how the observables should change.
Â
Gradient-based optimizer
When you only use pressure boundary conditions, you can use the gradient-based optimizer with multiple conditions. See also the Fluent 2024 R2 User's Guide, part III, chapter 48.2.6. Using the Gradient-Based Optimizer. Look for the subsection for "operating conditions" for details.
This workflow is limited to changing input parameters, hence the limitation to just changing the pressure values on either side of the channel.
When you use this, use a fixed step size for the objectives. Adaptive stepping does not work well. And, as mentioned above, you might need to experiment with weighting the objectives for the two conditions to be able to improve the design at all.
Gradient-based optimizer with different boundary condition types
If you need velocity or mass flow inlet vs. pressure outlet boundary conditions, you can do this with the same gradient-based optimizer, but you need a few lines of script to change the type based on the value of an input parameter.- Create an expression with a fixed-value input parameter. For example, a value of 0 is the primary flow direction, a different value the reverse.
- Setup the optimization like in the previous workflow.
- Create an execute command with the code to change the boundary conditions. In the current version you can only use Scheme to do this, PyFluent is not supported for the needed trigger words yet.
The code looks somewhat like the following (untested):
(if (eqv? (get-input-parameter-value 'flow_direction) 0)
 (begin
  ; Execute this for the primary flow direction
  (ti-menu-load-string "/define/boundary-conditions/zone-type opening1 velocity-inlet")
  (ti-menu-load-string "/define/boundary-conditions/zone-type opening2 pressure-outlet")
  (ti-menu-load-string "/define/boundary-conditions/set/velocity-inlet (opening1) vmag 5 q")
 )
 (begin
  ; Execute this for the reversed direction
  (ti-menu-load-string "/define/boundary-conditions/zone-type opening1 pressure-outlet")
  (ti-menu-load-string "/define/boundary-conditions/zone-type opening2 velocity-inlet")
  (ti-menu-load-string "/define/boundary-conditions/set/velocity-inlet (opening1) vmag 5 q")
 )
)
;@before-flowImportant, you must adjust the code to your case:
- Replace "flow_direction" with the name of your expression. The single quote in front of it must be kept!
- Adjust the name of your boundary conditions, here: "opening1" and "opening2", and their respective types for the two flow directions.
- Adjust the text command to set the BCs accordingly.
- Test each text command (see TUI in the documentation) and the script as a whole before you start a single iteration! Each Scheme statement is always within a pair of parenthesis. Indentation and additional white space is ignored by the interpreter.
The ";@before-flow" is needed only within the execute command. Set the command to execute every design iteration and use this trigger word to define when it is executed during the design iterations.
You can find more information in the documentation (same page as above), search for "Execute Commands". Once the script is executed for each flow calculation within the optimizer process, you can use the input parameter in the operating conditions section to change the direction accordingly.
Â
Please also note that scripts written in Scheme are not supported by Ansys. You can use the code but do not expect any technical support if you run into problems. Always save your case before the first use. And then test the code with simple statements and add additional statements slowly. It is very easy to make mistakes with the parenthesis which could turn a case useless, potentially. The statements from the example above are mentioned at different locations in the Fluent documentation, so it should be safe using them.
-
November 6, 2024 at 4:28 amJason SumSubscriber
Â
Dear Akram,
I think the third method you suggested is the most suitable way for my case.Â
As I am not familiar with Scheme scripting, could you advise where the script shall be imported into Fluent (is it loaded in the Execute Commend Interface under adjoint setup? ) and any guides for learning the Scheme scripting please.Â
Thanks!
Â
-
November 12, 2024 at 3:36 pmJason SumSubscriber
Dear Akram,
I would like to update you my latest attemp on adjoint solving with boundary condition interchange, grateful to have your guidance!
This is my approach:Â
1. setting the outlet face flow rate as the observable in adjoint setup2. initialising and running the adjoint solver (currently struggling adjoint residual convergence too)
3. after some settings in design tool, setting up two operation conditions in gradient-based optimiser (1. forward flow, 2. reverse flow) with one input parameter "flow-direction" (0 for forward flow, 1 for reverse flow). Then set up the targets of the observable for the two conditions respectively. (As you guided, the taget percentages of the two conditions should be experimented)
4. Creating a macro in Execute Command under gradient-based optimiser, where the following script saved in the macro and run for each design iteration. I tested the code without the IF condition and it suceeded to run both flow cases automatically without errors, but it is not going well when adding the IF condition and being called as an execute command.
(if (eqv? (get-input-parameter-value 'flow-direction) 0)  (begin    ;; Scheme script for setting boundary conditions in Fluent - Forward    (display "Setting boundary conditions...\n")    ;; Set pressure inlet for zone 6 with a total pressure of 0 Pa    (ti-menu-load-string "define/boundary-conditions/zone-type 6 pressure-inlet")   (ti-menu-load-string "define/boundary-conditions pressure-inlet 6 yes no 0 no 0 no yes no no yes 5 10 q")   ;; Set pressure outlet for zone 7 with a gauge pressure of -50 Pa   (ti-menu-load-string "define/boundary-conditions/zone-type 7 pressure-outlet")  (ti-menu-load-string "define/boundary-conditions pressure-outlet 7 yes no -50 no yes no no yes 5 10 yes no no q")  (display "Boundary conditions set successfully.\n")  ;; Initialize and solve forward flow  (display "Simulating forward flow...\n")  (ti-menu-load-string "solve/initialize/hyb-initialization ok")  (ti-menu-load-string "solve/iterate 1500") ;; Adjust iteration count as necessary  ;; Record the flow rate at BC ID 6 (forward flow)  (display "Recording flow rate for forward flow at BC ID 6...\n")  (define forward-flow-rate    (ti-menu-load-string "report/surface-integrals/mass-flow-rate 1 () yes forward-flow"))  (display "Forward flow rate at BC ID 6: ")  (display forward-flow-rate)  (display "\n") )Â;;---------------------------------------------------------------------------------- (begin  ;; Scheme script for setting boundary conditions in Fluent - Reverse  (display "Setting boundary conditions...\n")  ;; Set pressure inlet for zone 6 with a total pressure of -50 Pa  (ti-menu-load-string "define/boundary-conditions/zone-type 6 pressure-outlet")  (ti-menu-load-string "define/boundary-conditions pressure-outlet 6 yes no -50 no yes no no yes 5 10 yes no no q")  ;; Set pressure outlet for zone 7 with a gauge pressure of 0 Pa  (ti-menu-load-string "define/boundary-conditions/zone-type 7 pressure-inlet") (ti-menu-load-string "define/boundary-conditions pressure-inlet 7 yes no -0 no 0 no yes no no yes 5 10 q")  (display "Boundary conditions set successfully.\n")  ;; Initialize and solve reverse flow  (display "Simulating forward flow...\n") (ti-menu-load-string "solve/initialize/hyb-initialization ok") (ti-menu-load-string "solve/iterate 1500") ;; Adjust iteration count as necessary  ;; Record the flow rate at BC ID 6 (reverse flow)  (display "Recording flow rate for reverse flow at BC ID 6...\n")  (define reverse-flow-rate  (ti-menu-load-string "report/surface-integrals/mass-flow-rate 1 () yes reverse-flow"))  (display "Reverse flow rate at BC ID 6: ")  (display reverse-flow-rate)  (display "\n")  ));@before-flow
-
-
September 22, 2024 at 12:21 pmJason SumSubscriber
Dear both,
Thanks for the guide.Â
I am trying the adjoint solver now, and here is the test result of how mesh morphed to minimise flow from left to righ.
The sensitivity and displacement are focused on the bifurcated / diverging zones, which is only a small fine-tuning by the adjoint optimisation.Â
I expected there may be a more significant changes in shape. e.g. twisting in the circular bending to create greater resisitance.Â
So is adjoint solver optimisation just rely on the sensitivity detected in the areas where gradient are the most significant? or should I aim for a topology optimisation instead? How can it be done on Ansys?
Thanks for answering!
-
- You must be logged in to reply to this topic.
- Multi-Objective Shape Optimisation of Tesla Valve
- Creating Fluent Web Apps using optiSLang 2021R2.mp4
- Adjoint Method for Optimising Diodicity of Tesla Valve
- How to access “OSL_DESIGN_DIR” Environmental variable?
- Setup Optimetrics at HFSS 3D Layout Design
- Response constraint not allowing structural optimization to solve.
- Material parameter optimization
- Output parameter as an exported text data file
-
1191
-
513
-
488
-
225
-
209
© 2024 Copyright ANSYS, Inc. All rights reserved.