2.14. Appendix

2.14.1. Python Console

Many of the icing features and settings can be accessed and changed through the Console window, using python commands.

Many of the commands and settings present in the Fluent Icing panels can be recorded using python commands from the FileStart Journal menu. These journal files can also be executed through the FileRead Script File… menu.

Python Console & Operations

The Console window at the bottom right corner of Fluent Icing allows you to enter commands interactively. The following sections describe commands available in the python console

dir() and the command/attribute list

dir()

Display the list of global commands and top-level objects.

'AddSession', 'Project', 'ReadScriptFile', 'Sim', 'StartTranscript', 'StopTranscript', 'csim', 'currentSimulation'

dir(object)

Display the list of commands & attributes of the object.

Example 2.2: Entering Commands Interactively

(Assuming test1.cas is already loaded)

dir(Sim[“case_file”])

'Case', 'Connect', 'ConnectionInfo', 'IcingSimulation', 'StartServer'

r = currentSimulation()

A temporary variable can be used to simplify command lines.

dir(r.Case.App.Particles)

'Crystals', 'Droplets', 'Model', 'Type', 'Vapor'

dir(r.Case.App.Particles.Droplets.Particles.Droplets.Conditions)

' Appendix', 'Diameter', 'LWC', 'SLDFlag', 'WaterDensity'


Accessing/Changing Values

The () operator will return the current value of the attribute.

r.Case.App.Particles.Conditions.LWC()

Result: 0.001

r.Case.App.Particles.Conditions.LWC = 0.00344

Commands

If an item listed in dir() is a verb, it is a command.

For example

r.Case.App.Solution.AirflowRun.Initialize()

Sample Script

c = csim()

# Droplets: Configure 
c.Particles.Droplets.Conditions.Diameter = 16
c.Solution.ParticlesRun.Solver.CFL = 10
c.Solution.ParticlesRun.RunSettings.NumIterations = 140 
# Setup boundary conditions bc =
bc = c.BC["velocity-inlet-4"] 
bc.ParticlesInlet.AutoBC = False 
bc.ParticlesInlet.DropletDiameter = 16
bc.ParticlesInlet.DropletTemperature = 270 
bc.ParticlesInlet.DropletVelocityFlag = True 
bc.ParticlesInlet.DropletVelZ = 40.

2.14.2. Batch Launching

Batch Launching Arguments

Fluent Icing can be launched in batch mode by executing the bin/icing (Linux) or bin/icing.bat (Windows) executable file, and by using the following arguments.

  • -R file.py

    • After launching Fluent Icing, this option reads and executes the file.py python script.

    • By default, the python script will be exited and then the application will be exited (the exit status code of the application will be non-zero if the Python script has thrown an exception or some other error occurred).

  • -I

    • Runs Fluent Icing in interactive batch with-GUI mode (the graphical user interface will be displayed)

    • When using this argument, the application will not exit after completion of the python script.

  • -N

    • Runs Fluent Icing in full batch no-GUI mode (the graphical user interface will not be displayed).

  • -g

    • Runs Fluent Icing in full batch no-GUI mode (the graphical user interface will not be displayed).

    • In this mode, background graphics objects will not be generated, preventing you from accessing many post-processing or image creation operations.

  • -wait

    • Waits until execution of the file.py script is complete before continuing batch execution.

  • -t CPUs

    • Launches the solver using the specified number of CPUs.

Python Commands Relevant for Batch Execution

  • enableScriptEventLoop()

    • When executing bin/icing using only the -R file.py argument, this command should be specified at the beginning of the file.py script to ensure the script waits for the execution to finish. Using this command is an alternative to adding the -I -wait command line options.

Batch Launching Examples

The following sections show a few complete command line usage examples on Linux or Windows:

Linux

bin/icing -R file.py -t 4

  • Executes Fluent Icing and runs the file.py python script in interactive batch (with-GUI) mode using 4 CPUs.

  • This method replicates the standard user experience of Fluent Icing.

bin/icing-R file.py -N -t CPU -4

  • Executes Fluent Icing and runs the file.py python script in full batch (no-GUI) mode using 4 CPUs.

Windows

  • The functionality is the same as the above Linux commands, except that executable should be replaced with bin/icing.bat.

2.14.3. Data Structures

Hierarchy

  • RemoteSession (Simulation)

    • Case

      • App

        • Airflow

        • Particles

        • Ice

        • BC

        • Solution

          • AirflowRun

          • ParticlesRun

          • IceRun

  • Project

  • PostAnalysis

Global Functions

  • currentSimulation()

    Returns the current RemoteSession. If multiple Fluent connections exist, the current is related to the current selection in the outline view.

  • csim()

    Returns the currentSimulation().Case.App

2.14.4. Project API

A simulation is loaded once a project is created or opened. Project operations are defined in the Project object. If an operation fails, it will throw an exception.

  • Project

    • new("filename")

      Create a new project file in the specified path/filename, the path must be available. For example Project.new("/tmp/DEMO") will create /tmp/DEMO.flprj and /tmp/DEMO.cffdb/

    • open("filename")

      Open an existing project file.

    • close()

      Close the current project.

    • erase("filename")

      Erase the specified project, filename.flprj and filename.cffcb folder recursively.

    • isOpen()

      Returns True if a project is currently opened.

    • getURL()

      Returns the project file (.flprj) with with full path.

    • getFolder()

      Returns the full path of the project folder (cffdb).

    • openSimulation("name")

      Load the specified simulation, by name, from the current project. Fluent is launched with the default.

    • importCase("file.cas")

      Create a new simulation, importing the case file (.cas or .cas.h5, with path) to the project. This is equivalent to using the ribbon option Import Case, with default options.

    • saveCase()

      Save the current settings to the case file (similar to FileSave Case)

    • newRun("flow","name",iterations)

      newRun("particles","name",iterations)

      newRun("ice","name",time)

      newRun("multishot","name",iterations)

      Create a new run in the current simulation, of the following type, flow, particles, ice or multishot. The new run name is specified, and is executed for the specified number of iterations (for ice, the number is a floating point for the time value).

      Example 2.3: New Run Operation

      Project.erase("demoProject") 
      Project.new("demoProject") 
      Project.importCase("grid.cas")
      
      Project.newRun("flow","runA",12) 
      Project.newRun("particles","runB",12) 
      Project.newRun("ice","runC",0.001)
      
      Project.close()
      

2.14.5. Post-Analysis API (Beta)

When using graphical mode (not in pure batch mode), the python environment provides full access to the graphical capabilities of the Post-Analysis module. In this case, the Post-Analysis python module offers the related services.


Note:  Journaling capabilities for Post-Analysis are limited, and not all graphical operations will be recorded (camera configuration and movements, viewports, etc.)

Example 2.4: Sample Usage

m = PostAnalysis.LoadCase(Filename=”naca.01.cas.h5”)
d = PostAnalysis.LoadResult(Filename1=”naca.01.cas.fsp”,Filename2=”naca.01.dat.fsp”,FieldName=”Mach”)

PostAnalysis.DisplaySettings.RestoreView(ViewName="bottom")
PostAnalysis.Dataset[m].Case.Results.Graphics.Mesh["Mesh1"].Options.Edges = True
PostAnalysis.Dataset[m].Case.Results.Graphics.Mesh["Mesh1"].Display()

PostAnalysis.DisplaySettings.RestoreView(ViewName="front")
PostAnalysis.Dataset[d].Case.Results.Graphics.Mesh["Contour1"].Display()


  • PostAnalysis

    • Init()

      Initialize the post-processing framework (this will open the EnSight process and consume a post-processing license). Automatically invoked as required if LoadCase or LoadResult are used.

    • LoadCase(Filename="file.cas.h5”)

      Loads the specified case or mesh file. The return value is the identifier of the newly loaded dataset and can be used as a key in the PostAnalysis.Dataset[key] index. .cas, .cas.h5 and .cas.fsp can be loaded.

    • LoadResult(Filename1="file.cas.h5”,Filename2=”file.dat.h5”)

      LoadResult(Filename1="file.cas.h5”,Filename2=”file.dat.h5”,FieldName=”Fieldname”)

      Loads the specified case and result. The return value is the identifier of the newly loaded dataset and can be used as a key in the PostAnalysis.Dataset[key] index. .cas/.dat .cas.h5/.dat.h5 .cas.fsp/.dat.fsp must be loaded in matching pairs. If a FieldName is provided, the specified field.

    • Dataset

      Dictionary of loaded datasets

      • keys()

        Returns the list of dataset identifiers

    • Dataset[key].Case.Results

      Object containing the dataset’s graphical elements and their settings. Use the () operator to query the content.

    • DisplaySettings

      Object containing the viewports and their display settings. Use the () operator to query the content, and dir() to get the list of available commands.

    • GlobalScene

      Object containing the scenes and their display settings. Use the () operator to query the content.

2.14.6. Fluent Journal Commands

Once a case is configured in Fluent Icing and saved, it can be used in batch mode scenarios where a regular Fluent journal file is used. For batch mode execution of Fluent Icing commands, Fluent must be started with the -license=enterprise command line flag.


Note:  This mode is for advanced users. This mode will not store files in a project folder and has a limited feature set. Python scripting of Fluent Icing should be preferred.


Use regular Fluent journal file commands to execute standard Fluent operations:

  • Load/save the case file

  • Load/save the data file (.dat)

  • Initialize/Iterate the Fluent airflow solution

  • Etc.

In a case file where icing was set-up with Fluent Icing, the text command environment will provide the icing/ submenu and commands:

  • icing/

    • file/

    • settings/

    • flow/

    • drop/

    • ice/

    • multishot/

  • file/ commands

    • load-file / save-file

      • Load or save a single solution file, of a specified type

    • load-all / save-all

      • Load or save all solution files associated with a .cas(.h5)

        For FILE.cas(.h5), the default output filename is the filename without the suffix (FILE).

        The command would write FILE.droplet, FILE.swimsol, etc.

    • reset-file

      • Unload a specific solution type

    • reset-all

      • Unload from memory all icing solutions (FENSAP airflow, particles, ice)

    • status

      • List the currently loaded icing solutions, and their type

  • settings/

    • get variable

    • set variable value

      • Individual icing settings can be accessed and changed through these commands.


        Note:  Advanced users: The settings are the rpvar name without the fensapice/ prefix


    • auto-save?

      • Toggle the auto-save feature, which is writing solutions to files at the end of any icing solver run (airflow, particles, ice). The file is written alongside the case file (FILE.cas(.h5) will have FILE.droplet, etc.)

    • save-converg? save-gmres?

      • Toggle to save the convergence detail of icing solvers in text files alongside the case file

    • verbosity

      • Set the log output verbosity for icing solvers. Default is 0 (minimal), set to 1 (Complete) to get additional information on the solver execution.

  • flow/ commands (FENSAP only. Use Fluent text commands for the Fluent airflow solver).

    • init

      • Starts and initialize the solver.

      • This is automatically done when running calculate() for the first time, or by running calculate() after running the solver from another mode (FENSAP airflow, particles, ice or grid displacement).

    • calculate

      • Calculate FENSAP airflow for the number of iterations currently set-up in the flow/niter variable.

      • Multiple calculate commands can be executed, continuing the computation already started.

      • Example 2.5: Use the Icing/Settings/Set Command to Set the Number of Iterations

        Icing/settings/set flow/niter 250


      • end

        Release solver memory

  • drop/ commands (Particles solver)

    • init, calculate, end (Similar to flow/ commands)

      • The number of iterations is in drop/niter setting.

  • ice/ commands

    • run

      • Runs the icing solver (and/or grid displacement)

        The total time is in the setting ice/ice_total_time

    • end

      • Release solver memory

  • multishot/ commands

    • run

      • Runs the currently configured multi-shot

If icing settings are not part of your original case file, the command (load-fensapice) can be used to enable the icing solver commands and to display the icing/ menu. A case file set-up with Fluent Icing will automatically load the icing module when it is read.


Note:  The full set-up and execution of the icing settings through text commands is possible since all the icing settings are stored as rpvars and thread variables.


Interrupting a computation

On the interactive terminal of FENSAP, Ctrl+C will stop the computation at the end of the current iteration. When running in batch mode, the abort file (*.abort) can be used. The abort file is a simple text file containing the “stop” keyword.

For example, for casefilename.cas

echo stop > casefilename.abort

This will interrupt the solver at the end of the current time step, this will not trigger a journal file error and the execution will continue to the next steps.

2.14.7. Run Sequence

This feature makes it possible to prepare several runs with different settings and execute them in sequence without having to manually change settings between runs. It is available if Advanced Settings is enabled through FilePreferences...Icing, and activated by selecting FileRead Run Sequence…. A Select File dialog will open allowing you to select the spreadsheet that contains the list of runs. The spreadsheet must be in .csv format and follow a certain structure to be read correctly by Fluent Icing.

Spreadsheet Format

The .csv file must follow the following format:

KeywordsKeyword 1Keyword n
SimulationRunSolverSetting 1Setting n
 Run 1Solver choiceValueValue
 Run 2Solver choiceValueValue
 Run 3Solver choiceValueValue
  • Run

    Name of the run to be executed.

  • Solver

    Type of solver used for the run. Solver has to be either:

    • Flow

    • Particles

    • Ice

    • Multishot

  • Settings

    This corresponds to the setting you would like change between runs. It has to correspond to a parameter present in Fluent Icing's Outline View minus the parameter dimension in brackets. For example, when using Roughness Height [m]   as the setting to be changed between runs, you would omit [m].

    Example 2.6: This spreadsheet will execute 2 flow simulations and change the roughness height at the walls between them, all the other settings are kept as per the case file.

      Keywords 
    SimulationRunSolverRoughness Height
     flow_cleanflow0
     flow_roughflow0.0005


    Important:  The setting to be changed needs to be available in the Outline View. For example, Roughness Height [m] is available if Wall Roughness is set to High roughness for Icing. You can either specify this setting directly in the Outline View or add a column in the spreadsheet to set Wall Roughness to High roughness for Icing. The values can be numbers, strings or logicals depending on the type of the setting.



  • Keywords

    Keywords are used to filter settings. When a setting is written without a keyword similar to the previous example, all elements in the Outline View that contain this setting name will be modified. For example, Temperature appears under:

     Setup Airflow Reference Conditions Temperature [K]

     Setup Boundary Conditions Inlets pressure-far-fieldTemperature [K]

     Setup Boundary Conditions Walls wallTemperature [K]

    Keywords can be used to specify which elements are to be modified. Keywords correspond to different sections in the Outline View and can be any of the following:

    • Setup Airflow

    • Setup Particles

    • Setup Ice

    • BC (will apply to all boundary conditions)

    • Solution Airflow

    • Solution Particles

    • Solution Ice

    • Solution Multishot

    • Walls

    • Inlets

    • Outlets

    • The name of a specific boundary condition (example: wall-1, leading-edge or pressure-far-field-11)

    Example 2.7: The Temperature column sets the temperature everywhere in the Outline View (including airflow reference conditions, inlets, walls). The second column will apply a different temperature to walls only.

      Keywords  Walls
    SimulationRunSolverRoughness HeightTemperatureTemperature
     flow_cleanflow0262.3280.454
     flow_roughflow0.0005272.3290.454

  • Simulation

    Refers to the simulation used for the given run. If the field is empty, the simulation that is currently opened is used. If a simulation is entered, the sequence will verify that it is currently loaded. Should it not be currently load, the sequence will close and open the proper simulation. The simulation must be present in the project.

    Example 2.8: After the creation of a project, 2 different case files were imported to create a clean and iced simulation. Angle-of-Attack sweeps for both cases can be set up as shown below:

      Keyword  InletsInlets
    SimulationRunSolverVector ModeAoADirectionAlpha (X-Y)
    grid_cleanclean_AoA_m2degflow"Angle of attack"-2"Vector Angle"-2
    grid_cleanclean_AoA_0degflow"Angle of attack"0"Vector Angle"0
    grid_cleanclean_AoA_2degflow"Angle of attack"2"Vector Angle"2
    grid_cleanclean_AoA_4degflow"Angle of attack"4"Vector Angle"4
    grid_cleanclean_AoA_6degflow"Angle of attack"6"Vector Angle"6
    grid_cleanclean_AoA_8degflow"Angle of attack"8"Vector Angle"8
    grid_iceice_AoA_m2degflow"Angle of attack"-2"Vector Angle"-2
    grid_iceice_AoA_0degflow"Angle of attack"0"Vector Angle"0
    grid_iceice_AoA_2degflow"Angle of attack"2"Vector Angle"2
    grid_iceice_AoA_4degflow"Angle of attack"4"Vector Angle"4
    grid_iceice_AoA_6degflow"Angle of attack"6"Vector Angle"6
    grid_iceice_AoA_8degflow"Angle of attack"8"Vector Angle"8


    Note:  When executing run sequences that will switch between different simulations, you should close Fluent Icing after setting up the simulations. Re-open Fluent Icing and your project and load the simulation corresponding to the first run in the spreadsheet.


Python/TUI Commands

It is possible to execute python or TUI commands between runs by entering python-command or tui-command in the Solver column and the actual command in the Run column.

Example 2.9: After running two particles simulations with different distributions, the first result is loaded to be the baseline for the following icing simulation

Runsolver
flow_roughflow
droplets_mvdparticles
droplets_langdparticles
Project.loadParticlesResult("droplets_mvd")python-command
ice_mvdice

Restart Capabilities

When using Run Sequence, Fluent Icing lets you choose between the following options if one or several runs, defined in your .csv file, share the same name as existing runs in your project.

  • Overwrite All

    Delete the existing runs and run them again from the .csv file.

  • Skip All

    Keep the existing runs as is and only execute the runs from the file that do not exist in the project.

  • Configure…

    Pop up a list of the existing runs to choose which to overwrite.

2.14.8. Field Name Mapping

Solution files that are written using the CFF file format (.dat.fsp files, as loaded by EnSight and the Post-Analysis module) will display field names that are different than solution files that are written using the FENSAP format and opened with Viewmerical or CFD-Post. The CFF format field names have been normalized to common quantities across different Phases (air, droplets, crystals, vapor, ice). The following table maps the solution field names displayed in Viewmerical (FENSAP format) to the solution field names inside Post-Analysis (CFF format).

Viewmerical displayed NamePhasePost-Analysis & EnSight displayed name
Density (kg/m^3)airDensity
Pressure (N/m^2)air Pressure
V1-velocity (m/s); VelocityairVelocity u
V2-velocity (m/s)airVelocity v
V3-velocity (m/s)airVelocity w
Static temperature (K)airTemperature
laminar viscosity (kg/m s)airLaminar Viscosity
turbulent viscosity (kg/m s)airTurbulent Viscosity
y-plusairYplus
u-plusairUplus
nutilde (m^2/s)airSpalart-Allmaras nuTilda
kay (m^2/s^2)airTurbulent Kinetic Energy
omega (1/s)airTurbulent Eddy Frequency
epsilon (m/s^2)airTurbulent Eddy Dissipation
Classical heat flux (W/m^2)airWall Heat Flux
Gresho heat flux (W/m^2)airGresho Heat Flux
shear stress (Pa)airWall Shear u
shear stress (Pa)airWall Shear v
shear stress (Pa)airWall Shear w
roughness height (m)airRoughness Height
wall distance (m)airWall Distance
Droplet LWC (kg/m^3)dropletsConcentration
Droplet V1 (m/s); VelocitydropletsVelocity u
Droplet V2 (m/s)dropletsVelocity v
Droplet V3 (m/s)dropletsVelocity w
Droplet diameter (m)dropletsParticle Size
Droplet Temperature (K)dropletsTemperature
Droplet Specific Energy(J/kg)dropletsSpecific Internal Energy
Collection efficiency-DropletdropletsCollection Efficiency
Crystal ICC (kg/m^3)crystalsConcentration
Crystal V1 (m/s); VelocitycrystalsVelocity u
Crystal V2 (m/s)crystalsVelocity v
Crystal V3 (m/s)crystalsVelocity w
Crystal Diameter (m)crystalsParticle Size
Crystal Temperature (K)crystalsTemperature
Crystal Specific Energy(J/kg)crystalsSpecific Internal Energy
Crystal MeltfractioncrystalsMelt Ratio
Collection efficiency-CrystalcrystalsCollection Efficiency
Vapor Concentration (kg/m^3)vaporConcentration
Vapor Condensation (kg/m^2s)vaporCondensation Rate
Saturation Vapor Pressure(Pa)vaporSaturation Pressure
Vapor Pressure (Pa)vaporPartial Pressure
Relative Humidity %vaporRelative Humidity
Vapor Diffusivity (m^2/s)vaporDiffusivity
Wet-bulb Temperature (K)vaporWet Bulb Temperature
Mass Caught (kg/m^2s)iceMass Caught
Film Thickness (micron)iceFilm Thickness
Instant. Ice Growth (kg/m^2s)iceGrowth Rate
Ice Growth (kg/m^2)iceAccumulation
Wall Temperature (C)iceTemperature
Ice Density (kg/m^3)iceDensity
Cfx; VelocityiceFilm Velocity u
Cfy (m/s)iceFilm Velocity v
Cfz (m/s)iceFilm Velocity w
Instant. Mass EvaporationiceEvaporation Rate
FLOW SOLVER Convective FluxiceWall Heat Flux
ChiceHeat Transfer Coefficient
Current Convective Heat FluxiceCurrent Convective Heat Flux
Anti-Icing Heat FluxiceAnti-Icing Heat Flux
Ice thickness (m)iceThickness
Evaporative Heat FluxiceEvaporative Heat Flux
Anti-Icing Wall Temp. (K)iceAnti Icing Wall Temperature
Bead Height (m)iceBead Height