Text "scSTREAM scripting Unlock Dynamic CFD Simulations" over a background of swirling blue and black digital waves.

Comprehensive Guide to scSTREAM Scripting

Photo of author

By Admin Pang

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.

Screenshot of webinar introduction slide with Christophe Gayet's name and title.
Introduction to scripting webinar with Christophe Gayet
Source: SimAcademy Webinar) An Introduction for Scripting within scSTREAM

Why Use scSTREAM Scripting?

A slide explaining script uses, listing tasks such as adjusting temperature, setting heat sources, setting material properties, and adding user variables in a smart thermostat CFD model. Scripts can address such need.
Source: (SimAcademy Webinar) An Introduction for Scripting within scSTREAM

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.

Diagram comparing user functions and scripts in STREAM software, featuring compilation requirements, language options, and integration with the STREAM solver—ideal for tasks like smart thermostat CFD model development or a temperature control script CFD.
Historical context of in scSTREAM scripting.
Source: (SimAcademy Webinar) An Introduction for Scripting within scSTREAM

Types of Scripts in scSTREAM

A software interface shows parameter settings for a simulation. A dropdown menu highlights “Unformatted script,” and text explains formatted and unformatted scripts using a temperature control script CFD example.
Source: (SimAcademy Webinar) An Introduction for Scripting within scSTREAM

Unformatted Scripts

  • Do not take arguments, allowing versatile, general-purpose coding.
  • Useful for dynamically defining flux or heat sources based on spatial coordinates.
A software interface shows parameter settings for a simulation. A dropdown menu highlights “Unformatted script,” and text explains formatted and unformatted scripts using a temperature control script CFD example.
Source: (SimAcademy Webinar) An Introduction for Scripting within scSTREAM

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.
A PowerPoint slide explains "Formatted scripts" in a software, listing key points and showing a screenshot of a user interface for inputting a numeric value—ideal for topics like the scFLOW thermostatic control script.
Source: (SimAcademy Webinar) An Introduction for Scripting within scSTREAM

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 and TELP.
  • Retrieve element coordinates or conditions dynamically to adjust heat sources.
Slide showing formatted script setup for dynamic heat sources.
Example of defining a dynamic heat source
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.
Slide depicting the use of USRPOS for timing function scripts.
Example of timing functions in scSTREAM

Utility Functions

  • Retrieve physical quantities using ERCATCH or USREARCATCH.
  • Obtain integral or average values via Variable Registration for dynamic script adjustments.
Slide detailing retrieval of physical quantities via utility functions.
Example of utility functions in scSTREAM

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:

  1. Activate Variable Registration for volumes and faces to compute averages and fluxes.
  2. Define formatted scripts for dynamic inlet conditions:
    • Calculate temperatures using registered variables.
    • Adjust inlet temperatures proportionally based on room temperature feedback.
  3. Enhance outputs:
    • Implement additional data logging scripts using USRPOS.
    • Output calculated temperature variations for detailed post-analysis.
Implementation steps for dynamic temperature control
Implementation steps for dynamic temperature control

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.
Slide emphasizing the importance of right-click context menus and documentation.
Important tips for effective 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