Applying solution settings#

PyFluent allows you to use settings to interact with solution settings, and initialize and solve.

Steady or transient solution model#

>>> solver_time = solver.settings.setup.general.solver.time
>>> solver_time.get_state()
'steady'
>>> solver_time.allowed_values()
['steady', 'unsteady-1st-order']
>>> solver_time.set_state("unsteady-1st-order")

Pressure-based or density-based solver#

>>> solver_type = solver.settings.setup.general.solver.type
>>> solver_type.get_state()
'pressure-based'
>>> solver_type.allowed_values()
['pressure-based', 'density-based-implicit', 'density-based-explicit']
>>> solver.settings.setup.general.solver.type.set_state("density-based-explicit")
>>> solver_type.get_state()
'density-based-explicit'

Velocity coupling scheme and gradient options#

>>> methods = solver.settings.solution.methods
>>> flow_scheme = methods.p_v_coupling.flow_scheme
>>> flow_scheme.allowed_values()
['SIMPLE', 'SIMPLEC', 'PISO', 'Coupled']
>>> flow_scheme.set_state("Coupled")
>>> gradient_scheme = methods.gradient_scheme
>>> gradient_scheme.allowed_values()
['green-gauss-node-based', 'green-gauss-cell-based', 'least-square-cell-based']
>>> gradient_scheme.set_state("green-gauss-node-based")

Solution controls#

>>> p_v_controls = solver.settings.solution.controls.p_v_controls
>>> explicit_momentum_under_relaxation = p_v_controls.explicit_momentum_under_relaxation
>>> explicit_momentum_under_relaxation.min()
0
>>> explicit_momentum_under_relaxation.max()
1
>>> explicit_momentum_under_relaxation.set_state(0.4)
>>> flow_courant_number = p_v_controls.flow_courant_number
>>> flow_courant_number.min()
0
>>> flow_courant_number.max()
>>> flow_courant_number.set_state(0.3)

Create a report definition#

>>> surface_report_definitions = solver.settings.solution.report_definitions.surface
>>> defn_name = "outlet-temp-avg"
>>> surface_report_definitions[defn_name] = {}
>>> outlet_temperature = surface_report_definitions[defn_name]
>>> outlet_temperature.report_type.set_state("surface-massavg")
>>> outlet_temperature.field.set_state("temperature")

Initialize and solve#

>>> solution = solver.settings.solution
>>> solution.initialization.hybrid_initialize()
>>> solution.run_calculation.iterate(iter_count=100)