Christophe Gayet, a Technical Support Engineer at Hexagon with over 14 years of experience, recently conducted a detailed webinar introducing scripting in scSTREAM. This guide summarizes key insights and practical applications of scSTREAM scripting, highlighting its benefits, how to start scripting autonomously, and practical examples.

Source: SimAcademy Webinar) An Introduction for Scripting within scSTREAM
Table of Contents
Why Use scSTREAM Scripting?

Scripting in scSTREAM is beneficial for:
- Adjusting blowing temperature dynamically based on room temperature.
- Defining heat sources dependent on spatial temperature data.
- Utilizing custom material properties via equations.
- Incorporating user-defined variables and outputs into simulation files.
Historical Context
Initially, scSTREAM allowed user functions through edited and compiled files, limiting cross-platform usage. Modern scSTREAM scripting, however, uses JavaScript embedded directly within project files (.S files), ensuring cross-platform compatibility without additional compilation.

Source: (SimAcademy Webinar) An Introduction for Scripting within scSTREAM
Types of Scripts in scSTREAM

Unformatted Scripts
- Do not take arguments, allowing versatile, general-purpose coding.
- Useful for dynamically defining flux or heat sources based on spatial coordinates.

Formatted Scripts
- Predefined context and arguments, used explicitly for setting solver parameters or obtaining solver data.
- Categorized into:
- Setting functions: configuring solver parameters.
- Timing functions: triggering scripts at specific simulation stages.
- Utility functions: retrieving solver data or logging messages.

Practical Examples
Setting Functions
A common application of scSTREAM scripting is to set up a dynamic heat source:
- Define a formatted script in the solver parameters, using reserved arguments like
UXV
andTELP
. - Retrieve element coordinates or conditions dynamically to adjust heat sources.

Source: (SimAcademy Webinar) An Introduction for Scripting within scSTREAM
Timing Functions
Utilize USRPOS
to:
- Execute scripts at initialization, specific time cycles, or before outputting files.
- Log important information like global variable values directly into
.L
files for post-processing.

Utility Functions
- Retrieve physical quantities using
ERCATCH
orUSREARCATCH
. - Obtain integral or average values via Variable Registration for dynamic script adjustments.

Example Scenario: Dynamic Temperature Control
Consider a room scenario aiming to regulate inlet air temperature based on the average room temperature:
- Variable Registration: Compute the average temperature for a defined region.
- Dynamic Inlet Temperature: Employ scripts to dynamically modify inlet temperatures based on the computed average temperature.
- Output Enhancements: Add custom outputs like temperature differences directly into simulation outputs (
.FLD
files) and logs (.L
files).
Implementation Steps:
- Activate Variable Registration for volumes and faces to compute averages and fluxes.
- Define formatted scripts for dynamic inlet conditions:
- Calculate temperatures using registered variables.
- Adjust inlet temperatures proportionally based on room temperature feedback.
- Enhance outputs:
- Implement additional data logging scripts using
USRPOS
. - Output calculated temperature variations for detailed post-analysis.
- Implement additional data logging scripts using

Important Tips
- Right-click context menus: Use these extensively to access predefined variables, mesh details, and available functions quickly.
- Documentation: Regularly consult the scSTREAM documentation for detailed function references and examples of scSTREAM scripting.

Questions and Answers
During the webinar, several useful clarifications were made:
- Python scripting is currently unsupported; JavaScript remains the scripting language.
- Scripts can dynamically control airflow based on spatial temperatures, beneficial for data-driven HVAC simulations.
- Scripts potentially enable dynamic adjustments of simulation parameters like timestep based on variable conditions, depending on solver compatibility.
Conclusion
Christophe’s webinar thoroughly outlined the practical applications, necessary foundational knowledge, and detailed examples needed to effectively utilize scripting in scSTREAM. By adopting scSTREAM scripting, users significantly enhance simulation flexibility and automation, essential for complex, dynamic scenarios in computational fluid dynamics (CFD).
Reference
To watch the full session of the webinar, please visit: SimAcademy Webinar – An Introduction for Scripting within scSTREAM