The top-level settings object in Fluent's Pythonic interface is the
solver
. It contains all other settings objects in a
hierarchical structure.
>>> solver
The solver
object contains attributes such as
file
, setup
,
solution
, and results
. These objects
are also instances of settings objects and roughly mirror Fluent's approach to
organizing a simulation (and one that is visible in the Outline View through the Setup,
Solution, Results structure).
A settings object can be one of the primitive types, like
Integer
, Real
,
String
, and Boolean
, or a
container object.
There are three types of container objects: Group
,
NamedObject
, and
ListObject
.
A Group
object is a static container with predefined
child objects that can be accessed via attribute access. For example,
setup.models.energy
refers to the
energy
child of models
child of
the setup
object. The names of the child objects of a group
can be accessed with the child_names
attribute of a
Group
object.
A NamedObject
is a container
holding dynamically created named objects of its specified child type (accessible
via a child_object_type
attribute), similar to a
dictionary. A specified named object can be accessed using the index operator. For
example,
solver.setup.boundary_conditions.velocity_inlet['inlet2']
refers to the velocity_inlet
object with the name
inlet2
. Create named objects using the
create()
method and remove them using the
del
keyword, The current list of named object children can
be accessed with the get_object_names()
function of the
container class. For
example:
>>> contour1 = solver.results.graphics.contour.create("contour-1") >>> solver.results.graphics.contour.get_object_names() ['contour-1'] >>> contour1.field = "pressure" >>> contour1.surfaces_list = ["wall"] >>> contour1.display() . . . >>> del solver.results.graphics.contour["contour-1"] >>> solver.results.graphics.contour.get_object_names()
A ListObject
is a container holding dynamically created
unnamed objects of its specified child type (accessible via a
child_object_type
attribute) in a list. Children of
ListObject
can be accessed using the index operator. For
example,
solver.setup.cell_zone_conditions.fluid['fluid-1'].source_terms['mass'][2]
refers to the third (starting from index 0) mass source entry for the fluid zone
named fluid-1
. The current number of child objects can be
accessed with the get_size()
function.
The state of any object can be accessed by "calling" it. For container objects,
this returns the state of the children as a dictionary (for
Group
and NamedObject
types) or a
list (for ListObject
types):
>>> solver.setup.models.viscous.model() 'k-epsilon-standard' >>> from pprint import pprint >>> pprint (solver.setup.models.energy()) {'enabled': True, 'inlet_diffusion': True, 'kinetic_energy': False, 'pressure_work': False, 'viscous_dissipation': False} >>> solver.setup.boundary_conditions.velocity_inlet['inlet1'].vmag.constant() 10.0
To modify the state of any object, you can assign the corresponding attribute in
its parent object. This assignment can be done at any level. For
Group
and NamedObject
type
objects, the state value is a dictionary. For ListObject
type objects, the state value is a list.
>>> solver.setup.models.viscous.model = 'laminar' >>> solver.setup.models.energy = { 'enabled' : False } >>> solver.setup.boundary_conditions.velocity['inlet1'].vmag.constant = 14
The state of an object can also be accessed with the
get_state()
method and modified with the
set_state()
method.
The current state can also be printed in a simple text format with the
print_state()
method. For example, assume you
entered:
>>> solver.setup.models.print_state()
Output is displayed in the following format:
viscous : k_epsilon_model : standard near_wall_treatment : standard-wall-fn? model : k-epsilon-standard options : viscous_heating : False curvature_correction : False production_kato_launder : False production_limiter : False energy : enabled : True pressure_work : False viscous_dissipation : False inlet_diffusion : True kinetic_energy : False multiphase : number_of_phases : 0 models : none
Commands are methods of settings objects that you use to modify the state of the
application. For example, the hybrid_initialize()
method of
solution.initialization
initializes the solution using the
hybrid initialization method. The command_names
attribute
of a settings object provides the names of its commands.
If needed, commands can be passed keyword arguments, and the list of valid
arguments can be accessed using the arguments
attribute. If
an argument is not specified, its default value is used. Arguments are also settings
objects and can be either the primitive type or the container type.
For example:
>>>solver.solution.run_calculation.iterate.argument_names ['iter_count'] >>> solver.solution.run_calculation.iterate(iter_count=2) iter continuity x-velocity y-velocity z-velocity energy k epsilon time/iter 1 1.0000e+00 3.3399e+00 4.5158e-02 0.0000e+00 1.1371e-09 4.8996e-02 1.4475e+00 0:00:00 1 2 1.0000e+00 1.7086e-01 1.4975e-01 1.0733e-01 1.6440e-10 1.3899e+00 7.8817e+00 0:00:00 0