pyfluent code

Jinane Radi
Jinane Radi Member Posts: 5
Name Dropper First Comment

hello everyone , I'm new in using pyfluent ,I've created this code from a YouTube video
concerning the utilization of pyfluent .
the code works perfectly until the line when Fluent should switch to solution mode. its gives me this error

the code I have written is below

import ansys.fluent.core as pyfluent
meshing_session = pyfluent.launch_fluent(precision="double", processor_count=2, mode ="meshing" ,show_gui=True)

workflow.InitializeWorkflow(WorkflowType=r'Fault-tolerant Meshing')
workflow.InitializeWorkflow(WorkflowType=r'Watertight Geometry')
workflow.TaskObject['Import Geometry'].Arguments.set_state({r'FileName': r'C:/Users/DELL/Desktop/Fluent ANSYS/Static Mixer geometry.dsco',})
workflow.TaskObject['Import Geometry'].Execute()

workflow.TaskObject['Add Local Sizing'].AddChildAndUpdate()
workflow.TaskObject['Generate the Surface Mesh'].Execute()
workflow.TaskObject['Describe Geometry'].UpdateChildTasks(SetupTypeChanged=False)
workflow.TaskObject['Describe Geometry'].Arguments.set_state({r'SetupType': r'The geometry consists of only fluid regions with no voids',})
workflow.TaskObject['Describe Geometry'].UpdateChildTasks(SetupTypeChanged=True)
workflow.TaskObject['Describe Geometry'].Execute()
workflow.TaskObject['Update Boundaries'].Execute()
workflow.TaskObject['Update Regions'].Execute()
workflow.TaskObject['Add Boundary Layers'].AddChildAndUpdate()
workflow.TaskObject['Generate the Volume Mesh'].Execute()
solver.execute_tui(r'''(newline)''') = {"enabled" : True}'fluid', 'water-liquid')
solver.setup.cell_zone_conditions.fluid['fluid'] = {"material" : "water-liquid"}
solver.setup.boundary_conditions.velocity_inlet['velocity-inlet-1'] = {"vmag" : 0.}
solver.setup.boundary_conditions.velocity_inlet['velocity-inlet-1'] = {"vmag" : 0.}
solver.setup.boundary_conditions.velocity_inlet['velocity-inlet-2'] = {"vmag" : 1.}
solver.setup.boundary_conditions.velocity_inlet['velocity-inlet-2'] = {"vmag" : 1.}
solver.solution.run_calculation.iterate(iter_count = 20)



  • PabloA
    PabloA Member, Employee Posts: 2
    Name Dropper First Comment First Anniversary Ansys Employee
    edited January 31

    Hi Jinane,

    execute_tui is not available for meshing interface. As good practices, please do not use scheme or journal commands if they can be avoided. You can fix your problem by using

    solver = meshing_session.switch_to_solver()

    instead of the journal command.


  • Jinane Radi
    Jinane Radi Member Posts: 5
    Name Dropper First Comment

    Hello Mr.Pabloa , thank you so much , it works perfectly .

    Since I am a beginner in using pyfluent , what do you mean by not using scheme or journal commands ?

    by the way , Do you have any ideas on how to save this work, for example, in a folder such as a fluent file?