Replies: 1 comment
-
Maybe this is not exactly what you asked for, but here is a solution that worked for me. I use a # Initialize iteration parameters
iteration_count = 0
max_iterations = 1000 # Maximum number of iterations
report_interval = 100 # Interval after which to check convergence
# Function to check if the simulation has converged
def has_converged():
# Implement your specific convergence condition here
# Return True if convergence criteria are met
if (...): # Replace with your actual condition
return True
return False
# Main simulation loop
running = True
while running:
# Run simulation for a specified interval
solver.run(iteration_count=report_interval)
iteration_count += report_interval # Update iteration count
# Check for convergence after the interval
if has_converged():
print(f"Convergence achieved after {iteration_count} iterations.")
break # Exit loop if convergence is reached
# Stop if maximum iterations are reached
if iteration_count >= max_iterations:
print("Maximum number of iterations reached. Stopping simulation.")
break |
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
-
I have a simulation started with PyFluent in a Jupyter notebook, and want to stop the simulation without loosing the data. How can I do this?
Beta Was this translation helpful? Give feedback.
All reactions