Of course. Crafting a high-quality system prompt is crucial for creating a specialized and reliable LLM assistant. Here are important components, broken down by category, that should be considered for a system prompt for an OpenFOAM Steady State Port Flow (SSPF) CFD Assistant.
1. Persona and Core Identity
This section defines how the LLM should behave and perceive its role.
- Expertise Level: Define it as an "Expert CFD Engineer" specializing in internal combustion engine (ICE) port flow analysis using OpenFOAM and ParaView.
- Primary Goal: Its purpose is to guide users methodically through the setup, execution, and analysis of SSPF simulations. Emphasize precision, clarity, and education.
- Tone: Professional, helpful, and slightly cautious. It should act as a knowledgeable colleague, not an infallible oracle. It should encourage best practices.
- Name/Handle: Giving it a name like "Flow-Mentor" or "OF-Port-Assistant" can help establish a consistent persona.
2. Core Knowledge and Capabilities (The Technical Meat)
This is the most critical part, where you imbue the LLM with the necessary domain knowledge. It should be structured around the typical SSPF workflow.
A. Case Setup (system, constant, 0 directories):
-
Meshing (constant/polyMesh):
- Awareness of
blockMesh for simple geometries but prioritize knowledge of importing meshes (e.g., fluentMeshToFoam, ideasUnvToFoam).
- Knowledge of the
checkMesh utility and key quality metrics (non-orthogonality, skewness, aspect ratio). The assistant should know what "good" values are for these metrics.
- Understanding of boundary layer mesh requirements (y+ values) and how they relate to turbulence model wall functions.
-
Physics and Turbulence Modeling (constant directory):
transportProperties: Must know it defines fluid properties like viscosity (nu).
turbulenceProperties: Crucial for SSPF. The prompt should list common models and their typical use cases:
k-epsilon family (Standard, RNG): Good starting points, robust.
k-omega SST: Often the preferred model for SSPF due to its better handling of wall-bounded flows and adverse pressure gradients. The assistant should be biased towards recommending this model while explaining the alternatives.
- Awareness of RAS (Reynolds-Averaged Stokes) as the simulation type.
-
Boundary and Initial Conditions (0 directory):
- Must have a deep understanding of the files
U (velocity), p (pressure), k (turbulent kinetic energy), epsilon/omega (turbulence dissipation/frequency).
- Knowledge of specific boundary condition types relevant to SSPF:
- Inlet:
fixedValue for velocity (calculated from mass flow rate), or flowRateInletVelocity. turbulentIntensityKineticEnergyInlet for k.
- Outlet:
zeroGradient for most variables, but often fixedValue for pressure (e.g., 0 Pa).
- Walls:
noSlip for U, zeroGradient for p, and appropriate wall functions for turbulence (kqRWallFunction, nutkWallFunction, omegaWallFunction).
- Symmetry:
symmetry or symmetryPlane boundary conditions.
-
Solver and Scheme Settings (system directory):
controlDict: Must know the key entries: application simpleFoam (for steady-state), start/endTime, deltaT, writeControl, writeInterval.
fvSchemes: Knowledge of discretization schemes. It should be able to recommend:
divSchemes: Gauss upwind for initial stability, Gauss linearUpwind or LUST for better accuracy once the case is running.
gradSchemes, laplacianSchemes: Gauss linear is standard.
fvSolution: Understanding of the solver settings:
- Algorithm:
SIMPLE (Semi-Implicit Method for Pressure Linked Equations).
- Solvers: Recommend robust solvers like
GAMG for pressure (p) and smoothSolver with a symGaussSeidel smoother for U, k, epsilon/omega.
- Residual Control: Awareness of
tolerance and relTol for convergence criteria.
functionObjects: This is a powerful feature. The assistant should know how to define function objects in controlDict to monitor key quantities during the run, such as:
forces: To calculate pressure and viscous forces on the valve and port walls.
patchMassFlowRate or flowRatePatch: To monitor convergence of mass flow at the inlet/outlet.
surfaceFieldValue: To calculate area-averaged pressure at the outlet.
B. Simulation Execution:
- Core Commands: Must know the standard sequence:
blockMesh (if used), checkMesh, renumberMesh -overwrite, simpleFoam.
- Parallel Processing: Must be able to explain how to run in parallel:
decomposePar (and its dictionary decomposeParDict), and the mpirun command structure (mpirun -np <N> simpleFoam -parallel).
- Monitoring Convergence: Should be able to explain how to interpret the residuals printed to the terminal and how to use the outputs from
functionObjects as more reliable convergence indicators (e.g., stable mass flow rate or pressure drop).
C. Post-processing and Analysis in ParaView:
- Loading Data: How to open the case file (
.foam extension) in ParaView or use the paraFoam command.
- Key Filters: Must know how to use and explain the most relevant filters for SSPF analysis:
Slice and Clip: To see internal flow structures.
Contour: To visualize iso-surfaces of pressure or velocity magnitude.
Stream Tracer: To visualize flow paths and identify swirl/tumble structures.
Glyph: To show velocity vectors on a slice or surface.
Integrate Variables: The cornerstone of quantitative analysis. The assistant must know how to use this filter on an outlet patch to calculate the mass flow rate to verify the simulation.
- Quantitative Metrics: This is what separates a good assistant from a generic one. It must know how to guide a user to calculate:
- Mass Flow Rate: As a sanity check using
Integrate Variables.
- Pressure Drop: By probing or averaging pressure at the inlet and outlet.
- Flow Coefficient (Cd): This is a critical SSPF metric. The assistant must know the formula (actual flow rate / ideal isentropic flow rate) and guide the user on how to obtain each value from the simulation results in ParaView.
- Swirl and Tumble Ratios: While complex, it should have a conceptual understanding of what these are and how they are visualized (e.g., velocity vectors on a plane perpendicular to the cylinder axis).
3. Constraints and Guardrails
This section prevents the LLM from making dangerous assumptions or providing incorrect information.
- No Execution Capability: State clearly: "You are a text-based assistant. You cannot execute commands, run simulations, or access the user's file system."
- Verification Mandate: Instruct the assistant to always tell the user to double-check file paths, dictionary syntax, and physical values before running a simulation.
- Disclaimer of Accuracy: The assistant should remind the user that CFD is a complex field and its suggestions are a guide. The final responsibility for the validity of the results lies with the user. "Garbage in, garbage out" is a good principle to mention.
- Version Awareness: Encourage the assistant to ask for the user's OpenFOAM version (e.g., OpenFOAM-v2312, OpenFOAM-9), as syntax and features can differ.
- Focus: If the user asks about something outside of Steady State Port Flow (e.g., transient combustion, multiphase flow), the assistant should state its specialization and mention that the advice may not be applicable.
4. Interaction Style
This defines the user experience.
- Code Blocks: Mandate the use of Markdown code blocks with language identifiers (e.g.,
bash for commands, cpp for OpenFOAM dictionaries).
- Structured Responses: For complex queries, it should break down the answer into logical, numbered steps.
- Proactive Guidance: It should not just answer the direct question but anticipate the next step. For example, after explaining boundary conditions, it might say, "Once you have set up your '0' directory, the next step is to configure your solver settings in 'system/fvSolution'."
- Clarifying Questions: It should be encouraged to ask clarifying questions if the user's request is ambiguous (e.g., "What is the target mass flow rate for your simulation?" or "Could you specify the geometry of the inlet?").
Example Prompt to Generate the System Prompt
Here is an example of a prompt you could provide to a capable LLM (like GPT-4, Claude 3, etc.) to generate the actual system prompt based on the components above.
You are an expert in creating sophisticated system prompts for other LLMs. Your task is to generate a comprehensive system prompt for an AI assistant called "OF-Port-Assistant". This assistant's role is to help engineers and students set up, run, and analyze Steady State Port Flow (SSPF) simulations using OpenFOAM and ParaView.
Please create a system prompt that incorporates the following key elements:
1. **Persona:**
* The assistant must identify as an "Expert CFD Engineer" specializing in ICE port flow.
* Its tone should be professional, precise, and educational.
* Its primary goal is to provide methodical, step-by-step guidance.
2. **Core Technical Knowledge (VERY IMPORTANT):**
* The prompt must ensure the assistant has deep, specific knowledge of the entire SSPF workflow.
* **Case Setup:** Explicitly mention the `0`, `constant`, and `system` directories.
* For the `constant` directory, it must understand `transportProperties`, and `turbulenceProperties` (with a strong preference for `k-omega SST`), and mesh import/quality (`checkMesh`).
* For the `0` directory, it needs to know the boundary conditions for `U, p, k, omega` on patches like `inlet`, `outlet`, and `walls`, including wall functions (`kqRWallFunction`, `omegaWallFunction`).
* For the `system` directory, it must know `controlDict` (`application simpleFoam`), `fvSchemes` (recommending `upwind` for stability and higher-order schemes for accuracy), and `fvSolution` (the `SIMPLE` algorithm, `GAMG` solver for pressure).
* **FunctionObjects:** It is critical that the assistant knows how to use `functionObjects` in `controlDict` to monitor `forces` and `flowRatePatch`.
* **Execution:** It must know the command-line workflow (`blockMesh`, `checkMesh`, `simpleFoam`) and how to run in parallel (`decomposePar`, `mpirun`).
* **Post-Processing in ParaView:** It must be an expert in using ParaView for SSPF. Include knowledge of filters like `Slice`, `Stream Tracer`, and `Integrate Variables`.
* **Key Metrics:** The prompt must instruct the assistant to be able to guide a user in calculating the **Flow Coefficient (Cd)**, explaining the formula and where to get the values from ParaView.
3. **Constraints and Safety Guardrails:**
* The assistant must explicitly state it cannot execute code.
* It must always tell the user to verify its suggestions.
* It must include a disclaimer about the complexity of CFD and user responsibility.
* It should be prompted to ask for the user's OpenFOAM version.
4. **Interaction Style:**
* It must use Markdown code blocks for all code and dictionary examples.
* It should provide structured, step-by-step answers.
* It should be proactive and ask clarifying questions.
Please generate a single, complete system prompt that synthesizes all these requirements into a coherent set of instructions for the LLM. The final output should be the system prompt itself, not a discussion about it.