automatization using pyfluent #1763
Replies: 5 comments
-
In 2023 R1 Fluent, we don't seem to support convergence criteria in settings API. You can use the TUI API as mentioned in #1766. The settings "Print to Console" are within
"Compute from" also doesn't seem to be in settings API, try to transform the corresponding TUI call to set it from Python. |
Beta Was this translation helpful? Give feedback.
-
Subject: Re: Assistance Needed with PyFluent Scripting
Dear Sir,
I hope this email finds you well. I want to extend my gratitude for your
prompt response and the code snippet you provided to help me to plot the
report definitions in PyFluent. However, I must admit that I'm encountering
some difficulties in implementing it effectively.
As I mentioned earlier, I am relatively new to the field of coding, and I
find it a bit challenging to fully grasp the intricacies of the provided
code. While I understand the importance of scripting for automating my
parametric study, I'm struggling to integrate the code into my existing
workflow.
Considering my current level of familiarity with coding, I was wondering if
it would be possible for you to provide a more detailed example of how I
can use the code to achieve my goal. An example to activate the
print-to-console option for the "report definitions" that includes
step-by-step instructions or explanations would greatly aid my
understanding and help me bridge the gap between theory and practical
application.
I truly value your expertise and support, and I'm committed to learning and
improving my coding skills. Having a practical example to work from would
undoubtedly contribute significantly to my understanding of how to activate
the "print to console option and write file underreport definition " using
PyFluent's scripting interface.
Thank you once again for your willingness to assist me in overcoming this
challenge. I look forward to your continued guidance and hope to
successfully implement this functionality in my simulations.
Best regards,
Paul Stephen
…On Tue, Jul 18, 2023 at 10:28 PM Mainak Kundu ***@***.***> wrote:
In 2023 R1 Fluent, we don't seem to support convergence criteria in
settings API. You can use the TUI API as mentioned in #1766
<#1766>.
The settings "Print to Console" are within solver.solution.monitor.
Execute solver.solution.monitor() to get the full state dictionary from
which you can figure out the path of the individual settings. You can also
use find_children to find the child settings paths:
>>> from ansys.fluent.core.solver.flobject import find_children
>>> find_children(solver.solution, "*plots*")
['monitor/report_plots']
>>> find_children(solver.solution, "*print*")
['monitor/report_files/print', 'monitor/report_plots/print', 'monitor/convergence_conditions/convergence_reports/print']
"Compute from" also doesn't seem to be in settings API, try to transform
the corresponding TUI call to set it from Python.
—
Reply to this email directly, view it on GitHub
<#1763 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BA73XRW2FJILCJ7VLB6SXK3XQ3WWZANCNFSM6AAAAAA2ANGVKQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Subject: Assistance Required: Enabling Print-to-Console and Plotting Thrust
Force Using Report Definitions
Hello Sir,
I hope this email finds you well. I am reaching out to seek your guidance and assistance with an issue I am facing while attempting to utilize report definitions in Ansys Fluent through PyFluent.
In continuation with our previous discussions, I have been trying to extract and plot the thrust force from the report definition using the provided options. Specifically, I aimed to enable the "print-to-console" option, as well as the "report file" and "report plot" options. Unfortunately, despite following your earlier suggestions, I have encountered challenges in achieving the desired outcome.
To provide more context, I used the following code:
1)TO DEFINE THE THRUST FORCE
solver.solution.report_definitions.force.set_state({'thrust-force': {'average_over': 1, 'per_zone': False, 'thread_names': ["blades"], 'force_vector': [0.0, 0.0, 1.0]}})
2) TO OBTAIN THE REPORT FILE OPTION UNDER THE MONITORS
solver.solution.monitor.report_files.set_state({'thrust-force_file': {'name': 'thrust-force_file', 'file_name': '.\\report-file-0.out', 'frequency': 1, 'itr_index': '1', 'run_index': '0', 'frequency_of': 'iteration', 'report_defs': [], 'print': True, 'active': True, 'write_instantaneous_values': False}})
3)TO OBTAIN THE RPORT PLOT OPTION UNDER MONITORS
solver.solution.monitor.report_plots.set_state({'thrust_force_plot': {'name': 'thrust_force_plot', 'plot_window': False, 'frequency': 1, 'frequency_of': 'iteration', 'report_defs': [], 'print': True, 'title': 'report-plot-0', 'x_label': 'iteration', 'y_label': '', 'active': True, 'plot_instantaneous_values': False}})
However, even after attempting to enable these options, the thrust force data does not seem to be getting plotted on the console as expected. Moreover, in this process, I have encountered a new error message that is impeding my progress.
I would be more than willing to share additional details to aid in diagnosing the issue. I have captured an image of the new error that I encountered, and I can also provide you with the code snippets that I utilized in this attempt.
Your expertise and support have been invaluable to me, and I am grateful for your dedication in helping me overcome these challenges. I look forward to your response and guidance.
Thank you and best regards,
Paul
![Inkedstandard initialization (1)](https://github.com/ansys/pyfluent/assets/138394566/f6cb755c-de91-4b07-9298-3e4eeb939439)
…On Tue, Jul 18, 2023 at 10:28 PM Mainak Kundu ***@***.***> wrote:
In 2023 R1 Fluent, we don't seem to support convergence criteria in
settings API. You can use the TUI API as mentioned in #1766
<#1766>.
The settings "Print to Console" are within solver.solution.monitor.
Execute solver.solution.monitor() to get the full state dictionary from
which you can figure out the path of the individual settings. You can also
use find_children to find the child settings paths:
>>> from ansys.fluent.core.solver.flobject import find_children
>>> find_children(solver.solution, "*plots*")
['monitor/report_plots']
>>> find_children(solver.solution, "*print*")
['monitor/report_files/print', 'monitor/report_plots/print', 'monitor/convergence_conditions/convergence_reports/print']
"Compute from" also doesn't seem to be in settings API, try to transform
the corresponding TUI call to set it from Python.
—
Reply to this email directly, view it on GitHub
<#1763 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BA73XRW2FJILCJ7VLB6SXK3XQ3WWZANCNFSM6AAAAAA2ANGVKQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Assuming you are using Ansys 2023 R1, the following script will print thrust-force to console at every iteration:
|
Beta Was this translation helpful? Give feedback.
-
@Paul090196 I am interested in this PyFluent project. When altering the angle of attack on the Aerofoil, did you use a parametric study to do it? And were you changing the force vectors of lift and drag to represent the change in angle of attack? Thanks, Tom |
Beta Was this translation helpful? Give feedback.
-
I am currently working on automating the calculation of drag and lift coefficients for an airfoil using Ansys Fluent's Python Console in the 2023 R1 version. I have successfully obtained the desired values using the graphical user interface and now aim to automate the process for different angles of attack.
I have implemented a "for loop" in my script to specify the angles of attack, and the simulation runs successfully until it converges for each angle. However, I encountered an issue when generating the simulation reports. The previously obtained values are being overwritten, resulting in incorrect reports. I have attached an image that clearly shows how the results for previously printed values are changing when the solution runs for subsequent angles of attack. I believe there might be a step missing in my script to ensure that the reports are saved separately for each iteration of the loop. If anyone has encountered a similar issue or has suggestions to resolve this problem, your input would be highly appreciated.
Here is a simplified version of my script for reference:
import math
V_infinity =c
alpha = [a,b]
for i in range (len(alpha)):
solver.setup.boundary_conditions.velocity_inlet.set_state({'inlet': {'velocity_spec': 'Components', 'velocity': [{'option': 'value', 'value': (V_infinity*((math. cos((alpha[i])0.01745329))))}, {'option': 'value', 'value': (V_infinity((math. sin((alpha[i])*0.01745329))))}, {'option': 'value', 'value': 0}]}})
solver.solution.report_definitions.lift[f"Lift-Coefficient at {i}"]={}
solver.solution.report_definitions.lift[f"Lift-Coefficient at {i}"].force_vector.set_state([-((math.sin((alpha[i])*0.01745329))),((math.cos((alpha[i])*0.01745329))),0])
solver.solution.report_definitions.lift[f"Lift-Coefficient at {i}"].thread_names=['airfoil']
solver.solution.report_definitions.drag[f"drag-Coefficient at {i}"]={}
solver.solution.report_definitions.drag[f"drag-Coefficient at {i}"].force_vector.set_state([((math.cos((alpha[i])*0.01745329))),((math.sin((alpha[i])*0.01745329))),0])
solver.solution.report_definitions.drag[f"drag-Coefficient at {i}"].thread_names=['airfoil']
solver.setup.reference_values.velocity.set_state(V_infinity)
solver.setup.reference_values.compute.from_zone_name.set_state("inlet")
solver.solution.monitor.convergence_conditions.condition.set_state('all-conditions-are-met')
solver.solution.initialization.standard_initialize()
solver.solution.initialization.set_defaults.set_state({'pressure':0,'x-velocity': (V_infinity*((math. cos((alpha[i])0.01745329)))), 'y-velocity': (V_infinity((math. sin((alpha[i])*0.01745329)))), 'k': e, 'omega': f})
solver.solution.run_calculation.iterate(iter_count=z)
solver.report.simulation_reports.generate_simulation_report()
solver.report.simulation_reports.generate_simulation_report.report_name.set_state(f"Report at {i}"))
Additionally, I am interested in modifying the convergence criteria for residuals in my simulations. I would like to adjust the values of the absolute criteria from [1e-3] to [1e-6] using the Python Console. Could someone kindly explain the process of changing the values of residuals programmatically? I believe modifying these criteria would help me achieve better convergence in my simulations.
Furthermore, while defining report definitions such as the lift coefficient, I would like to know how to select the option "Print to Console", "Report_Files" and 'Report_Plots' to print the results directly to the console using the Python Console. This feature would be extremely useful for real-time monitoring and analysis during simulations. If anyone has experience with this option or knows the appropriate method to accomplish it programmatically, I would greatly appreciate your insights.
Lastly, within the PyAnsys environment, there is an Initialization tab that offers various options. I am initializing the solution with standard initialize, However, I am unsure about the process of choosing between the "Compute from "options programmatically using which allows to initialize the boundaries with the specified initial values. It would be immensely helpful if someone could provide guidance on how to make the appropriate selection based on specific simulation requirements.
Thank you all in advance for your time and expertise. I look forward to your valuable suggestions and insights to overcome these challenges and enhance my automation process in Ansys Fluent
Beta Was this translation helpful? Give feedback.
All reactions