# PyFluent - Python Interface for Ansys Fluent PyFluent provides comprehensive Pythonic access to Ansys Fluent's computational fluid dynamics (CFD) capabilities. This library enables seamless integration of Fluent within the Python ecosystem, allowing users to automate simulation workflows, perform parametric studies, and extract field data programmatically. PyFluent supports both solver and meshing operations, offering access to Fluent's text user interface (TUI) commands, settings API, workflow automation, and built-in postprocessing capabilities. The library is designed for engineers and researchers who need to integrate CFD simulations into broader Python-based workflows, automate repetitive tasks, run parametric studies at scale, or build custom applications on top of Fluent's powerful simulation engine. PyFluent supports various deployment modes including local standalone execution, Docker containers, and HPC cluster environments with job schedulers like Slurm. ## Launching Fluent and Creating Sessions ### launch_fluent - Start a Fluent Session Start a new Fluent session locally or in a containerized environment with full control over simulation parameters. ```python import ansys.fluent.core as pyfluent from ansys.fluent.core import examples # Launch solver session with double precision on 4 processors solver = pyfluent.launch_fluent( product_version="25.1", dimension=pyfluent.Dimension.THREE, precision="double", processor_count=4, mode="solver", ui_mode=pyfluent.UIMode.NO_GUI ) # Download and load example mesh mesh_file = examples.download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow") solver.settings.file.read_case(file_name=mesh_file) # Verify mesh quality solver.mesh.check() print(f"Connected to Fluent {solver.get_fluent_version()}") # Perform simulation setup and solve solver.settings.models.energy.enabled = True solver.settings.solution.initialization.hybrid_initialize() solver.settings.solution.run_calculation.iterate(iter_count=100) # Cleanup solver.exit() ``` ### connect_to_fluent - Connect to Existing Session Connect to a running Fluent instance using IP, port, and password or server-info file. ```python import ansys.fluent.core as pyfluent # Connect using explicit connection parameters solver = pyfluent.connect_to_fluent( ip="192.168.1.100", port=12345, password="fluent_password" ) # Or connect using server-info file solver = pyfluent.connect_to_fluent( server_info_file_name="/path/to/serverinfo-fluent.txt", cleanup_on_exit=False # Don't shutdown Fluent when done ) # Use the connected session print(f"Server healthy: {solver.is_server_healthy()}") solver.tui.mesh.check() ``` ### launch_fluent with Advanced Options Launch Fluent with GPU acceleration, container configuration, and HPC scheduler integration. ```python import ansys.fluent.core as pyfluent # Launch with GPU solver using specific GPUs solver = pyfluent.launch_fluent( mode="solver", processor_count=4, gpu=[0, 1], # Use GPU 0 and 1 precision="double" ) # Launch in Docker container with custom configuration solver = pyfluent.launch_fluent( container_dict={ "image": "ghcr.io/ansys/fluent:25.1", "mount_source": "/home/user/fluent_data", "mount_target": "/fluent_data" }, cwd="/fluent_data", processor_count=2 ) # Launch on Slurm cluster (returns SlurmFuture) slurm_future = pyfluent.launch_fluent( scheduler_options={ "scheduler": "slurm", "scheduler_headnode": "cluster-head.domain.com", "scheduler_queue": "standard", "scheduler_account": "research_project" }, processor_count=16, mode="solver" ) solver = slurm_future.result() # Wait for job allocation and startup ``` ## Settings API for Solver Configuration ### Material and Cell Zone Configuration Configure fluid properties and assign materials to cell zones using the hierarchical settings API. ```python import ansys.fluent.core as pyfluent solver = pyfluent.launch_fluent(mode="solver", processor_count=2) solver.settings.file.read_case(file_name="mixing_elbow.cas.h5") # Enable energy equation solver.settings.models.energy.enabled = True # Import material from database solver.settings.materials.database.copy_by_name( type="fluid", name="water-liquid" ) # Assign material to cell zone solver.settings.cell_zone_conditions.fluid["elbow-fluid"].material = "water-liquid" # Configure turbulence model solver.settings.models.viscous.model = "k-omega" solver.settings.models.viscous.k_omega_options.model = "sst" # Verify configuration print(f"Energy model enabled: {solver.settings.models.energy.enabled}") print(f"Fluid material: {solver.settings.cell_zone_conditions.fluid['elbow-fluid'].material}") ``` ### Boundary Conditions Setup Define inlet, outlet, and wall boundary conditions with momentum and thermal specifications. ```python import ansys.fluent.core as pyfluent solver = pyfluent.launch_fluent(mode="solver", processor_count=2) solver.settings.file.read_case(file_name="elbow.cas.h5") solver.settings.models.energy.enabled = True # Configure cold inlet cold_inlet = solver.settings.boundary_conditions.velocity_inlet["cold-inlet"] cold_inlet.momentum.velocity_magnitude.value = 0.4 # m/s cold_inlet.thermal.temperature.value = 293.15 # K (20°C) cold_inlet.turbulence.turbulence_specification = "Intensity and Hydraulic Diameter" cold_inlet.turbulence.turbulent_intensity = 0.05 cold_inlet.turbulence.hydraulic_diameter.value = 0.1 # meters # Configure hot inlet hot_inlet = solver.settings.boundary_conditions.velocity_inlet["hot-inlet"] hot_inlet.momentum.velocity_magnitude.value = 1.2 # m/s hot_inlet.thermal.temperature.value = 313.15 # K (40°C) # Configure pressure outlet outlet = solver.settings.boundary_conditions.pressure_outlet["outlet"] outlet.momentum.gauge_pressure.value = 0 # Pa # Configure wall with heat flux wall = solver.settings.boundary_conditions.wall["elbow-wall"] wall.thermal.thermal_condition = "Heat Flux" wall.thermal.heat_flux.value = 1000 # W/m² print("Boundary conditions configured successfully") ``` ### Solution Initialization and Execution Initialize flow field and run iterative calculations with residual monitoring. ```python import ansys.fluent.core as pyfluent from ansys.fluent.core.streaming_services.events_streaming import SolverEvent solver = pyfluent.launch_fluent(mode="solver", processor_count=4) solver.settings.file.read_case(file_name="configured_case.cas.h5") # Set solution methods solver.settings.solution.methods.p_v_coupling.scheme = "Coupled" solver.settings.solution.methods.discretization_scheme.pressure = "Second Order" solver.settings.solution.methods.discretization_scheme.momentum = "Second Order Upwind" solver.settings.solution.methods.discretization_scheme.energy = "Second Order Upwind" # Configure solution controls solver.settings.solution.controls.advanced.enable_pseudo_time_method = True solver.settings.solution.controls.pseudo_time_settings.time_step_method = "Automatic" # Register callback for iteration monitoring def on_iteration(session, event_info): print(f"Iteration {event_info.index} completed") solver.events.register_callback(SolverEvent.ITERATION_ENDED, on_iteration) # Initialize solution print("Initializing solution...") solver.settings.solution.initialization.hybrid_initialize() # Run calculation print("Running calculation...") solver.settings.solution.run_calculation.iterate(iter_count=500) # Save results solver.settings.file.write_case_data(file_name="converged_solution.cas.h5") ``` ## Field Data Extraction and Post-Processing ### Scalar Field Data Extraction Extract scalar field data (pressure, temperature, density) from surfaces with boundary values. ```python import ansys.fluent.core as pyfluent from ansys.fluent.core import ScalarFieldDataRequest import numpy as np solver = pyfluent.launch_fluent(mode="solver", processor_count=2) solver.settings.file.read_case_data(file_name="solved_case.cas.h5") # Request temperature data from wall surfaces request = ScalarFieldDataRequest( field_name="temperature", surfaces=["hot-inlet", "cold-inlet", "elbow-wall"], node_value=True, boundary_value=True ) # Get field data data = solver.fields.field_data.get_field_data(request) # Process results for surface_name, surface_data in data.items(): temps = surface_data['temperature'] print(f"\nSurface: {surface_name}") print(f" Temperature range: {np.min(temps):.2f} - {np.max(temps):.2f} K") print(f" Average temperature: {np.mean(temps):.2f} K") print(f" Data points: {len(temps)}") ``` ### Vector Field Data Extraction Extract vector field data (velocity, momentum) from specified surfaces with magnitude calculations. ```python import ansys.fluent.core as pyfluent from ansys.fluent.core import VectorFieldDataRequest import numpy as np solver = pyfluent.launch_fluent(mode="solver", processor_count=2) solver.settings.file.read_case_data(file_name="flow_solution.cas.h5") # Request velocity vectors from inlet request = VectorFieldDataRequest( field_name="velocity", surfaces=["inlet", "outlet"] ) velocity_data = solver.fields.field_data.get_field_data(request) # Calculate velocity magnitudes for surface_name, surface_data in velocity_data.items(): vel_x = surface_data['velocity'][0] # X-component vel_y = surface_data['velocity'][1] # Y-component vel_z = surface_data['velocity'][2] # Z-component magnitude = np.sqrt(vel_x**2 + vel_y**2 + vel_z**2) print(f"\n{surface_name}:") print(f" Max velocity: {np.max(magnitude):.3f} m/s") print(f" Min velocity: {np.min(magnitude):.3f} m/s") print(f" Mean velocity: {np.mean(magnitude):.3f} m/s") ``` ### Surface Data Extraction with Connectivity Extract surface mesh data including vertices, face connectivity, normals, and centroids. ```python import ansys.fluent.core as pyfluent from ansys.fluent.core import SurfaceFieldDataRequest, SurfaceDataType solver = pyfluent.launch_fluent(mode="solver", processor_count=2) solver.settings.file.read_case_data(file_name="case.cas.h5") # Request comprehensive surface data request = SurfaceFieldDataRequest( data_types=[ SurfaceDataType.Vertices, SurfaceDataType.FacesConnectivity, SurfaceDataType.FacesNormal, SurfaceDataType.FacesCentroid ], surfaces=["wall-1", "inlet"], overset_mesh=False, flatten_connectivity=True ) surface_data = solver.fields.field_data.get_field_data(request) # Process mesh topology for surface_name, data in surface_data.items(): vertices = data['vertices'] # Nx3 array of vertex coordinates connectivity = data['faces'] # Face-to-vertex connectivity normals = data['face-normal'] # Face normal vectors centroids = data['face-centroid'] # Face centroids print(f"\n{surface_name}:") print(f" Vertices: {vertices.shape}") print(f" Faces: {len(connectivity)}") print(f" Normals: {normals.shape}") ``` ### Batch Field Data Requests Create batched requests for multiple fields to optimize data transfer performance. ```python import ansys.fluent.core as pyfluent from ansys.fluent.core import ( ScalarFieldDataRequest, VectorFieldDataRequest, SurfaceFieldDataRequest, SurfaceDataType ) solver = pyfluent.launch_fluent(mode="solver", processor_count=2) solver.settings.file.read_case_data(file_name="results.cas.h5") # Create batch with multiple requests batch = solver.fields.field_data.new_batch() # Add multiple field requests batch.add_requests( ScalarFieldDataRequest(field_name="pressure", surfaces=["inlet", "outlet"]), ScalarFieldDataRequest(field_name="temperature", surfaces=["wall"]), VectorFieldDataRequest(field_name="velocity", surfaces=["inlet"]), SurfaceFieldDataRequest( data_types=[SurfaceDataType.Vertices, SurfaceDataType.FacesConnectivity], surfaces=["wall"] ) ) # Execute all requests in single transaction results = batch.get_response() # Access results by request type pressure_data = results['ScalarFieldDataRequest']['pressure'] temperature_data = results['ScalarFieldDataRequest']['temperature'] velocity_data = results['VectorFieldDataRequest']['velocity'] surface_mesh = results['SurfaceFieldDataRequest']['wall'] print(f"Retrieved {len(results)} field data types in batch") ``` ### Pathlines Generation and Extraction Generate and extract pathline data for flow visualization with particle tracking. ```python import ansys.fluent.core as pyfluent from ansys.fluent.core import PathlinesFieldDataRequest solver = pyfluent.launch_fluent(mode="solver", processor_count=2) solver.settings.file.read_case_data(file_name="flow_field.cas.h5") # Configure pathlines request request = PathlinesFieldDataRequest( field_name="velocity-magnitude", surfaces=["inlet"], steps=1000, step_size=0.001, # seconds skip=0, reverse=False, zones=None, accuracy_control_on=True, tolerance=0.001 ) # Generate and extract pathlines pathlines_data = solver.fields.field_data.get_field_data(request) # Process pathline results vertices = pathlines_data['vertices'] # All pathline points lines = pathlines_data['lines'] # Connectivity for each pathline velocities = pathlines_data['velocity-magnitude'] # Field values along paths particle_time = pathlines_data['particle-time'] # Time at each point print(f"Generated {len(lines)} pathlines") print(f"Total pathline points: {len(vertices)}") print(f"Velocity range: {velocities.min():.3f} - {velocities.max():.3f} m/s") ``` ## Parametric Studies and Design Exploration ### Local Parametric Study Definition Define parametric studies locally with multiple design points before submitting to Fluent. ```python from ansys.fluent.core.parametric import LocalParametricStudy import ansys.fluent.core as pyfluent # Create local parametric study from case file study = LocalParametricStudy(case_filepath="/path/to/elbow_parametric.cas.h5") # Configure base design point base_dp = study.design_point("Base DP") base_dp.input_parameters['inlet_velocity'] = 1.0 base_dp.input_parameters['inlet_temperature'] = 300.0 # Add design points with varying parameters for i in range(1, 21): dp = study.add_design_point(f"design_point_{i}") dp.input_parameters['inlet_velocity'] = 0.5 + (i * 0.1) # 0.6 to 2.5 m/s dp.input_parameters['inlet_temperature'] = 290 + (i * 2) # 292 to 330 K # Display study configuration print(f"Total design points: {len(study.design_point_table)}") for dp in study.design_point_table[:3]: print(f"{dp.name}: velocity={dp.input_parameters['inlet_velocity']:.2f}, " f"temp={dp.input_parameters['inlet_temperature']:.1f}") ``` ### Running Parametric Studies in Parallel Execute parametric studies across multiple Fluent instances for parallel evaluation. ```python from ansys.fluent.core.parametric import LocalParametricStudy # Create and configure study (as shown above) study = LocalParametricStudy(case_filepath="parametric_case.cas.h5") base_dp = study.design_point("Base DP") base_dp.input_parameters['inlet_velocity'] = 1.0 for i in range(1, 51): dp = study.add_design_point(f"dp_{i}") dp.input_parameters['inlet_velocity'] = i * 0.05 # Run study on 8 parallel Fluent servers print("Starting parametric study execution...") study.run_in_fluent( num_servers=8, start_transcript=False, capture_report_data=True ) # Process results print("\nParametric Study Results:") print("-" * 80) for dp in study.design_point_table: vel = dp.input_parameters['inlet_velocity'] # Output parameters populated after execution if dp.output_parameters: pressure_drop = dp.output_parameters.get('pressure_drop', 'N/A') avg_temp = dp.output_parameters.get('average_temperature', 'N/A') print(f"{dp.name}: vel={vel:.2f} m/s, ΔP={pressure_drop}, T_avg={avg_temp}") else: print(f"{dp.name}: vel={vel:.2f} m/s, Status=Not completed") ``` ## Meshing Workflows and Mesh Generation ### Watertight Meshing Workflow Create high-quality volume mesh from CAD geometry using watertight workflow. ```python import ansys.fluent.core as pyfluent from ansys.fluent.core import examples # Launch meshing mode meshing = pyfluent.launch_fluent(mode="meshing", processor_count=4) # Download example geometry cad_file = examples.download_file("exhaust_system.pmdb", "pyfluent/exhaust_system") # Initialize watertight geometry workflow meshing.workflow.InitializeWorkflow(WorkflowType="Watertight Geometry") # Import CAD geometry import_geom = meshing.workflow.TaskObject["Import Geometry"] import_geom.Arguments = {"FileName": cad_file, "LengthUnit": "mm"} import_geom.Execute() # Add local sizing controls add_local_sizing = meshing.workflow.TaskObject["Add Local Sizing"] add_local_sizing.AddChildToTask() local_sizing = meshing.workflow.TaskObject["Add Local Sizing"].TaskObject["inlet_sizing"] local_sizing.Arguments = { "BOIControlName": "inlet", "BOIExecution": "Body Of Influence", "BOISize": 2.5 } add_local_sizing.Execute() # Generate surface mesh generate_surface = meshing.workflow.TaskObject["Generate the Surface Mesh"] generate_surface.Arguments = { "CFDSurfaceMeshControls": { "MinSize": 0.5, "MaxSize": 10.0, "GrowthRate": 1.2 } } generate_surface.Execute() # Improve surface mesh quality improve_surface = meshing.workflow.TaskObject["Improve Surface Mesh"] improve_surface.Execute() # Generate volume mesh generate_volume = meshing.workflow.TaskObject["Generate the Volume Mesh"] generate_volume.Arguments = { "VolumeFill": "poly-hexcore", "VolumeFillControls": { "HexMaxCellLength": 15.0 } } generate_volume.Execute() # Check mesh quality print("Mesh quality check:") meshing.tui.mesh.check_quality() # Switch to solver solver = meshing.switch_to_solver() print("Successfully switched to solver mode") ``` ### Fault-Tolerant Meshing Workflow Generate mesh from imperfect CAD geometry using fault-tolerant workflow. ```python import ansys.fluent.core as pyfluent # Launch meshing meshing = pyfluent.launch_fluent(mode="meshing", processor_count=4) # Initialize fault-tolerant workflow meshing.workflow.InitializeWorkflow(WorkflowType="Fault-tolerant Meshing") # Import geometry import_cad = meshing.workflow.TaskObject["Import CAD and Part Management"] import_cad.Arguments = { "FileName": "/path/to/geometry.scdoc", "LengthUnit": "in" } import_cad.Execute() # Update regions update_regions = meshing.workflow.TaskObject["Update Regions"] update_regions.Execute() # Update boundaries update_boundaries = meshing.workflow.TaskObject["Update Boundaries"] update_boundaries.Arguments = { "BoundaryLabelList": ["inlet", "outlet", "wall"], "BoundaryLabelTypeList": ["velocity-inlet", "pressure-outlet", "wall"] } update_boundaries.Execute() # Define size functions describe_geom = meshing.workflow.TaskObject["Describe Geometry"] describe_geom.Arguments = {"SetupType": "The geometry consists of only fluid regions with no voids"} describe_geom.Execute() # Generate surface mesh generate_surface = meshing.workflow.TaskObject["Generate the Surface Mesh"] generate_surface.Arguments = {"SurfaceMeshControls": {"MaxSize": 5.0}} generate_surface.Execute() # Generate volume mesh generate_volume = meshing.workflow.TaskObject["Generate the Volume Mesh"] generate_volume.Execute() # Write mesh and switch to solver meshing.tui.file.write_mesh("fault_tolerant_mesh.msh.h5") solver = meshing.switch_to_solver() ``` ## TUI (Text User Interface) Commands ### Solver TUI Command Execution Execute Fluent solver commands through hierarchical TUI interface for advanced operations. ```python import ansys.fluent.core as pyfluent solver = pyfluent.launch_fluent(mode="solver", processor_count=2) # File operations solver.tui.file.read_case("simulation.cas.h5") # Mesh operations solver.tui.mesh.check() solver.tui.mesh.repair_improve.allow_repair_at_boundaries("yes") solver.tui.mesh.scale(0.001, 0.001, 0.001) # mm to m conversion # Models configuration solver.tui.define.models.energy("yes") solver.tui.define.models.viscous.ke_realizable("yes") # Material creation solver.tui.define.materials.copy("fluid", "air") # Boundary condition setup solver.tui.define.boundary_conditions.velocity_inlet( "inlet", # Zone name "yes", # Apply to mixture "no", # Turbulent intensity and length scale "no", # Reference frame 1.5, # Velocity magnitude (m/s) "no", # Temperature specified 300 # Temperature (K) ) # Solution settings solver.tui.solve.set.p_v_coupling(24) # Coupled scheme solver.tui.solve.set.discretization_scheme.pressure(12) # Second order solver.tui.solve.set.discretization_scheme.mom(1) # Second order upwind # Initialize and solve solver.tui.solve.initialize.hybrid_initialize() solver.tui.solve.iterate(200) # Report results solver.tui.report.surface_integrals.area("inlet", "outlet") solver.tui.report.surface_integrals.mass_flow_rate("inlet", "outlet") # Save case and data solver.tui.file.write_case_data("converged.cas.h5") ``` ### Meshing TUI Command Execution Execute meshing operations and quality checks using TUI commands. ```python import ansys.fluent.core as pyfluent meshing = pyfluent.launch_fluent(mode="meshing", processor_count=4) # Import mesh or geometry meshing.tui.file.import_.cad_geometry("model.scdoc", "yes") # Mesh quality checks meshing.tui.mesh.check_quality() meshing.tui.mesh.smooth.smooth("surf-mesh", 20, 0.75) # Boundary layer settings meshing.tui.boundary.prism_settings.n_layers(5) meshing.tui.boundary.prism_settings.first_aspect_ratio(5) meshing.tui.boundary.prism_settings.growth_rate(1.2) # Generate mesh meshing.tui.mesh.poly_hexcore( "yes", # Enable poly-hexcore "yes", # Auto size 2.0, # Max cell length 0.1 # Min cell length ) # Write mesh file meshing.tui.file.write_mesh("generated_mesh.msh.h5") # Switch to solution mode meshing.tui.switch_to_solution_mode("yes") ``` ## File Session for Read-Only Access ### Read Case Files Without Launching Fluent Access field data from case/data files without starting a full Fluent session. ```python from ansys.fluent.core.file_session import FileSession from ansys.fluent.core import ScalarFieldDataRequest, VectorFieldDataRequest import numpy as np # Open file session (lightweight, read-only) file_session = FileSession( case_file_name="/path/to/solved_case.cas.h5", data_file_name="/path/to/solved_case.dat.h5" ) # Access field data using same API as regular sessions batch = file_session.field_data.new_batch() batch.add_requests( ScalarFieldDataRequest(field_name="pressure", surfaces=["inlet", "outlet"]), ScalarFieldDataRequest(field_name="temperature", surfaces=["wall"]), VectorFieldDataRequest(field_name="velocity", surfaces=["inlet"]) ) # Retrieve data data = batch.get_response() # Process extracted data pressure_inlet = data['ScalarFieldDataRequest']['pressure']['inlet'] pressure_outlet = data['ScalarFieldDataRequest']['pressure']['outlet'] temperature = data['ScalarFieldDataRequest']['temperature']['wall'] velocity = data['VectorFieldDataRequest']['velocity']['inlet'] print(f"Inlet pressure: {np.mean(pressure_inlet):.2f} Pa") print(f"Outlet pressure: {np.mean(pressure_outlet):.2f} Pa") print(f"Pressure drop: {np.mean(pressure_inlet - pressure_outlet):.2f} Pa") print(f"Wall temperature: {np.mean(temperature):.2f} K") # File session automatically releases resources when done file_session.exit() ``` ## Event Streaming and Monitoring ### Register Event Callbacks for Real-Time Monitoring Monitor simulation progress with event callbacks for iterations, data reads, and case modifications. ```python import ansys.fluent.core as pyfluent from ansys.fluent.core.streaming_services.events_streaming import SolverEvent solver = pyfluent.launch_fluent(mode="solver", processor_count=4) solver.settings.file.read_case(file_name="setup.cas.h5") # Iteration monitoring callback def on_iteration_ended(session, event_info): iteration = event_info.index if iteration % 10 == 0: print(f"Completed iteration {iteration}") # Case modification callback def on_case_modified(session, event_info): print(f"Case modified at {event_info.timestamp}") # Data read callback def on_data_read(session, event_info): print(f"Data file loaded: {event_info.file_name}") # Register callbacks solver.events.register_callback(SolverEvent.ITERATION_ENDED, on_iteration_ended) solver.events.register_callback(SolverEvent.CASE_MODIFIED, on_case_modified) solver.events.register_callback(SolverEvent.DATA_READ, on_data_read) # Run simulation with active monitoring solver.settings.solution.initialization.hybrid_initialize() solver.settings.solution.run_calculation.iterate(iter_count=500) # Unregister callbacks when done solver.events.unregister_callback(SolverEvent.ITERATION_ENDED, on_iteration_ended) ``` ## Journal Recording and Playback ### Record and Execute Fluent Journals Capture command sequences as journal files for reproducibility and automation. ```python import ansys.fluent.core as pyfluent solver = pyfluent.launch_fluent(mode="solver", processor_count=2) # Start journal recording solver.journal.start("setup_commands.jou") # Execute commands (automatically recorded) solver.settings.file.read_case(file_name="base_case.cas.h5") solver.settings.models.energy.enabled = True solver.settings.models.viscous.model = "k-epsilon" inlet = solver.settings.boundary_conditions.velocity_inlet["inlet"] inlet.momentum.velocity_magnitude.value = 2.0 inlet.thermal.temperature.value = 300 solver.settings.solution.initialization.hybrid_initialize() solver.settings.solution.run_calculation.iterate(iter_count=100) # Stop recording solver.journal.stop() print("Journal saved to setup_commands.jou") # Later: Execute recorded journal on new session new_solver = pyfluent.launch_fluent( mode="solver", journal_file_names="setup_commands.jou" ) # Or execute journal in running session solver.tui.file.read_journal("setup_commands.jou") ``` ## Advanced Configuration and Utilities ### Search API for Finding Settings Search through Fluent object hierarchy to find settings, commands, and parameters. ```python from ansys.fluent.core import search import ansys.fluent.core as pyfluent # Search for settings related to boundary conditions results = search("boundary condition") print("Boundary condition related objects:") for result in results[:5]: print(f" {result}") # Search for turbulence models turbulence_results = search("turbulence model") print("\nTurbulence model objects:") for result in turbulence_results[:5]: print(f" {result}") # Search in specific session context solver = pyfluent.launch_fluent(mode="solver") inlet_results = search("inlet", session=solver) print("\nInlet related objects:") for result in inlet_results[:10]: print(f" {result}") ``` ### Module Configuration Options Configure PyFluent global settings for launch behavior and performance tuning. ```python import ansys.fluent.core as pyfluent # Configure Fluent version pyfluent.config.fluent_release_version = "25.1" # Set launch timeout pyfluent.config.launch_fluent_timeout = 120 # seconds # Enable container launch by default pyfluent.config.launch_fluent_container = True # Configure container mount paths pyfluent.config.container_mount_source = "/home/user/fluent_data" pyfluent.config.container_mount_target = "/fluent_data" # Enable watchdog for cleanup pyfluent.config.start_watchdog = True # Configure data model caching pyfluent.config.datamodel_use_state_cache = True pyfluent.config.datamodel_use_attr_cache = True # Launch with configured settings solver = pyfluent.launch_fluent(mode="solver", processor_count=2) print(f"Launched Fluent {solver.get_fluent_version()}") ``` ## Summary PyFluent serves as a comprehensive Python interface for Ansys Fluent, enabling automation of complex CFD workflows from geometry import through mesh generation to solution and post-processing. The library supports multiple session types including full solver sessions with equation solving capabilities, meshing sessions with automated workflow support, and lightweight file sessions for data extraction without launching Fluent. Key use cases include running parametric design studies with parallel execution across multiple Fluent instances, extracting field data for custom visualization and analysis in Python scientific computing environments, and integrating CFD simulations into larger multiphysics or optimization workflows. The API provides three primary interaction paradigms: the Settings API for object-oriented access to solver and mesh configurations, the TUI interface for executing traditional Fluent text commands, and the Workflow API for automating meshing operations. Field data extraction capabilities support various request types including scalar fields (pressure, temperature, density), vector fields (velocity, momentum), surface mesh topology with connectivity information, and particle pathlines for flow visualization. The library handles deployment complexity through support for local standalone execution, Docker containerization with volume mounting, and HPC cluster integration via job schedulers like Slurm, making it suitable for both interactive development and production automation scenarios.