FLUENT / PyAnsys (Ansys Fluent Python Console Usage) #1749
Closed
Paul090196
started this conversation in
General
Replies: 2 comments
-
Duplicate of #1763 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you for your response.
…On Wed, Aug 30, 2023 at 11:05 PM Mainak Kundu ***@***.***> wrote:
Closed #1749 <#1749> as
resolved.
—
Reply to this email directly, view it on GitHub
<#1749>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BA73XRW5YUA5MWRMD6YX7NTXX6TJ5ANCNFSM6AAAAAAZ3TLAWA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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