Template File Definitions and Parameterization
Introduction to Simulation Cases in OpenSource Solvers
OpenSource solvers are a staple in the computational fluid dynamics (CFD) community, offering powerful capabilities through simulation cases. These cases are typically defined in input text files, which dictate the behavior and conditions of the simulations. However, setting up these files can be complex and technical, demanding a high level of expertise from the professionals who use these OpenSource codes.
The Challenge with Text File Configurations
The intricacy of these text files lies in their requirement for precise parameter adjustments, which are essential for accurate simulation outcomes. Understanding and setting these parameters correctly requires a deep understanding of the solver's workings and the physics behind the simulation case. As a result, this complexity often creates a barrier to entry for those not intimately familiar with the OpenSource code.
Templize's Solution
Templize addresses this challenge by enabling experts to create templates for specific simulation cases. These templates allow the parametrization of input text files, simplifying the process of setting up a simulation. By abstracting the complexities into user-friendly templates, Templize opens up the use of OpenSource solvers to a broader audience.
Templating with Jinja Syntax
Templize employs Jinja syntax for templating, which is a widely used template engine for Python. Jinja allows the substitution of parameters within text files easily. Here are a few simple examples of how parameters can be substituted using Jinja:
- To insert the value of a parameter called
velocity
, you would use the syntax{{ velocity }}
in the text file. - If you have a parameter for
temperature
with a default value of 300, it could be represented as{{ temperature | default(300) }}
. - For a conditional statement, you might use
{% if wall_heat_transfer %} ... {% endif %}
to include certain settings only ifwall_heat_transfer
is true.
Parameter Replacement in Modelers
The parameters defined in the parameters section of a template in Templize are placeholders that will be replaced with actual user-defined values when a modeler is published and model runs are generated. During the creation of a model run, Templize takes the values input by the user and substitutes them into the corresponding places in the text file where the Jinja placeholders are located.
Implications for Users
For users, this means that they can interact with a template through a high-level interface without needing to edit the complex text files directly. They input values into the predefined parameters, and Templize handles the insertion of these values into the text files.