<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hidenori Ishii</title>
    <description>The latest articles on DEV Community by Hidenori Ishii (@47_robin_ebe9e47eb349d767).</description>
    <link>https://dev.to/47_robin_ebe9e47eb349d767</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4266963%2F9f495066-e7f6-4473-8fec-d76c67f8b7a9.png</url>
      <title>DEV Community: Hidenori Ishii</title>
      <link>https://dev.to/47_robin_ebe9e47eb349d767</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/47_robin_ebe9e47eb349d767"/>
    <language>en</language>
    <item>
      <title>CFAST Unity Dev Report #4: Building a Stateful Fortran Fire Simulation Worker for Unity</title>
      <dc:creator>Hidenori Ishii</dc:creator>
      <pubDate>Thu, 26 Nov 2026 13:42:22 +0000</pubDate>
      <link>https://dev.to/47_robin_ebe9e47eb349d767/cfast-x-unity-dev-report-4-building-a-stateful-fortran-fire-simulation-worker-for-unity-9ao</link>
      <guid>https://dev.to/47_robin_ebe9e47eb349d767/cfast-x-unity-dev-report-4-building-a-stateful-fortran-fire-simulation-worker-for-unity-9ao</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;1. Development Environment&lt;/li&gt;
&lt;li&gt;2. Why a Stateful Fire Simulator Is Necessary&lt;/li&gt;
&lt;li&gt;3. System Architecture&lt;/li&gt;
&lt;li&gt;4. Extending the Fortran Calculation Loop&lt;/li&gt;
&lt;li&gt;5. Preserving DASSL Solver State&lt;/li&gt;
&lt;li&gt;6. Handling Changes in Simulation Inputs&lt;/li&gt;
&lt;li&gt;7. Designing the Communication Protocol&lt;/li&gt;
&lt;li&gt;8. Validating Native Inputs&lt;/li&gt;
&lt;li&gt;9. Interprocess Communication&lt;/li&gt;
&lt;li&gt;10. Atomic Publication of Simulation Results&lt;/li&gt;
&lt;li&gt;11. Asynchronous Process Management in CSharp&lt;/li&gt;
&lt;li&gt;12. Preventing Concurrent STEP Requests&lt;/li&gt;
&lt;li&gt;13. Separating the Different Time Domains&lt;/li&gt;
&lt;li&gt;14. Accepting Simulation Results Safely&lt;/li&gt;
&lt;li&gt;15. Validating Simulation Continuity&lt;/li&gt;
&lt;li&gt;16. Connecting Loading and Gameplay&lt;/li&gt;
&lt;li&gt;17. Model Identity and Build Provenance&lt;/li&gt;
&lt;li&gt;18. Worker Lifecycle Management&lt;/li&gt;
&lt;li&gt;19. Validation Results&lt;/li&gt;
&lt;li&gt;20. Similarities to Embedded Software Engineering&lt;/li&gt;
&lt;li&gt;21. AI-Assisted Native Software Development&lt;/li&gt;
&lt;li&gt;22. Current Limitations&lt;/li&gt;
&lt;li&gt;23. Interactive Technical Documentation&lt;/li&gt;
&lt;li&gt;24. Conclusion&lt;/li&gt;
&lt;li&gt;References&lt;/li&gt;
&lt;li&gt;About the Project&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I am an independent developer working on a firefighting and disaster response game called &lt;strong&gt;SOKYU: OPERATION RESCUE BLAZE SERIES&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The project combines Unity game development, embedded systems, robotics, artificial intelligence, and scientific fire simulation.&lt;/p&gt;

&lt;p&gt;In the previous development reports, I introduced how I integrated CFAST, a fire simulator developed by the National Institute of Standards and Technology (NIST), into an interactive game environment.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Report&lt;/th&gt;
&lt;th&gt;Technical Focus&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;#1&lt;/td&gt;
&lt;td&gt;Fire simulation integration and numerical stability&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#2&lt;/td&gt;
&lt;td&gt;Multiple fire sources, fuel consumption, and asynchronous state management&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#3&lt;/td&gt;
&lt;td&gt;Real-time smoke rendering and performance optimization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#4&lt;/td&gt;
&lt;td&gt;Stateful native simulation and interprocess communication&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In this fourth report, I will focus on the software architecture behind these features.&lt;/p&gt;

&lt;p&gt;CFAST is written primarily in Fortran, while Unity gameplay logic is implemented in C#.&lt;/p&gt;

&lt;p&gt;The challenge is to connect these two systems without losing the internal state of the fire simulation or blocking the game's main thread.&lt;/p&gt;

&lt;p&gt;Rather than repeatedly starting a conventional CFAST simulation, I developed a &lt;strong&gt;stateful CFAST derivative that operates as an independent native worker&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This article introduces the actual implementation architecture, including selected Fortran and C# code excerpts.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Development Environment
&lt;/h2&gt;

&lt;p&gt;The integration uses the following technologies.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Technology&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Game engine&lt;/td&gt;
&lt;td&gt;Unity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gameplay programming&lt;/td&gt;
&lt;td&gt;C#&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fire simulator&lt;/td&gt;
&lt;td&gt;CFAST 7.7.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Native programming&lt;/td&gt;
&lt;td&gt;Fortran&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Numerical solver&lt;/td&gt;
&lt;td&gt;DASSL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Communication&lt;/td&gt;
&lt;td&gt;Standard input and result files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asynchronous execution&lt;/td&gt;
&lt;td&gt;Task, async, await&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data integrity&lt;/td&gt;
&lt;td&gt;SHA-256&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Development assistance&lt;/td&gt;
&lt;td&gt;OpenAI Codex&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The CFAST derivative is based on a specific upstream revision.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CFAST Version: 7.7.7

Upstream Commit:
b43e74e0f43c704582c5782f5446597ce729a07f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Official repository:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/firemodels/cfast" rel="noopener noreferrer"&gt;https://github.com/firemodels/cfast&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pinning the upstream revision makes it possible to identify exactly which scientific simulation implementation the derivative is based on.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Why a Stateful Fire Simulator Is Necessary
&lt;/h2&gt;

&lt;p&gt;A conventional fire simulation workflow generally starts with predefined input conditions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Building Model
      |
Fire and Ventilation Conditions
      |
CFAST Execution
      |
Simulation Results
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This workflow is suitable when the simulation scenario is known before execution.&lt;/p&gt;

&lt;p&gt;An interactive game is different.&lt;/p&gt;

&lt;p&gt;During gameplay, a player may:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open or close a door.&lt;/li&gt;
&lt;li&gt;Open a window.&lt;/li&gt;
&lt;li&gt;Apply water to a fire.&lt;/li&gt;
&lt;li&gt;Extinguish a fire.&lt;/li&gt;
&lt;li&gt;Change the combustion conditions inside a compartment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These events cannot all be defined in advance.&lt;/p&gt;

&lt;p&gt;More importantly, the state of the fire depends on its previous history.&lt;/p&gt;

&lt;p&gt;Opening a door ten seconds after ignition is not necessarily equivalent to opening the same door sixty seconds after ignition.&lt;/p&gt;

&lt;p&gt;The temperature, smoke accumulation, oxygen concentration, and wall thermal conditions may already be different.&lt;/p&gt;

&lt;p&gt;Restarting CFAST from its initial state whenever an input changes would lose that history.&lt;/p&gt;

&lt;p&gt;I therefore extended CFAST so that it can receive new input conditions at accepted simulation boundaries while preserving its internal physical state.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. System Architecture
&lt;/h2&gt;

&lt;p&gt;The CFAST worker runs as a separate native process rather than executing directly inside Unity's managed runtime.&lt;/p&gt;

&lt;p&gt;The actual SOKYU integration contains the following principal components.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;StageTwoCfastBackground&lt;/td&gt;
&lt;td&gt;Stage02 gameplay integration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CfastLiveSession&lt;/td&gt;
&lt;td&gt;Request ownership and result acceptance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CfastLiveProcessTransport&lt;/td&gt;
&lt;td&gt;Native process communication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;live_inputs.f90&lt;/td&gt;
&lt;td&gt;Native input validation and application&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;solve.f90&lt;/td&gt;
&lt;td&gt;CFAST numerical calculation loop&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DASSL&lt;/td&gt;
&lt;td&gt;Numerical integration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BlazeZeroCfastSmokeVolume&lt;/td&gt;
&lt;td&gt;Compartment smoke rendering&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The overall architecture is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SOKYU / UNITY / C#
+---------------------------------------+
| Gameplay Logic                        |
| Fire Sources / Doors / Windows        |
|                 |                     |
| StageTwoCfastBackground               |
|                 |                     |
| CfastLiveSession                      |
|                 |                     |
| CfastLiveProcessTransport             |
+-----------------+---------------------+
                  |
                  | STEP / FIRE / VENTG
                  | Standard Input
                  v
CFAST NATIVE WORKER / FORTRAN
+---------------------------------------+
| live_inputs.f90                       |
|                 |                     |
| solve.f90                             |
|                 |                     |
| DASSL Numerical Integration           |
|                 |                     |
| Persistent Physical State             |
|                 |                     |
| Simulation Snapshot                   |
+-----------------+---------------------+
                  |
                  | Atomic Result File
                  v
UNITY RESULT VALIDATION
+---------------------------------------+
| Current / AcceptedStep                |
|                 |                     |
| Fire / Fuel State                     |
| Indoor Volumetric Smoke               |
| Opening Smoke Rendering               |
+---------------------------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The native worker preserves the simulation state while Unity continues processing the game.&lt;/p&gt;

&lt;p&gt;This architecture separates gameplay execution, scientific computing, communication, and graphics rendering.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Extending the Fortran Calculation Loop
&lt;/h2&gt;

&lt;p&gt;The main modification is applied to the CFAST numerical calculation loop.&lt;/p&gt;

&lt;p&gt;The relevant upstream file is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source/CFAST/solve.f90
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The conventional calculation loop contains a termination condition based on the specified simulation end time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight fortran"&gt;&lt;code&gt;&lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;idid&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mf"&gt;0.000001_eb&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;=&lt;/span&gt;&lt;span class="n"&gt;tstop&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the stateful derivative, the loop condition also considers whether live simulation mode is active.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight fortran"&gt;&lt;code&gt;&lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;idid&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mf"&gt;0.000001_eb&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;=&lt;/span&gt;&lt;span class="n"&gt;tstop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;or&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;live_active&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allows the calculation loop to remain active across multiple externally supplied simulation requests.&lt;/p&gt;

&lt;p&gt;However, simply keeping the loop alive is not sufficient.&lt;/p&gt;

&lt;p&gt;The worker must stop at the requested simulation boundary, publish the accepted result, and wait for the next command.&lt;/p&gt;

&lt;p&gt;The following code is adapted from the actual patch, with performance instrumentation omitted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight fortran"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;live_active&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;idid&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="n"&gt;live_target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="k"&gt;then&lt;/span&gt;

    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;update_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;odevara&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;update_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;odevarc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;update_species&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_eb&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;snapshot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;total_steps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
        &lt;span class="n"&gt;rwork&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;iwork&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;pprime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nf"&gt;rpar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;next_request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;tstop&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;live_changed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;live_done&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="k"&gt;exit&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;live_changed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;live_rebase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
        &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;n_odes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;rwork&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
        &lt;span class="n"&gt;pdzero&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;pdnew&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;rpar&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;ipar&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important operations are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reach the requested simulation boundary.&lt;/li&gt;
&lt;li&gt;Synchronize the accepted numerical state.&lt;/li&gt;
&lt;li&gt;Generate a simulation snapshot.&lt;/li&gt;
&lt;li&gt;Publish the result.&lt;/li&gt;
&lt;li&gt;Receive the next request.&lt;/li&gt;
&lt;li&gt;Apply changes to the simulation inputs.&lt;/li&gt;
&lt;li&gt;Continue from the accepted state.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The same invocation of the native simulation loop remains active.&lt;/p&gt;

&lt;p&gt;The calculation is not reconstructed from the previously exported snapshot.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Preserving DASSL Solver State
&lt;/h2&gt;

&lt;p&gt;CFAST uses DASSL to solve differential-algebraic equations.&lt;/p&gt;

&lt;p&gt;A general DAE system can be expressed as:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
F(t,y,\dot{y})=0&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;DASSL maintains internal information required for numerical integration.&lt;/p&gt;

&lt;p&gt;The stateful derivative retains the relevant solver arrays and physical state within the running worker.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Variable&lt;/th&gt;
&lt;th&gt;General Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;p&lt;/td&gt;
&lt;td&gt;Current numerical state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pprime&lt;/td&gt;
&lt;td&gt;Time derivative of the state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;rwork&lt;/td&gt;
&lt;td&gt;Real-valued solver workspace&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;iwork&lt;/td&gt;
&lt;td&gt;Integer solver workspace&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;info&lt;/td&gt;
&lt;td&gt;Solver control information&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In addition to these arrays, the worker retains physical simulation history.&lt;/p&gt;

&lt;p&gt;This includes compartment conditions, species quantities, wall conduction, target states, ignition events, and accumulated quantities such as fuel pyrolysis.&lt;/p&gt;

&lt;p&gt;The distinction between internal state and exported results is important.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Internal CFAST State
----------------------------
Solver Workspace
Physical State
Gas Species History
Wall Conduction
Ignition and Event State
Accumulated Quantities
             |
             | Selected Observation
             v
Exported Snapshot
----------------------------
Room Conditions
Fire Conditions
Opening Flow Conditions
Simulation Time
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The snapshot is an observation intended for Unity.&lt;/p&gt;

&lt;p&gt;It is not a complete restart checkpoint containing every piece of internal information required to reconstruct the native solver.&lt;/p&gt;

&lt;p&gt;When no simulation input changes, the derivative does not deliberately reset DASSL at every STEP boundary.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Handling Changes in Simulation Inputs
&lt;/h2&gt;

&lt;p&gt;A player opening a door changes the gas transport conditions.&lt;/p&gt;

&lt;p&gt;A player extinguishing a fire changes the requested heat release rate.&lt;/p&gt;

&lt;p&gt;These changes can modify the equations being evaluated by the solver.&lt;/p&gt;

&lt;p&gt;Preserving the physical state does not mean that numerical reinitialization must never occur.&lt;/p&gt;

&lt;p&gt;When the input changes, the derivative uses the existing CFAST solver reinitialization mechanism while retaining the accepted physical state.&lt;/p&gt;

&lt;p&gt;The actual implementation includes the following rebasing operation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight fortran"&gt;&lt;code&gt;&lt;span class="n"&gt;told&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;

&lt;span class="nf"&gt;pold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;nequals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;p&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;nequals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;ipar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;ires&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;calculate_residuals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
    &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;pdzero&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;pdnew&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;ires&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;rpar&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;ipar&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ires&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'input residual'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;pdold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n_odes&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;nequals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
    &lt;span class="nf"&gt;pdnew&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n_odes&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;nequals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;set_info_flags&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;rwork&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code evaluates the residual using the updated conditions and rebases the relevant non-ODE flow history before invoking the existing solver initialization mechanism.&lt;/p&gt;

&lt;p&gt;The compartment, gas species, and wall thermal states are not reset to their original values.&lt;/p&gt;

&lt;p&gt;The intended behavior is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Accepted Physical State
          |
     Input Changes?
       /       \
     No         Yes
      |          |
Continue      Re-evaluate
Solver        Residual
History          |
              Rebase Flow
              Information
                 |
          Solver Reinitialization
                 |
      Continue Physical Simulation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the meaning of stateful simulation in this project.&lt;/p&gt;

&lt;p&gt;The physical simulation continues across requests, while numerical solver preparation is performed when required.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Designing the Communication Protocol
&lt;/h2&gt;

&lt;p&gt;Unity and the Fortran worker exchange information using a custom text-based protocol.&lt;/p&gt;

&lt;p&gt;The protocol is designed to preserve the relationship between:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The execution session&lt;/li&gt;
&lt;li&gt;The simulation model&lt;/li&gt;
&lt;li&gt;The STEP number&lt;/li&gt;
&lt;li&gt;The previous accepted simulation time&lt;/li&gt;
&lt;li&gt;The next requested simulation time&lt;/li&gt;
&lt;li&gt;The fire and opening conditions&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7.1 STEP Request
&lt;/h3&gt;

&lt;p&gt;The basic request format is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;STEP runBase64url epoch modelSHA256 step fromSeconds targetSeconds fireUpdateCount wallVentUpdateCount
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;runBase64url&lt;/td&gt;
&lt;td&gt;Encoded execution session identifier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;epoch&lt;/td&gt;
&lt;td&gt;Session generation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;modelSHA256&lt;/td&gt;
&lt;td&gt;Simulation model identity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;step&lt;/td&gt;
&lt;td&gt;Sequential request number&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;fromSeconds&lt;/td&gt;
&lt;td&gt;Previously accepted simulation time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;targetSeconds&lt;/td&gt;
&lt;td&gt;Requested simulation time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;fireUpdateCount&lt;/td&gt;
&lt;td&gt;Number of fire update records&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;wallVentUpdateCount&lt;/td&gt;
&lt;td&gt;Number of wall vent update records&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The run identifier uses canonical, unpadded Base64url encoding.&lt;/p&gt;

&lt;p&gt;This avoids problematic characters that could otherwise interfere with Fortran list-directed input.&lt;/p&gt;

&lt;h3&gt;
  
  
  7.2 Fire Source Input
&lt;/h3&gt;

&lt;p&gt;The fire source update format is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FIRE id hrrWatts heatOfCombustionJoulesPerKg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fire ID refers to the native model's one-based fire ordinal, not a Unity GameObject name.&lt;/p&gt;

&lt;p&gt;The requested heat release rate and heat of combustion are used to define the prescribed fuel pyrolysis rate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight fortran"&gt;&lt;code&gt;&lt;span class="nf"&gt;fireinfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="nf"&gt;qdot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;q&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;fireinfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="nf"&gt;mdot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;q&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nf"&gt;hoc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;fireinfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="nf"&gt;hoc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;hoc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The relationship is:&lt;/p&gt;

&lt;p&gt;$$&lt;/p&gt;

&lt;h1&gt;
  
  
  \dot{m}_{fuel}
&lt;/h1&gt;

&lt;p&gt;\frac{\dot{Q}_{requested}}{\Delta H_c}&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;The actual HRR calculated by CFAST can differ from the requested HRR because of oxygen limitations and other modeled combustion conditions.&lt;/p&gt;
&lt;h3&gt;
  
  
  7.3 Opening Input
&lt;/h3&gt;

&lt;p&gt;Wall opening conditions are updated using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VENT id openingFraction
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A geometry-enabled update can also be submitted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VENTG id openingFraction width sill soffit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This extended record includes the opening width, lower edge, and upper edge.&lt;/p&gt;

&lt;p&gt;It is used to represent dynamic opening conditions derived from the Unity building.&lt;/p&gt;

&lt;p&gt;For example, a door operation can change the effective opening condition submitted to the worker.&lt;/p&gt;

&lt;p&gt;The current dynamic input protocol supports wall vents. Dynamic control of horizontal and mechanical vents is outside the implemented protocol described here.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. Validating Native Inputs
&lt;/h2&gt;

&lt;p&gt;The communication protocol must reject invalid data before changing the native simulation state.&lt;/p&gt;

&lt;p&gt;The Fortran input implementation contains explicit validation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight fortran"&gt;&lt;code&gt;&lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
    &lt;span class="s1"&gt;'request time range'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;step&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="n"&gt;live_step&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;epoch&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
    &lt;span class="s1"&gt;'step sequence'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hash&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="n"&gt;model_hash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
    &lt;span class="s1"&gt;'model identity'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fire input values are also validated.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight fortran"&gt;&lt;code&gt;&lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;q&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hoc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
    &lt;span class="s1"&gt;'fire units/range'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Opening fractions must remain within the permitted range.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight fortran"&gt;&lt;code&gt;&lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;
    &lt;span class="s1"&gt;'vent fraction'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Additional checks cover duplicate IDs, invalid record counts, model identity, and non-finite numerical values.&lt;/p&gt;

&lt;p&gt;Importantly, the implementation validates the entire input batch before applying changes to the model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Receive Request
      |
Validate Request Header
      |
Validate All FIRE Records
      |
Validate All VENT Records
      |
All Records Valid?
    /      \
  No        Yes
   |         |
Reject     Apply Input
Request    Changes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This avoids accepting the valid portion of a request while leaving the simulation in a partially updated state because another record was invalid.&lt;/p&gt;

&lt;p&gt;For a stateful simulator, input validation is part of maintaining numerical and application-level consistency.&lt;/p&gt;




&lt;h2&gt;
  
  
  9. Interprocess Communication
&lt;/h2&gt;

&lt;p&gt;The native communication architecture combines standard input and file-based result exchange.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Communication&lt;/th&gt;
&lt;th&gt;Mechanism&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Unity to CFAST&lt;/td&gt;
&lt;td&gt;Standard input&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CFAST startup acknowledgement&lt;/td&gt;
&lt;td&gt;ready file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CFAST to Unity&lt;/td&gt;
&lt;td&gt;Result files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Standard output&lt;/td&gt;
&lt;td&gt;Diagnostic log&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Standard error&lt;/td&gt;
&lt;td&gt;Diagnostic log&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The diagnostic streams are separated from the machine-readable simulation results.&lt;/p&gt;

&lt;p&gt;This prevents ordinary diagnostic messages from being interpreted as protocol records.&lt;/p&gt;

&lt;p&gt;The worker operates in a dedicated execution directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Session Directory/
|
+-- model.in
+-- stdout.log
+-- stderr.log
|
+-- wire/
    |
    +-- ready
    +-- step-1.result
    +-- step-2.result
    +-- step-3.result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each request advances the same native simulation process.&lt;/p&gt;

&lt;p&gt;A new process is not started for each STEP.&lt;/p&gt;




&lt;h2&gt;
  
  
  10. Atomic Publication of Simulation Results
&lt;/h2&gt;

&lt;p&gt;File-based communication introduces a potential race condition.&lt;/p&gt;

&lt;p&gt;A file may already exist while its contents are still being written.&lt;/p&gt;

&lt;p&gt;If Unity reads it at that moment, the result may be incomplete.&lt;/p&gt;

&lt;p&gt;The native publication protocol therefore uses the following sequence.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Write Temporary Result
          |
Close Temporary File
          |
Rename Within the Same Filesystem
          |
Publish Final Result Filename
          |
Unity Reads Final Result
          |
Validate and Accept
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;step-42.result.tmp
          |
          | Close + Rename
          v
step-42.result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unity consumes the final filename rather than the temporary file.&lt;/p&gt;

&lt;p&gt;This provides an atomic publication boundary under the expected same-filesystem rename semantics.&lt;/p&gt;

&lt;p&gt;It does not provide a persistent recovery checkpoint or guarantee durability after every possible operating system failure.&lt;/p&gt;

&lt;p&gt;The purpose is to prevent a partially written simulation result from being accepted as a complete observation.&lt;/p&gt;




&lt;h2&gt;
  
  
  11. Asynchronous Process Management in CSharp
&lt;/h2&gt;

&lt;p&gt;On the Unity side, native process communication is managed by &lt;code&gt;CfastLiveProcessTransport&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The worker is started using the .NET process API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ProcessStartInfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;executable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"model.in"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;WorkingDirectory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;directory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;UseShellExecute&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;CreateNoWindow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;RedirectStandardInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;RedirectStandardOutput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;RedirectStandardError&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The native process runs independently of the Unity main thread.&lt;/p&gt;

&lt;p&gt;STEP requests are executed asynchronously.&lt;/p&gt;

&lt;p&gt;The following simplified excerpt illustrates the structure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;deadline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
        &lt;span class="nc"&gt;CancellationTokenSource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CreateLinkedTokenSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;cancellation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="n"&gt;deadline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CancelAfter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Start the worker when necessary.&lt;/span&gt;
    &lt;span class="c1"&gt;// Submit the request.&lt;/span&gt;
    &lt;span class="c1"&gt;// Wait for the result.&lt;/span&gt;
    &lt;span class="c1"&gt;// Parse and validate the response.&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The main objective is to avoid blocking Unity's gameplay thread while scientific computation is in progress.&lt;/p&gt;

&lt;p&gt;However, asynchronous execution does not eliminate numerical calculation delays.&lt;/p&gt;

&lt;p&gt;If CFAST becomes unresponsive, Unity can continue processing the game, but new simulation data will not be available.&lt;/p&gt;

&lt;p&gt;That distinction was particularly important in the numerical stability investigation introduced in Development Report #1.&lt;/p&gt;




&lt;h2&gt;
  
  
  12. Preventing Concurrent STEP Requests
&lt;/h2&gt;

&lt;p&gt;The worker represents a sequential simulation.&lt;/p&gt;

&lt;p&gt;A STEP request must begin from the previously accepted native simulation state.&lt;/p&gt;

&lt;p&gt;Submitting multiple requests concurrently would complicate the relationship between the current native state and the requested simulation times.&lt;/p&gt;

&lt;p&gt;The transport therefore permits only one request in flight.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Interlocked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CompareExchange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="k"&gt;ref&lt;/span&gt; &lt;span class="n"&gt;inFlight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;InvalidOperationException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s2"&gt;"One native request may be in flight."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The intended execution sequence is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Accepted State S0
        |
      STEP 1
        |
Accepted State S1
        |
      STEP 2
        |
Accepted State S2
        |
      STEP 3
        |
Accepted State S3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each request has an explicit starting state and target time.&lt;/p&gt;

&lt;p&gt;This is not a parallel simulation of several independent future states.&lt;/p&gt;

&lt;p&gt;The single-request constraint makes the ownership and continuity of the native simulation easier to validate.&lt;/p&gt;




&lt;h2&gt;
  
  
  13. Separating the Different Time Domains
&lt;/h2&gt;

&lt;p&gt;A real-time game and a numerical simulator use different concepts of time.&lt;/p&gt;

&lt;p&gt;The current implementation distinguishes between several time domains.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Time Domain&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Unity frame time&lt;/td&gt;
&lt;td&gt;Time associated with game and rendering frames&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gameplay time&lt;/td&gt;
&lt;td&gt;Elapsed time within the game&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Committed simulation time&lt;/td&gt;
&lt;td&gt;Last accepted CFAST time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requested target time&lt;/td&gt;
&lt;td&gt;Next simulation boundary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DASSL internal time step&lt;/td&gt;
&lt;td&gt;Numerical integration interval&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;File polling interval&lt;/td&gt;
&lt;td&gt;Result-file observation interval&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The result file polling implementation contains the following code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nc"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;cancellation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ThrowIfCancellationRequested&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nc"&gt;IsAvailable&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;IOException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="s2"&gt;"Native worker terminated without a complete observation."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cancellation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ConfigureAwait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 10 ms delay is an I/O polling interval.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It is not the CFAST simulation time step.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;DASSL determines its internal integration steps according to the numerical calculation.&lt;/p&gt;

&lt;p&gt;Similarly, Unity may render several frames between accepted CFAST updates.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CFAST SIMULATION

State A ---------- State B -------- State C


UNITY RENDERING

Frame 1  Frame 2  Frame 3  Frame 4  Frame 5
   |        |        |        |        |
State A  State A  State B  State B  State C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This diagram is conceptual and does not represent measured frame or solver timing.&lt;/p&gt;

&lt;p&gt;Separating these time domains is essential when connecting a scientific simulator to a real-time graphics application.&lt;/p&gt;




&lt;h2&gt;
  
  
  14. Accepting Simulation Results Safely
&lt;/h2&gt;

&lt;p&gt;A completed asynchronous task does not automatically become the current gameplay state.&lt;/p&gt;

&lt;p&gt;The project uses &lt;code&gt;CfastLiveSession&lt;/code&gt; to manage requests and accepted observations.&lt;/p&gt;

&lt;p&gt;The request creation process includes a stamp containing the session identity, model identity, request number, and simulation boundaries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;stamp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CfastStepStamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;runId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;epoch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;modelHash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;step&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;CommittedSeconds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;targetSeconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The session starts the asynchronous operation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;pending&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;transport&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StepAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;cancellation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the owner calls &lt;code&gt;Pump&lt;/code&gt;, the session checks whether the result can be accepted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;retired&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;paused&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
    &lt;span class="n"&gt;pending&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;pending&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IsCompleted&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pending&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GetAwaiter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GetResult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;Validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;accepted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CfastLiveAcceptedStep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Stamp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;Current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nc"&gt;AcceptedStep&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;accepted&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Although &lt;code&gt;GetResult()&lt;/code&gt; appears in this code, the task completion state is checked first.&lt;/p&gt;

&lt;p&gt;The owner does not deliberately block while waiting for an unfinished numerical calculation.&lt;/p&gt;

&lt;p&gt;The result acceptance process is therefore:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Native Calculation Completed
            |
         Task Ready
            |
       Unity Session Pump
            |
       Validate Response
            |
       Validation Passed?
          /      \
        No        Yes
         |         |
     Reject      Update
     Result      Current State
                    |
              Fire and Smoke
              Visualization
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An asynchronous operation completing and a simulation state being accepted are two separate events.&lt;/p&gt;

&lt;p&gt;This is an important architectural decision in the SOKYU implementation.&lt;/p&gt;




&lt;h2&gt;
  
  
  15. Validating Simulation Continuity
&lt;/h2&gt;

&lt;p&gt;Each native result is validated before it becomes the current simulation state.&lt;/p&gt;

&lt;p&gt;The validation includes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Validation Item&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Session identity&lt;/td&gt;
&lt;td&gt;Prevent mixing different runs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Epoch&lt;/td&gt;
&lt;td&gt;Identify the correct execution generation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Model SHA-256&lt;/td&gt;
&lt;td&gt;Verify the input model&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;STEP number&lt;/td&gt;
&lt;td&gt;Match request and response&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Actual simulation time&lt;/td&gt;
&lt;td&gt;Verify the requested boundary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Compartment count&lt;/td&gt;
&lt;td&gt;Verify result layout&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fire count&lt;/td&gt;
&lt;td&gt;Verify native fire mapping&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Opening count&lt;/td&gt;
&lt;td&gt;Verify native opening mapping&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Process ID&lt;/td&gt;
&lt;td&gt;Check worker continuity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accepted internal steps&lt;/td&gt;
&lt;td&gt;Check numerical progression&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DASSL initialization count&lt;/td&gt;
&lt;td&gt;Check counter continuity&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One of the actual continuity checks is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Current&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ProcessId&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="nc"&gt;Current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ProcessId&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
     &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AcceptedSteps&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nc"&gt;Current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AcceptedSteps&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
     &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DasslInitializations&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;
         &lt;span class="nc"&gt;Current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DasslInitializations&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;InvalidDataException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s2"&gt;"Native continuity mismatch."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These checks are designed to prevent unexpected discontinuities in the accepted observation sequence.&lt;/p&gt;

&lt;p&gt;A matching process ID does not prove that the physical simulation is correct.&lt;/p&gt;

&lt;p&gt;Similarly, a monotonically increasing solver counter does not establish numerical accuracy.&lt;/p&gt;

&lt;p&gt;However, these observations help verify that the same native calculation process is continuing as intended.&lt;/p&gt;




&lt;h2&gt;
  
  
  16. Connecting Loading and Gameplay
&lt;/h2&gt;

&lt;p&gt;Stage02 uses an introductory heat release history during its initial loading sequence.&lt;/p&gt;

&lt;p&gt;The objective is to allow gameplay to begin with an existing fire environment rather than starting every simulation from an entirely clear compartment.&lt;/p&gt;

&lt;p&gt;The loading sequence prepares the native model and worker, then advances the introductory simulation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stage02 Loading
      |
Load Archived HRR Input
      |
Generate Native Model
      |
Extract and Validate Worker
      |
Start CFAST
      |
Advance Introductory Simulation
      |
Accept Final Introductory State
      |
Begin Gameplay
      |
Continue Using the Same Worker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same worker continues operating after the introductory phase.&lt;/p&gt;

&lt;p&gt;Its compartment conditions and numerical history are not discarded when gameplay begins.&lt;/p&gt;

&lt;p&gt;The Unity-side implementation determines the next target time using the introductory simulation boundary and elapsed gameplay time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
    &lt;span class="n"&gt;intro&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;EndSeconds&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;elapsed&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;adoptedAt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;HasPending&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
    &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CommittedSeconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A new request is issued only when the previous request is no longer pending and the target time advances beyond the accepted simulation time.&lt;/p&gt;

&lt;p&gt;The introductory fire history and the subsequent player-driven conditions are connected through the same stateful simulation process.&lt;/p&gt;




&lt;h2&gt;
  
  
  17. Model Identity and Build Provenance
&lt;/h2&gt;

&lt;p&gt;CFAST fire IDs and opening IDs are specific to a particular input model.&lt;/p&gt;

&lt;p&gt;Changing a model without updating the associated mappings could cause a Unity command to affect the wrong native fire or opening.&lt;/p&gt;

&lt;p&gt;To reduce this risk, the project verifies model identity using SHA-256.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;SHA256&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;OpenRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;copied&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;modelHash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;BitConverter&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ToString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ComputeHash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"-"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ToLowerInvariant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;modelHash&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Stamp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ModelId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;InvalidDataException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s2"&gt;"Input file SHA256 mismatch."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The bundled worker is also associated with a pinned manifest and executable hash.&lt;/p&gt;

&lt;p&gt;The build process retains information about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Upstream CFAST revision&lt;/li&gt;
&lt;li&gt;Source file hashes&lt;/li&gt;
&lt;li&gt;Applied patches&lt;/li&gt;
&lt;li&gt;Compiler information&lt;/li&gt;
&lt;li&gt;Build inputs&lt;/li&gt;
&lt;li&gt;Generated worker identity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The original upstream source and executable are not directly overwritten.&lt;/p&gt;

&lt;p&gt;Instead, the derivative is built from a preserved source snapshot in a separate build environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Official CFAST Source
          |
Pinned Source Revision
          |
Separate Build Directory
          |
Apply Live Integration Patch
          |
Add Native Integration Modules
          |
Compile Native Worker
          |
Record Build Provenance
          |
Package Worker for Unity
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SHA-256 verification confirms artifact identity.&lt;/p&gt;

&lt;p&gt;It does not independently establish the physical validity of the simulation model.&lt;/p&gt;




&lt;h2&gt;
  
  
  18. Worker Lifecycle Management
&lt;/h2&gt;

&lt;p&gt;The native worker has an explicit lifecycle associated with the game session.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create Session
      |
Prepare Workspace
      |
Start Native Worker
      |
Submit and Accept STEP Requests
      |
Stage Ends or Session Fails
      |
Retire Session
      |
Release Native Process
      |
Wait for Log Streams to Finish
      |
Release Workspace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a session is retired, subsequent responses are not permitted to update its accepted state.&lt;/p&gt;

&lt;p&gt;This is important because asynchronous operations can complete after the game has already transitioned to another state.&lt;/p&gt;

&lt;p&gt;The implementation also waits for relevant native process and log operations before completing workspace release.&lt;/p&gt;

&lt;p&gt;The current implementation does not automatically reconstruct the full CFAST simulation state in a replacement worker after an abnormal termination.&lt;/p&gt;

&lt;p&gt;That would require a separate recovery design.&lt;/p&gt;

&lt;p&gt;A previously accepted observation is not sufficient to restore every internal DASSL and CFAST state variable.&lt;/p&gt;




&lt;h2&gt;
  
  
  19. Validation Results
&lt;/h2&gt;

&lt;p&gt;The stateful worker is the foundation of the Stage02 Hall integration and smoke rendering system.&lt;/p&gt;

&lt;p&gt;Following the building model correction described in Development Report #1, the following results were obtained using the existing production worker and the revised Stage02 model.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Validation Item&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Previously unresponsive conditions resolved&lt;/td&gt;
&lt;td&gt;3 / 3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Native STEP responses&lt;/td&gt;
&lt;td&gt;1,078 / 1,078&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unity tests&lt;/td&gt;
&lt;td&gt;37 / 37&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Failed Unity tests&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Skipped Unity tests&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Independent review&lt;/td&gt;
&lt;td&gt;PASS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Outstanding review findings&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The Unity tests covered three gameplay modes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AIM3D&lt;/li&gt;
&lt;li&gt;AIM3D2&lt;/li&gt;
&lt;li&gt;ZERO&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the tested scenes, the accepted CFAST simulation time advanced beyond 20 seconds while indoor smoke and opening smoke updates continued.&lt;/p&gt;

&lt;p&gt;Additional checks included water damage retention, entrance door operation in ZERO, and native worker release when returning to the title screen.&lt;/p&gt;

&lt;p&gt;These results apply to the specific Stage02 integration and tested configurations.&lt;/p&gt;

&lt;p&gt;They are not a general performance benchmark of every possible CFAST model or execution environment.&lt;/p&gt;




&lt;h2&gt;
  
  
  20. Similarities to Embedded Software Engineering
&lt;/h2&gt;

&lt;p&gt;One of the interesting aspects of this project is how closely its architecture resembles embedded software engineering.&lt;/p&gt;

&lt;p&gt;Although Unity is a game engine, many of the underlying technical challenges are system-level problems.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Embedded Software Concept&lt;/th&gt;
&lt;th&gt;Application in SOKYU&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Task communication&lt;/td&gt;
&lt;td&gt;Unity and native worker communication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;State machine&lt;/td&gt;
&lt;td&gt;Simulation session lifecycle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Exclusive access&lt;/td&gt;
&lt;td&gt;Single in-flight STEP request&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asynchronous events&lt;/td&gt;
&lt;td&gt;Native calculation completion&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Input validation&lt;/td&gt;
&lt;td&gt;FIRE and VENT record validation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data consistency&lt;/td&gt;
&lt;td&gt;Request and response identity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Timeout management&lt;/td&gt;
&lt;td&gt;Unresponsive worker detection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resource management&lt;/td&gt;
&lt;td&gt;Native process and workspace release&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Version management&lt;/td&gt;
&lt;td&gt;Model and worker identity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Diagnostic logging&lt;/td&gt;
&lt;td&gt;Separate native output streams&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;As someone with experience in embedded software development, I find these similarities particularly interesting.&lt;/p&gt;

&lt;p&gt;The game engine provides the interactive environment.&lt;/p&gt;

&lt;p&gt;The scientific simulator provides numerical calculations.&lt;/p&gt;

&lt;p&gt;The software architecture connects these systems through clearly defined interfaces and state ownership.&lt;/p&gt;




&lt;h2&gt;
  
  
  21. AI-Assisted Native Software Development
&lt;/h2&gt;

&lt;p&gt;This project is being developed with the assistance of OpenAI Codex.&lt;/p&gt;

&lt;p&gt;The development work extends beyond generating Unity C# scripts.&lt;/p&gt;

&lt;p&gt;It includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Investigating the upstream Fortran source code&lt;/li&gt;
&lt;li&gt;Understanding the CFAST calculation loop&lt;/li&gt;
&lt;li&gt;Implementing native input control modules&lt;/li&gt;
&lt;li&gt;Designing communication protocols&lt;/li&gt;
&lt;li&gt;Investigating numerical solver behavior&lt;/li&gt;
&lt;li&gt;Developing C# asynchronous communication&lt;/li&gt;
&lt;li&gt;Performing regression tests&lt;/li&gt;
&lt;li&gt;Conducting independent code reviews&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The upstream numerical implementation is preserved, and modifications are managed as a separate derivative.&lt;/p&gt;

&lt;p&gt;Implementation and review responsibilities are separated.&lt;/p&gt;

&lt;p&gt;I also distinguish approved requirements from proposed functionality so that automated testing does not unnecessarily expand the development scope.&lt;/p&gt;

&lt;p&gt;AI-assisted development makes it possible to investigate unfamiliar technical domains.&lt;/p&gt;

&lt;p&gt;However, defining the engineering objective, understanding the meaning of the calculation results, and deciding which changes should be adopted remain essential developer responsibilities.&lt;/p&gt;




&lt;h2&gt;
  
  
  22. Current Limitations
&lt;/h2&gt;

&lt;p&gt;The stateful CFAST integration provides a foundation for simulation-driven gameplay, but it has several limitations.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Current Scope&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Persistent native calculation&lt;/td&gt;
&lt;td&gt;Implemented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dynamic fire inputs&lt;/td&gt;
&lt;td&gt;Implemented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dynamic wall vent inputs&lt;/td&gt;
&lt;td&gt;Implemented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Geometry-enabled opening inputs&lt;/td&gt;
&lt;td&gt;Implemented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asynchronous communication&lt;/td&gt;
&lt;td&gt;Implemented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Result validation&lt;/td&gt;
&lt;td&gt;Implemented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Automatic full-state restoration&lt;/td&gt;
&lt;td&gt;Not implemented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dynamic horizontal vent protocol&lt;/td&gt;
&lt;td&gt;Not implemented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stage02 LAN integration&lt;/td&gt;
&lt;td&gt;Outside the current native integration path&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The ordinary Stage02 CFAST integration in the inspected implementation targets supported macOS ARM64 modes.&lt;/p&gt;

&lt;p&gt;Full Windows, LAN, and production deployment validation should be considered separately.&lt;/p&gt;

&lt;p&gt;The architecture allows incremental simulation during gameplay, but this does not guarantee that every simulation request will complete within real-time constraints.&lt;/p&gt;

&lt;p&gt;The physical limitations of CFAST as a zone model also remain.&lt;/p&gt;

&lt;p&gt;This project is being developed as a game rather than a validated engineering tool for real-world fire prediction.&lt;/p&gt;




&lt;h2&gt;
  
  
  23. Interactive Technical Documentation
&lt;/h2&gt;

&lt;p&gt;I have also prepared technical documentation on the SOKYU project website.&lt;/p&gt;

&lt;p&gt;The website presents the fire simulation architecture through visual diagrams, animations, and interactive explanations.&lt;/p&gt;

&lt;h3&gt;
  
  
  CFAST × Unity Technical Guide
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html" rel="noopener noreferrer"&gt;Explore the CFAST and Unity Fire Simulation Guide&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Stage02 Technical Validation
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html#stage02-validation" rel="noopener noreferrer"&gt;Stage02 — Numerical Stability, Smoke Rendering, and Opening Control&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Topics include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CFAST's two-zone model&lt;/li&gt;
&lt;li&gt;Stateful simulation architecture&lt;/li&gt;
&lt;li&gt;Compartment and opening geometry&lt;/li&gt;
&lt;li&gt;Indoor volumetric smoke&lt;/li&gt;
&lt;li&gt;Opening smoke transport&lt;/li&gt;
&lt;li&gt;Numerical solver instability&lt;/li&gt;
&lt;li&gt;Building model corrections&lt;/li&gt;
&lt;li&gt;Rendering performance optimization&lt;/li&gt;
&lt;li&gt;Interactive interior doors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The documentation is primarily presented in Japanese, with visual diagrams and animations explaining the technical concepts.&lt;/p&gt;




&lt;h2&gt;
  
  
  24. Conclusion
&lt;/h2&gt;

&lt;p&gt;In this development report, I introduced the stateful Fortran-based CFAST worker that supports the fire simulation system in SOKYU: OPERATION RESCUE BLAZE SERIES.&lt;/p&gt;

&lt;p&gt;The main engineering challenges included:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Extending the CFAST numerical calculation loop&lt;/li&gt;
&lt;li&gt;Preserving physical and numerical state across requests&lt;/li&gt;
&lt;li&gt;Handling dynamic changes to fire and opening conditions&lt;/li&gt;
&lt;li&gt;Designing a language-independent communication protocol&lt;/li&gt;
&lt;li&gt;Publishing simulation observations atomically&lt;/li&gt;
&lt;li&gt;Managing asynchronous native execution in C#&lt;/li&gt;
&lt;li&gt;Preventing concurrent simulation requests&lt;/li&gt;
&lt;li&gt;Validating the identity and continuity of simulation results&lt;/li&gt;
&lt;li&gt;Connecting introductory simulation and normal gameplay&lt;/li&gt;
&lt;li&gt;Managing native worker lifecycles&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Integrating scientific computing into a game engine requires more than connecting an external executable.&lt;/p&gt;

&lt;p&gt;It requires a software architecture that respects the numerical model, preserves state ownership, and maintains reliable communication between independent execution environments.&lt;/p&gt;

&lt;p&gt;The stateful CFAST worker is the computational foundation behind the fire behavior, smoke transport, and interactive environmental changes introduced in the previous reports.&lt;/p&gt;

&lt;p&gt;In the next development report, I will investigate a particularly challenging issue encountered during development:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Debugging Numerical Stalls in Fortran-Based CFAST and DASSL Through Residual Analysis.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That report will focus on Newton iteration, discontinuous gas-layer assignment, convergence rejection, and numerical time-step reduction.&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://pages.nist.gov/cfast/" rel="noopener noreferrer"&gt;NIST CFAST Official Website&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/firemodels/cfast" rel="noopener noreferrer"&gt;CFAST Official GitHub Repository&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/firemodels/cfast/tree/b43e74e0f43c704582c5782f5446597ce729a07f" rel="noopener noreferrer"&gt;CFAST Version 7.7.7 — Development Baseline Source Code&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://doi.org/10.6028/NIST.TN.1889v1" rel="noopener noreferrer"&gt;CFAST Version 7 Technical Reference Guide&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://pages.nist.gov/fds/" rel="noopener noreferrer"&gt;NIST Fire Dynamics Simulator and Smokeview&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  About the Project
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SOKYU: OPERATION RESCUE BLAZE SERIES&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An independently developed firefighting and disaster response game combining:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scientific fire simulation&lt;/li&gt;
&lt;li&gt;Unity game development&lt;/li&gt;
&lt;li&gt;Fortran and C# integration&lt;/li&gt;
&lt;li&gt;Real-time computer graphics&lt;/li&gt;
&lt;li&gt;Embedded systems&lt;/li&gt;
&lt;li&gt;Robotics&lt;/li&gt;
&lt;li&gt;Artificial intelligence&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Developed by &lt;strong&gt;Motomachi Digital Making Lab&lt;/strong&gt;, Yokohama, Japan.&lt;/p&gt;

&lt;p&gt;Project Technical Website:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html" rel="noopener noreferrer"&gt;https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stage02 Technical Validation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html#stage02-validation" rel="noopener noreferrer"&gt;https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html#stage02-validation&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;CFAST × Unity Development Report #4&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;November 26, 2026&lt;/p&gt;

</description>
      <category>cfast</category>
      <category>nist</category>
      <category>unity3d</category>
    </item>
    <item>
      <title>CFAST Unity Dev Report #3: From Fire Simulation to Real-Time Smoke Rendering</title>
      <dc:creator>Hidenori Ishii</dc:creator>
      <pubDate>Thu, 26 Nov 2026 13:32:27 +0000</pubDate>
      <link>https://dev.to/47_robin_ebe9e47eb349d767/cfast-x-unity-dev-report-3-from-fire-simulation-to-real-time-smoke-rendering-hf3</link>
      <guid>https://dev.to/47_robin_ebe9e47eb349d767/cfast-x-unity-dev-report-3-from-fire-simulation-to-real-time-smoke-rendering-hf3</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;1. Game Smoke Effects vs. Simulation-Driven Smoke&lt;/li&gt;
&lt;li&gt;2. Understanding the CFAST Two-Zone Model&lt;/li&gt;
&lt;li&gt;3. Two Separate Smoke Rendering Systems&lt;/li&gt;
&lt;li&gt;4. Indoor Volumetric Smoke Rendering&lt;/li&gt;
&lt;li&gt;5. Optical Density and Smoke Visibility&lt;/li&gt;
&lt;li&gt;6. Visualizing Gas Transport Through Openings&lt;/li&gt;
&lt;li&gt;7. Bidirectional Flow Through a Single Opening&lt;/li&gt;
&lt;li&gt;8. Investigating Differences Between Game Modes&lt;/li&gt;
&lt;li&gt;9. Why Identical Renderers Can Produce Different Results&lt;/li&gt;
&lt;li&gt;10. Dynamic Interior Doors and Smoke Transport Paths&lt;/li&gt;
&lt;li&gt;11. Investigating Rendering Performance&lt;/li&gt;
&lt;li&gt;12. Optimizing Opening Smoke Rendering&lt;/li&gt;
&lt;li&gt;13. Reusing Meshes Without Reducing Rendering Accuracy&lt;/li&gt;
&lt;li&gt;14. Performance Measurement Results&lt;/li&gt;
&lt;li&gt;15. Component Performance vs. Overall Game FPS&lt;/li&gt;
&lt;li&gt;16. Separating Simulation Time from Rendering Time&lt;/li&gt;
&lt;li&gt;17. CFAST and FDS for Future Smoke Visualization&lt;/li&gt;
&lt;li&gt;18. Interactive Technical Documentation&lt;/li&gt;
&lt;li&gt;19. Conclusion&lt;/li&gt;
&lt;li&gt;References&lt;/li&gt;
&lt;li&gt;About the Project&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I am an independent developer working on a firefighting and disaster response game called &lt;strong&gt;SOKYU: OPERATION RESCUE BLAZE SERIES&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In the previous development reports, I introduced how I integrated CFAST, a fire simulator developed by the National Institute of Standards and Technology (NIST), with the Unity game engine.&lt;/p&gt;

&lt;p&gt;The series currently covers the following topics:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Report&lt;/th&gt;
&lt;th&gt;Topic&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;#1&lt;/td&gt;
&lt;td&gt;Integrating NIST's fire simulator into a game&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#2&lt;/td&gt;
&lt;td&gt;Fire states, fuel consumption, and asynchronous extinguishing events&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#3&lt;/td&gt;
&lt;td&gt;Real-time smoke rendering and performance optimization&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In this third report, I will focus on how numerical fire simulation results are transformed into visible smoke inside Unity.&lt;/p&gt;

&lt;p&gt;CFAST does not generate ready-to-render three-dimensional smoke meshes or game particles.&lt;/p&gt;

&lt;p&gt;Instead, it provides numerical information describing the fire environment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Gas-layer heights&lt;/li&gt;
&lt;li&gt;Optical density&lt;/li&gt;
&lt;li&gt;Temperature&lt;/li&gt;
&lt;li&gt;Gas composition&lt;/li&gt;
&lt;li&gt;Mass flow rates&lt;/li&gt;
&lt;li&gt;Gas transport directions&lt;/li&gt;
&lt;li&gt;Opening conditions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The challenge is to convert these numerical results into an interactive visual experience while maintaining acceptable rendering performance.&lt;/p&gt;

&lt;p&gt;This requires combining scientific computing, computer graphics, geometry processing, and real-time software engineering.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Game Smoke Effects vs. Simulation-Driven Smoke
&lt;/h2&gt;

&lt;p&gt;Unity provides several technologies for creating fire and smoke effects, including particle systems, shaders, and the Visual Effect Graph.&lt;/p&gt;

&lt;p&gt;These tools allow developers to create visually convincing smoke effects.&lt;/p&gt;

&lt;p&gt;For this project, however, I wanted smoke to respond to changes in the simulated fire environment rather than relying exclusively on predefined effects.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Smoke accumulates near the ceiling.&lt;/li&gt;
&lt;li&gt;The gas-layer interface changes as the fire develops.&lt;/li&gt;
&lt;li&gt;Smoke may travel into adjacent rooms.&lt;/li&gt;
&lt;li&gt;Opening a door changes the available gas transport paths.&lt;/li&gt;
&lt;li&gt;Windows and exterior doors affect ventilation.&lt;/li&gt;
&lt;li&gt;Existing smoke does not immediately disappear when a fire stops producing heat.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The objective is to connect these visual changes to numerical simulation results.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Effect-Driven Approach&lt;/th&gt;
&lt;th&gt;CFAST-Driven Approach&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Smoke generation&lt;/td&gt;
&lt;td&gt;Configured visual effects&lt;/td&gt;
&lt;td&gt;Simulation-dependent smoke state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Smoke accumulation&lt;/td&gt;
&lt;td&gt;Effect parameters&lt;/td&gt;
&lt;td&gt;Compartment gas-layer state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Smoke density&lt;/td&gt;
&lt;td&gt;Artist-defined parameters&lt;/td&gt;
&lt;td&gt;Calculated optical density&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Smoke-layer height&lt;/td&gt;
&lt;td&gt;Predefined or animated&lt;/td&gt;
&lt;td&gt;Calculated layer interface&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Door operation&lt;/td&gt;
&lt;td&gt;Effect activation&lt;/td&gt;
&lt;td&gt;Simulation input changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Smoke transport direction&lt;/td&gt;
&lt;td&gt;Configured particle movement&lt;/td&gt;
&lt;td&gt;Calculated gas flow direction&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Residual smoke&lt;/td&gt;
&lt;td&gt;Particle lifetime&lt;/td&gt;
&lt;td&gt;Accepted simulation state&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This does not mean that traditional game effects are inferior.&lt;/p&gt;

&lt;p&gt;The difference is that the visual effects in this project are driven by the evolving state of a fire simulation.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Understanding the CFAST Two-Zone Model
&lt;/h2&gt;

&lt;p&gt;CFAST stands for &lt;strong&gt;Consolidated Fire and Smoke Transport&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is an open-source fire simulation program developed by NIST.&lt;/p&gt;

&lt;p&gt;Official website:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pages.nist.gov/cfast/" rel="noopener noreferrer"&gt;https://pages.nist.gov/cfast/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;CFAST primarily represents each compartment using two gas layers.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An upper gas layer, where hot combustion gases and smoke typically accumulate.&lt;/li&gt;
&lt;li&gt;A lower gas layer, which is generally cooler.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The temperature, composition, volume, and optical properties of these layers change as the simulation progresses.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                CEILING
    ┌──────────────────────────┐
    │                          │
    │     Upper Gas Layer      │
    │     Hot Gas and Smoke    │
    │                          │
    ├──────────────────────────┤ ← Layer Interface
    │                          │
    │     Lower Gas Layer      │
    │                          │
    │         Fire Source      │
    └──────────────────────────┘
                  FLOOR
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This model is computationally different from CFD-based simulation.&lt;/p&gt;

&lt;p&gt;CFAST does not directly calculate the detailed three-dimensional velocity field at every location inside a compartment.&lt;/p&gt;

&lt;p&gt;Instead, it calculates representative compartment and gas-layer conditions together with modeled gas transport processes.&lt;/p&gt;

&lt;p&gt;This distinction determines how the simulation results can be visualized in Unity.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Two Separate Smoke Rendering Systems
&lt;/h2&gt;

&lt;p&gt;One of the most important architectural decisions was to separate indoor smoke rendering from opening smoke rendering.&lt;/p&gt;

&lt;p&gt;These two types of smoke represent different information.&lt;/p&gt;

&lt;h3&gt;
  
  
  Indoor Smoke
&lt;/h3&gt;

&lt;p&gt;Indoor smoke represents the optical state of a compartment and its upper and lower gas layers.&lt;/p&gt;

&lt;p&gt;It is rendered using compartment-based smoke volumes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Opening Smoke
&lt;/h3&gt;

&lt;p&gt;Opening smoke represents visible gas transport through doors, windows, and other supported openings.&lt;/p&gt;

&lt;p&gt;It is rendered using particles and dynamically generated meshes.&lt;/p&gt;

&lt;p&gt;The overall architecture is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;              CFAST Native Worker
                       │
              Accepted Simulation Data
                       │
         ┌─────────────┴─────────────┐
         │                           │
  Compartment Data              Opening Data
         │                           │
  Layer Heights                 Mass Flow Rates
  Optical Density               Flow Directions
  Room Geometry                 Source Optical State
         │                           │
         ▼                           ▼
  Volumetric Smoke              Opening Smoke
      Renderer                  Particle Renderer
         │                           │
         └─────────────┬─────────────┘
                       ▼
                Unity Game View
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This separation allows the two rendering systems to use the simulation information appropriate to their respective purposes.&lt;/p&gt;

&lt;p&gt;Indoor smoke does not require every visible part of the smoke volume to be represented by an individual particle.&lt;/p&gt;

&lt;p&gt;Opening smoke, on the other hand, benefits from a directional particle-based representation.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Indoor Volumetric Smoke Rendering
&lt;/h2&gt;

&lt;p&gt;Indoor smoke is rendered using compartment geometry and the accepted gas-layer information from CFAST.&lt;/p&gt;

&lt;p&gt;The primary rendering inputs are:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Compartment geometry&lt;/td&gt;
&lt;td&gt;Defines the smoke rendering region&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lower-layer depth&lt;/td&gt;
&lt;td&gt;Determines the gas-layer interface&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Upper-layer optical density&lt;/td&gt;
&lt;td&gt;Controls upper-layer extinction&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lower-layer optical density&lt;/td&gt;
&lt;td&gt;Controls lower-layer extinction&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accepted simulation time&lt;/td&gt;
&lt;td&gt;Associates rendering with a confirmed simulation state&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  4.1 Calculating the Layer Interface
&lt;/h3&gt;

&lt;p&gt;If the compartment floor elevation is represented by $y_{floor}$ and the lower-layer depth calculated by CFAST is represented by $h_{lower}$, the interface position is:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
y_{interface}=y_{floor}+h_{lower}&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;As the simulation progresses, changes in this interface position are reflected in the Unity smoke volume.&lt;/p&gt;

&lt;p&gt;For example, a descending gas-layer interface can increase the region occupied by upper-layer smoke.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Early Fire                    Developing Fire

┌───────────────────┐        ┌───────────────────┐
│ Upper Smoke Layer │        │                   │
├───────────────────┤        │                   │
│                   │        │ Upper Smoke Layer │
│                   │        │                   │
│ Lower Gas Layer   │        ├───────────────────┤
│                   │        │ Lower Gas Layer   │
└───────────────────┘        └───────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The illustration is conceptual and does not represent measured smoke-layer heights.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.2 Preparing GPU Layer Data
&lt;/h3&gt;

&lt;p&gt;The Unity implementation converts the accepted CFAST room information into a compact data structure for rendering.&lt;/p&gt;

&lt;p&gt;The following is a simplified excerpt based on the existing implementation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;upperOD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;room&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;UpperOpticalDensityPerMetre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;lowerOD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;room&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;LowerOpticalDensityPerMetre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;interfaceHeight&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;floor&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;lowerDepth&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;layer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Vector4&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;interfaceHeight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;lowerOD&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;upperOD&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;0f&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The resulting vector contains the layer interface position and the optical density values required by the rendering system.&lt;/p&gt;

&lt;p&gt;The implementation also uses GPU buffers for compartment geometry and layer information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;material&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SetBuffer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"_GasPlanes"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;planes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;material&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SetBuffer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"_GasCells"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cells&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;material&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SetBuffer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"_GasLayers"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;layers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The three buffers serve different purposes.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Buffer&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;GasPlanes&lt;/td&gt;
&lt;td&gt;Boundary planes of the gas regions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GasCells&lt;/td&gt;
&lt;td&gt;Compartment-related rendering geometry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GasLayers&lt;/td&gt;
&lt;td&gt;Current upper-layer and lower-layer optical information&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The geometry and the evolving simulation state are represented separately.&lt;/p&gt;

&lt;p&gt;This allows the rendering system to update the gas-layer state without reconstructing the entire compartment geometry for every simulation result.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.3 Why Not Use Persistent Particles for the Entire Room?
&lt;/h3&gt;

&lt;p&gt;Representing an entire smoke-filled room using persistent particles can introduce substantial particle management and rendering costs.&lt;/p&gt;

&lt;p&gt;A compartment-based volume avoids making the existence of indoor smoke dependent on the lifetime of individual particles.&lt;/p&gt;

&lt;p&gt;The accepted CFAST layer state remains available to the renderer until a new simulation state is received.&lt;/p&gt;

&lt;p&gt;This is particularly useful for representing accumulated indoor smoke.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Optical Density and Smoke Visibility
&lt;/h2&gt;

&lt;p&gt;Optical density describes the attenuation of light as it travels through a medium.&lt;/p&gt;

&lt;p&gt;In the context of fire simulation, it provides information related to the visibility reduction caused by smoke.&lt;/p&gt;

&lt;p&gt;It is important to distinguish optical density from a simple opacity parameter.&lt;/p&gt;

&lt;p&gt;Optical density depends on the optical properties of the medium and the distance through which light travels.&lt;/p&gt;

&lt;p&gt;For an optical density per unit length $D$ and a path length $L$, an idealized decadic attenuation relationship can be expressed as:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
\frac{I}{I_0}=10^{-DL}&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;$I_0$ is the original light intensity.&lt;/li&gt;
&lt;li&gt;$I$ is the transmitted light intensity.&lt;/li&gt;
&lt;li&gt;$D$ is the optical density per unit length.&lt;/li&gt;
&lt;li&gt;$L$ is the optical path length.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An equivalent exponential extinction representation is:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
\frac{I}{I_0}=e^{-\kappa L}&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;Where:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
\kappa=D\ln(10)&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;These equations describe the general relationship between optical density and light attenuation.&lt;/p&gt;

&lt;p&gt;They are presented here to explain the underlying optical concept, not as a complete reproduction of the project's shader implementation.&lt;/p&gt;

&lt;p&gt;In Unity, smoke visibility is also affected by rendering factors such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lighting&lt;/li&gt;
&lt;li&gt;Scattering&lt;/li&gt;
&lt;li&gt;Camera position&lt;/li&gt;
&lt;li&gt;Viewing distance&lt;/li&gt;
&lt;li&gt;Occlusion&lt;/li&gt;
&lt;li&gt;Other visual effects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Therefore, two scenes containing the same optical density values may still appear different if their rendering environments differ.&lt;/p&gt;


&lt;h2&gt;
  
  
  6. Visualizing Gas Transport Through Openings
&lt;/h2&gt;

&lt;p&gt;Doors and windows create transport paths between compartments or between a compartment and the exterior environment.&lt;/p&gt;

&lt;p&gt;CFAST calculates gas transport through these openings.&lt;/p&gt;

&lt;p&gt;The opening smoke renderer uses several pieces of information from the accepted simulation results.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Simulation Input&lt;/th&gt;
&lt;th&gt;Rendering Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Signed mass flow rate&lt;/td&gt;
&lt;td&gt;Determines transport direction&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gas density&lt;/td&gt;
&lt;td&gt;Converts mass flow into volumetric flow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Native opening area&lt;/td&gt;
&lt;td&gt;Supports average velocity calculation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Source gas-layer optical density&lt;/td&gt;
&lt;td&gt;Determines the visible smoke contribution&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Opening geometry&lt;/td&gt;
&lt;td&gt;Defines the visualization region&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h3&gt;
  
  
  6.1 Converting Mass Flow into Volumetric Flow
&lt;/h3&gt;

&lt;p&gt;The volumetric flow rate is calculated using the relationship:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
\dot{V}=\frac{|\dot{m}|}{\rho}&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;$\dot{m}$ is the signed gas mass flow rate in kg/s.&lt;/li&gt;
&lt;li&gt;$\rho$ is the gas density in kg/m³.&lt;/li&gt;
&lt;li&gt;$\dot{V}$ is the volumetric flow rate in m³/s.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The sign of the mass flow rate is used to determine the transport direction.&lt;/p&gt;
&lt;h3&gt;
  
  
  6.2 Calculating Average Flow Velocity
&lt;/h3&gt;

&lt;p&gt;Given an opening area $A$, the average flow velocity can be calculated as:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
v=\frac{\dot{V}}{A}&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;The result is an average velocity associated with the modeled opening flow.&lt;/p&gt;

&lt;p&gt;It is not a detailed three-dimensional velocity field.&lt;/p&gt;

&lt;p&gt;The Unity renderer uses this information to represent directional smoke transport.&lt;/p&gt;
&lt;h3&gt;
  
  
  6.3 Smoke Transport Is Not the Same as Airflow
&lt;/h3&gt;

&lt;p&gt;Gas flow through an opening does not necessarily mean that dense smoke should be rendered.&lt;/p&gt;

&lt;p&gt;The optical state of the gas source layer must also be considered.&lt;/p&gt;

&lt;p&gt;A flow originating from a relatively clear lower gas layer may contain significantly less visible smoke than a flow originating from a smoke-filled upper layer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Signed Mass Flow
       │
       ├── Flow Direction
       │
       └── Mass Flow / Gas Density
                    │
              Volumetric Flow
                    │
              Opening Area
                    │
              Average Velocity
                    │
Source Optical Density
                    │
                    ▼
          Opening Smoke Rendering
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is how numerical transport information is connected to the visual smoke representation.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Bidirectional Flow Through a Single Opening
&lt;/h2&gt;

&lt;p&gt;An opening does not necessarily have only one gas transport direction.&lt;/p&gt;

&lt;p&gt;Depending on the fire conditions, pressure differences, and temperatures, a doorway may support simultaneous flows in different directions.&lt;/p&gt;

&lt;p&gt;For example, hot smoke may leave a compartment through the upper part of an opening while cooler air enters through the lower part.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Fire Compartment           Adjacent Compartment

┌──────────────────────┬──────────────────────┐
│                      │                      │
│ Hot Smoke  ──────────┼───────────────&amp;gt;      │
│                      │                      │
│                OPENING                      │
│                      │                      │
│            &amp;lt;─────────┼────────── Cooler Air │
│                      │                      │
└──────────────────────┴──────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The opening smoke renderer uses the direction-specific and region-specific flow information calculated by CFAST.&lt;/p&gt;

&lt;p&gt;This avoids assigning one fixed direction to every particle associated with an opening.&lt;/p&gt;

&lt;p&gt;However, the illustrated flow pattern is not guaranteed whenever a door is opened.&lt;/p&gt;

&lt;p&gt;The actual gas transport depends on the accepted simulation conditions.&lt;/p&gt;

&lt;p&gt;The objective is to visualize the calculated transport rather than impose a predefined animation.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. Investigating Differences Between Game Modes
&lt;/h2&gt;

&lt;p&gt;During development, I noticed that smoke appeared different between stages and between gameplay modes.&lt;/p&gt;

&lt;p&gt;The three relevant gameplay modes were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AIM3D&lt;/li&gt;
&lt;li&gt;AIM3D2&lt;/li&gt;
&lt;li&gt;ZERO&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The question was whether these differences originated from the simulation or the rendering implementation.&lt;/p&gt;

&lt;h3&gt;
  
  
  8.1 Investigating CFAST Optical Density
&lt;/h3&gt;

&lt;p&gt;In an early Stage02 native test, I compared the optical density of the living area and entrance hall three seconds after the simulation started.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Compartment&lt;/th&gt;
&lt;th&gt;Upper-Layer Optical Density&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;R4 — Living, dining, and kitchen area&lt;/td&gt;
&lt;td&gt;0.291650&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R5 — Entrance hall&lt;/td&gt;
&lt;td&gt;0.009422&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The entrance hall's upper-layer optical density was approximately 3.23% of the living area's value.&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
\frac{0.009422}{0.291650}\times100&lt;br&gt;
\approx3.23\%&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;The lower-layer optical density in the entrance hall was also close to zero.&lt;/p&gt;

&lt;p&gt;Gas containing smoke was moving from the living area into the entrance hall, but the calculated optical density in the entrance hall was still relatively low.&lt;/p&gt;

&lt;p&gt;This showed that the limited visible smoke in that compartment was not necessarily a rendering defect.&lt;/p&gt;

&lt;p&gt;These results were obtained before the later addition of six interior doors and their fully closed initial conditions.&lt;/p&gt;

&lt;p&gt;They should not be interpreted as measurements of the latest door configuration.&lt;/p&gt;
&lt;h3&gt;
  
  
  8.2 Comparing the Actual Unity Rendering
&lt;/h3&gt;

&lt;p&gt;A separate investigation compared the indoor smoke rendering across the three gameplay modes.&lt;/p&gt;

&lt;p&gt;The comparison controlled the following conditions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CFAST smoke-layer data&lt;/li&gt;
&lt;li&gt;Camera position&lt;/li&gt;
&lt;li&gt;Camera orientation&lt;/li&gt;
&lt;li&gt;Field of view: 60 degrees&lt;/li&gt;
&lt;li&gt;Stage geometry&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A total of 150 images were collected from nine scene executions.&lt;/p&gt;

&lt;p&gt;When the same smoke-layer data and camera conditions were used within the same stage, the indoor smoke images matched at the pixel level across the three modes.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Validation Item&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AIM3D indoor smoke&lt;/td&gt;
&lt;td&gt;Shared rendering implementation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AIM3D2 indoor smoke&lt;/td&gt;
&lt;td&gt;Shared rendering implementation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ZERO indoor smoke&lt;/td&gt;
&lt;td&gt;Shared rendering implementation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Matched-condition indoor smoke images&lt;/td&gt;
&lt;td&gt;Pixel-level match&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This established that, within the tested conditions, separate smoke rendering implementations were not required for each mode.&lt;/p&gt;


&lt;h2&gt;
  
  
  9. Why Identical Renderers Can Produce Different Results
&lt;/h2&gt;

&lt;p&gt;Even when multiple gameplay modes use the same rendering implementation, their simulation inputs may differ.&lt;/p&gt;

&lt;p&gt;In the earlier Stage02 configuration, the entrance door was open in the AIM modes and closed in ZERO.&lt;/p&gt;

&lt;p&gt;This produced different CFAST gas transport conditions.&lt;/p&gt;

&lt;p&gt;The following values were measured at a simulation time of three seconds.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Gameplay Mode&lt;/th&gt;
&lt;th&gt;Smoke-Bearing Upper Gas Flow from LDK to Hall&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AIM3D&lt;/td&gt;
&lt;td&gt;0.003881 kg/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AIM3D2&lt;/td&gt;
&lt;td&gt;0.003881 kg/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ZERO&lt;/td&gt;
&lt;td&gt;0.003678 kg/s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The difference in the opening configuration changed the simulation results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Different Opening Conditions
              ↓
Different CFAST Inputs
              ↓
Different Gas Transport
              ↓
Different Compartment Conditions
              ↓
Different Smoke Visualization
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is an important debugging principle.&lt;/p&gt;

&lt;p&gt;A visible difference is not automatically evidence of a rendering bug.&lt;/p&gt;

&lt;p&gt;The numerical input to the renderer must also be compared.&lt;/p&gt;

&lt;p&gt;Other visual factors, including lighting, fire effects, and occlusion, can contribute to differences in the final scene appearance.&lt;/p&gt;

&lt;p&gt;The investigation did not independently quantify every one of these contributions.&lt;/p&gt;




&lt;h2&gt;
  
  
  10. Dynamic Interior Doors and Smoke Transport Paths
&lt;/h2&gt;

&lt;p&gt;Six interactive interior doors were added to Stage02.&lt;/p&gt;

&lt;p&gt;All six doors start in the fully closed state.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Opening&lt;/th&gt;
&lt;th&gt;Connected Compartments&lt;/th&gt;
&lt;th&gt;Opening Direction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;V1&lt;/td&gt;
&lt;td&gt;Entrance hall and toilet&lt;/td&gt;
&lt;td&gt;Toward the entrance hall&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;V3&lt;/td&gt;
&lt;td&gt;Bathroom and washroom&lt;/td&gt;
&lt;td&gt;Toward the washroom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;V4&lt;/td&gt;
&lt;td&gt;Living area and left bedroom&lt;/td&gt;
&lt;td&gt;Toward the living area&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;V5&lt;/td&gt;
&lt;td&gt;Entrance hall and washroom&lt;/td&gt;
&lt;td&gt;Toward the washroom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;V6&lt;/td&gt;
&lt;td&gt;Entrance hall and living area&lt;/td&gt;
&lt;td&gt;Toward the living area&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;V7&lt;/td&gt;
&lt;td&gt;Living area and right bedroom&lt;/td&gt;
&lt;td&gt;Toward the living area&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The former opening V2 remains permanently closed.&lt;/p&gt;

&lt;p&gt;V7 is the designated entrance to the right bedroom.&lt;/p&gt;

&lt;h3&gt;
  
  
  Closing an Opening
&lt;/h3&gt;

&lt;p&gt;When V6 is closed, direct gas transport through V6 between the living area and entrance hall is prevented by the model configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Opening an Opening
&lt;/h3&gt;

&lt;p&gt;When V6 is opened, a potential gas transport path becomes available.&lt;/p&gt;

&lt;p&gt;The actual flow direction and flow rate are determined by CFAST.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PLAYER OPERATES DOOR
          │
          ▼
UNITY DOOR STATE
          │
          ▼
CFAST OPENING INPUT
          │
          ▼
GAS TRANSPORT CALCULATION
          │
          ▼
ACCEPTED SIMULATION RESULT
          │
     ┌────┴────┐
     ▼         ▼
 Indoor      Opening
 Smoke       Smoke
 Update      Update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The player is changing a simulation input, rather than simply activating a smoke effect.&lt;/p&gt;

&lt;p&gt;Closing a door also does not imply that all smoke already present inside the adjacent compartments should immediately disappear.&lt;/p&gt;

&lt;p&gt;Existing indoor smoke remains associated with the accepted compartment simulation state.&lt;/p&gt;




&lt;h2&gt;
  
  
  11. Investigating Rendering Performance
&lt;/h2&gt;

&lt;p&gt;Real-time smoke visualization introduces both CPU and GPU workloads.&lt;/p&gt;

&lt;p&gt;During actual Stage02 gameplay, I observed differences in lag symptoms depending on whether the entrance door was open or closed.&lt;/p&gt;

&lt;p&gt;Several possible contributors were identified.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Processing Area&lt;/th&gt;
&lt;th&gt;Potential Workload&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CFAST&lt;/td&gt;
&lt;td&gt;Gas transport calculations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CPU&lt;/td&gt;
&lt;td&gt;Particle generation and simulation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CPU&lt;/td&gt;
&lt;td&gt;Particle data retrieval&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CPU&lt;/td&gt;
&lt;td&gt;Vertex generation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CPU&lt;/td&gt;
&lt;td&gt;Mesh updates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CPU/GPU&lt;/td&gt;
&lt;td&gt;Mesh data transfer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GPU&lt;/td&gt;
&lt;td&gt;Transparent particle overdraw&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GPU&lt;/td&gt;
&lt;td&gt;Volumetric smoke rendering&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GPU&lt;/td&gt;
&lt;td&gt;Additional visible geometry&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The number of open transport paths may influence the rendering workload.&lt;/p&gt;

&lt;p&gt;However, the observation alone does not establish whether the primary bottleneck is the number of openings, the number of particles, GPU overdraw, or the CFAST calculation itself.&lt;/p&gt;

&lt;p&gt;I therefore started with a smaller optimization: eliminating unnecessary CPU work in the opening smoke renderer.&lt;/p&gt;

&lt;p&gt;The CFAST calculation method and simulation update frequency were preserved.&lt;/p&gt;




&lt;h2&gt;
  
  
  12. Optimizing Opening Smoke Rendering
&lt;/h2&gt;

&lt;p&gt;The original opening smoke rendering path could perform particle retrieval and mesh writing even when there were no particles to render.&lt;/p&gt;

&lt;p&gt;This created unnecessary CPU work.&lt;/p&gt;

&lt;p&gt;The revised implementation distinguishes between three conditions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;No particles are available.&lt;/li&gt;
&lt;li&gt;The rendering input is identical to the previous frame's input.&lt;/li&gt;
&lt;li&gt;The rendering input has changed.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  12.1 No Particles Available
&lt;/h3&gt;

&lt;p&gt;When an opening contains no particles to render, unnecessary operations are skipped.&lt;/p&gt;

&lt;p&gt;These include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Particle data retrieval&lt;/li&gt;
&lt;li&gt;Unnecessary vertex generation&lt;/li&gt;
&lt;li&gt;Unnecessary mesh transfer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, appearance and boundary buffer updates are preserved.&lt;/p&gt;

&lt;p&gt;The optimization must not prevent the renderer from updating the opening geometry or other required visual state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BEFORE OPTIMIZATION

Particle Retrieval
        ↓
Vertex Generation
        ↓
Mesh Writing
        ↓
Appearance and Boundary Updates


AFTER OPTIMIZATION — EMPTY OPENING

Check Particle Count
        ↓
No Particles
        ↓
Skip Unnecessary Particle and Mesh Operations
        ↓
Preserve Appearance and Boundary Updates
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  12.2 Zero Gas Flow Does Not Mean Zero Existing Particles
&lt;/h3&gt;

&lt;p&gt;A gas flow rate of zero does not automatically mean that every particle associated with an opening has disappeared.&lt;/p&gt;

&lt;p&gt;Existing particles may still require visualization.&lt;/p&gt;

&lt;p&gt;The optimization therefore checks the actual particle state rather than using zero gas flow as an unconditional reason to disable rendering.&lt;/p&gt;

&lt;p&gt;This preserves the existing behavior when the opening condition changes.&lt;/p&gt;




&lt;h2&gt;
  
  
  13. Reusing Meshes Without Reducing Rendering Accuracy
&lt;/h2&gt;

&lt;p&gt;When particles remain present, the renderer determines whether the rendering inputs have changed.&lt;/p&gt;

&lt;p&gt;The comparison includes information such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Particle position&lt;/li&gt;
&lt;li&gt;Particle size&lt;/li&gt;
&lt;li&gt;Particle rotation&lt;/li&gt;
&lt;li&gt;Particle opacity or optical appearance&lt;/li&gt;
&lt;li&gt;Relevant transformation matrices&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the rendering inputs are exactly identical, the previously generated mesh can be reused.&lt;/p&gt;

&lt;p&gt;If the inputs change, the mesh is updated.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             Opening Smoke Rendering
                         │
                  Particles Present?
                    │          │
                   No         Yes
                    │          │
                    ▼          ▼
               Skip Work    Compare Input
                               │
                       ┌───────┴───────┐
                       │               │
                   Identical        Changed
                       │               │
                       ▼               ▼
                  Reuse Mesh       Update Mesh
                       │               │
                       └───────┬───────┘
                               ▼
                    Appearance and Boundary
                           Updates
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example Frame Sequence
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Frame&lt;/th&gt;
&lt;th&gt;Rendering Input&lt;/th&gt;
&lt;th&gt;Mesh Operation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Frame 1&lt;/td&gt;
&lt;td&gt;Initial input&lt;/td&gt;
&lt;td&gt;Generate mesh&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Frame 2&lt;/td&gt;
&lt;td&gt;Identical&lt;/td&gt;
&lt;td&gt;Reuse mesh&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Frame 3&lt;/td&gt;
&lt;td&gt;Identical&lt;/td&gt;
&lt;td&gt;Reuse mesh&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Frame 4&lt;/td&gt;
&lt;td&gt;Changed&lt;/td&gt;
&lt;td&gt;Update mesh&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Frame 5&lt;/td&gt;
&lt;td&gt;Identical to Frame 4&lt;/td&gt;
&lt;td&gt;Reuse mesh&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This is an explanatory example, not a recorded rendering trace.&lt;/p&gt;

&lt;p&gt;No fixed mesh refresh interval was introduced.&lt;/p&gt;

&lt;p&gt;No arbitrary tolerance threshold was added to classify different particle positions as identical.&lt;/p&gt;

&lt;p&gt;The objective was to remove redundant processing without deliberately reducing rendering quality.&lt;/p&gt;




&lt;h2&gt;
  
  
  14. Performance Measurement Results
&lt;/h2&gt;

&lt;p&gt;The opening smoke optimization was evaluated using the Stage02 ZERO scene in the Unity Editor.&lt;/p&gt;

&lt;p&gt;The accepted CFAST state, camera conditions, and graphics settings were controlled during the comparison.&lt;/p&gt;

&lt;h3&gt;
  
  
  14.1 Initial Optimization Candidate
&lt;/h3&gt;

&lt;p&gt;The initial candidate produced the following median CPU processing times.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Condition&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;Initial Candidate&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;No particles&lt;/td&gt;
&lt;td&gt;0.0878 ms&lt;/td&gt;
&lt;td&gt;0.0063 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Identical rendering input&lt;/td&gt;
&lt;td&gt;0.2843 ms&lt;/td&gt;
&lt;td&gt;0.0927 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Moving particles&lt;/td&gt;
&lt;td&gt;0.2752 ms&lt;/td&gt;
&lt;td&gt;0.2528 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;However, independent review identified a problem with the empty-particle optimization.&lt;/p&gt;

&lt;p&gt;The early-return path also skipped required appearance and boundary buffer updates.&lt;/p&gt;

&lt;p&gt;As a result, the initial performance improvement could not be accepted as the final result.&lt;/p&gt;

&lt;p&gt;The implementation was revised to preserve these required updates.&lt;/p&gt;

&lt;p&gt;This is an example of why performance improvements must be evaluated together with behavioral correctness.&lt;/p&gt;

&lt;h3&gt;
  
  
  14.2 Final Measurement After Review Corrections
&lt;/h3&gt;

&lt;p&gt;The revised empty-opening implementation was measured again.&lt;/p&gt;

&lt;p&gt;The test covered 13 openings containing no smoke particles.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measurement&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Median CPU processing time&lt;/td&gt;
&lt;td&gt;0.09370 ms&lt;/td&gt;
&lt;td&gt;0.04965 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Particle retrieval calls per frame&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mesh write calls per frame&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The CPU processing time reduction was:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
\frac{0.09370-0.04965}{0.09370}&lt;br&gt;
\times100&lt;br&gt;
\approx47.01\%&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approximately 47% less CPU processing time for the measured operation.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Opening Smoke CPU Processing Time

Before  |████████████████████| 0.09370 ms

After   |███████████         | 0.04965 ms


CPU Time Reduction: Approximately 47%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result applies specifically to the measured rendering operation involving 13 empty openings.&lt;/p&gt;

&lt;p&gt;It is not a measurement of overall game FPS.&lt;/p&gt;

&lt;p&gt;The initially measured values for identical inputs and moving particles should also be distinguished from the final empty-opening measurement.&lt;/p&gt;




&lt;h2&gt;
  
  
  15. Component Performance vs. Overall Game FPS
&lt;/h2&gt;

&lt;p&gt;A percentage reduction in the processing time of one component does not necessarily translate into the same percentage improvement in overall game performance.&lt;/p&gt;

&lt;p&gt;The absolute time saved in the final empty-opening test was:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
0.09370-0.04965=0.04405\text{ ms}&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;For comparison, a game running at 60 FPS has a nominal frame time of:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
\frac{1000}{60}\approx16.67\text{ ms}&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;The optimization eliminates unnecessary work, but the absolute time saved is relatively small compared with the total frame budget.&lt;/p&gt;

&lt;p&gt;If GPU rendering is the primary bottleneck, reducing CPU processing time may have little effect on FPS.&lt;/p&gt;

&lt;p&gt;Similarly, a CFAST simulation stall cannot be resolved simply by reducing mesh generation overhead.&lt;/p&gt;

&lt;p&gt;These are separate performance problems.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Optimization Area&lt;/th&gt;
&lt;th&gt;Intended Improvement&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Native simulation&lt;/td&gt;
&lt;td&gt;Numerical calculation performance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inter-process communication&lt;/td&gt;
&lt;td&gt;Simulation response latency&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CPU rendering preparation&lt;/td&gt;
&lt;td&gt;Particle and mesh processing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GPU rendering&lt;/td&gt;
&lt;td&gt;Smoke shading and transparency&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Game frame processing&lt;/td&gt;
&lt;td&gt;Overall responsiveness&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The current optimization demonstrates an improvement in CPU processing for the measured component.&lt;/p&gt;

&lt;p&gt;An overall FPS improvement in the production standalone Player has not yet been established.&lt;/p&gt;


&lt;h2&gt;
  
  
  16. Separating Simulation Time from Rendering Time
&lt;/h2&gt;

&lt;p&gt;The project uses a stateful CFAST worker that advances the fire simulation through incremental requests.&lt;/p&gt;

&lt;p&gt;Unity renders the currently accepted simulation state.&lt;/p&gt;

&lt;p&gt;The simulation update frequency and rendering frame rate do not need to be identical.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CFAST SIMULATION

STEP 1 ──────── STEP 2 ──────── STEP 3
   │               │               │
   ▼               ▼               ▼
State A         State B         State C


UNITY RENDERING

Frame 1  Frame 2  Frame 3  Frame 4  Frame 5
    │        │        │        │        │
 State A  State A  State B  State B  State C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This illustration shows the conceptual relationship between accepted simulation updates and rendering frames.&lt;/p&gt;

&lt;p&gt;It does not represent the actual timing of a recorded gameplay session.&lt;/p&gt;

&lt;h3&gt;
  
  
  Accepted Simulation State
&lt;/h3&gt;

&lt;p&gt;Indoor smoke rendering uses the accepted compartment state.&lt;/p&gt;

&lt;p&gt;The opening smoke renderer uses the corresponding accepted transport information.&lt;/p&gt;

&lt;p&gt;The renderer does not need to reconstruct the fire simulation independently for every graphics frame.&lt;/p&gt;

&lt;p&gt;This separation has several advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Numerical simulation can run outside the Unity main thread.&lt;/li&gt;
&lt;li&gt;Rendering can continue using accepted simulation information.&lt;/li&gt;
&lt;li&gt;Static compartment geometry can be maintained separately from dynamic smoke-layer data.&lt;/li&gt;
&lt;li&gt;Mesh updates can be avoided when the relevant rendering input has not changed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, if the native worker stops returning new results, Unity cannot continue updating the physical smoke state with new simulation information.&lt;/p&gt;

&lt;p&gt;This is why the numerical stability issues discussed in Development Report #1 are also relevant to graphics rendering.&lt;/p&gt;

&lt;p&gt;Simulation stability and rendering efficiency are different aspects of the same interactive system.&lt;/p&gt;




&lt;h2&gt;
  
  
  17. CFAST and FDS for Future Smoke Visualization
&lt;/h2&gt;

&lt;p&gt;CFAST provides compartment-level gas-layer information and modeled gas transport.&lt;/p&gt;

&lt;p&gt;This is useful for interactive simulation, but it has limitations when representing detailed local smoke motion.&lt;/p&gt;

&lt;p&gt;For example, CFAST does not directly provide the spatial velocity fields required to reproduce:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Small-scale smoke vortices&lt;/li&gt;
&lt;li&gt;Detailed flow around furniture&lt;/li&gt;
&lt;li&gt;Local turbulence near obstacles&lt;/li&gt;
&lt;li&gt;Fine spatial variations in smoke concentration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another NIST fire simulation program, &lt;strong&gt;FDS (Fire Dynamics Simulator)&lt;/strong&gt;, uses computational fluid dynamics to calculate spatially distributed fire-driven flows.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Characteristic&lt;/th&gt;
&lt;th&gt;CFAST&lt;/th&gt;
&lt;th&gt;FDS&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Simulation model&lt;/td&gt;
&lt;td&gt;Zone model&lt;/td&gt;
&lt;td&gt;CFD&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Spatial representation&lt;/td&gt;
&lt;td&gt;Compartments and gas layers&lt;/td&gt;
&lt;td&gt;Three-dimensional computational mesh&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Smoke information&lt;/td&gt;
&lt;td&gt;Representative layer conditions&lt;/td&gt;
&lt;td&gt;Spatial distribution&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gas velocity&lt;/td&gt;
&lt;td&gt;Modeled transport processes&lt;/td&gt;
&lt;td&gt;Spatial velocity field&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Computational workload&lt;/td&gt;
&lt;td&gt;Generally lower&lt;/td&gt;
&lt;td&gt;Generally higher&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Current project role&lt;/td&gt;
&lt;td&gt;Incremental gameplay simulation&lt;/td&gt;
&lt;td&gt;Detailed fire analysis and visualization development&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;I am exploring how these two simulation models can complement each other in game development.&lt;/p&gt;

&lt;p&gt;A potential architecture is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CFAST                         FDS
  │                            │
Compartment State         Detailed Fire Analysis
  │                            │
Smoke Layers              Spatial Smoke Distribution
Opening Flows             Local Flow Structures
  │                            │
  └─────────────┬──────────────┘
                ▼
           Unity Engine
                │
       Interactive Visualization
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CFAST-based smoke rendering described in this article is already implemented.&lt;/p&gt;

&lt;p&gt;The broader use of FDS spatial data remains a separate development and investigation topic.&lt;/p&gt;

&lt;p&gt;A complete real-time coupling of FDS velocity fields and CFAST compartment states is not claimed here.&lt;/p&gt;

&lt;p&gt;Future reports will discuss FDS, Smokeview, and the different roles of zone models and CFD in more detail.&lt;/p&gt;




&lt;h2&gt;
  
  
  18. Interactive Technical Documentation
&lt;/h2&gt;

&lt;p&gt;I have also prepared a technical guide on the project website.&lt;/p&gt;

&lt;p&gt;The guide uses diagrams, animations, and interactive visual explanations to introduce the CFAST and Unity integration.&lt;/p&gt;

&lt;h3&gt;
  
  
  CFAST × Unity Technical Guide
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html" rel="noopener noreferrer"&gt;Explore the CFAST and Unity Fire Simulation Guide&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Stage02 Technical Validation
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html#stage02-validation" rel="noopener noreferrer"&gt;Stage02 — Numerical Stability, Smoke Rendering, and Opening Control&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The technical documentation covers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CFAST's two-zone model&lt;/li&gt;
&lt;li&gt;Compartment-based smoke visualization&lt;/li&gt;
&lt;li&gt;Smoke transport through openings&lt;/li&gt;
&lt;li&gt;Numerical solver instability&lt;/li&gt;
&lt;li&gt;Horizontal vent closure&lt;/li&gt;
&lt;li&gt;Building model corrections&lt;/li&gt;
&lt;li&gt;Opening smoke rendering optimization&lt;/li&gt;
&lt;li&gt;Interactive interior doors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The website is primarily presented in Japanese, with visual diagrams and animations explaining the technical concepts.&lt;/p&gt;

&lt;p&gt;Readers interested in simulation-driven game development, scientific computing, and real-time graphics are welcome to explore the project.&lt;/p&gt;




&lt;h2&gt;
  
  
  19. Conclusion
&lt;/h2&gt;

&lt;p&gt;In this development report, I introduced how numerical fire simulation results are transformed into real-time smoke visualization inside Unity.&lt;/p&gt;

&lt;p&gt;The main architectural decisions include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Separating indoor volumetric smoke from opening smoke rendering.&lt;/li&gt;
&lt;li&gt;Using CFAST gas-layer heights and optical density for compartment visualization.&lt;/li&gt;
&lt;li&gt;Using signed mass flow rates and gas density for opening smoke visualization.&lt;/li&gt;
&lt;li&gt;Connecting door and window operations to simulation input conditions.&lt;/li&gt;
&lt;li&gt;Distinguishing numerical simulation differences from rendering differences.&lt;/li&gt;
&lt;li&gt;Reusing meshes when the rendering input is unchanged.&lt;/li&gt;
&lt;li&gt;Eliminating unnecessary work for openings containing no smoke particles.&lt;/li&gt;
&lt;li&gt;Separating component-level performance measurements from overall game FPS.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the most important lessons from this project is that scientific simulation and computer graphics solve different problems.&lt;/p&gt;

&lt;p&gt;CFAST calculates the evolving fire environment using its physical and numerical models.&lt;/p&gt;

&lt;p&gt;Unity transforms the accepted numerical information into an interactive visual experience.&lt;/p&gt;

&lt;p&gt;Connecting the two requires careful consideration of data representation, numerical stability, rendering architecture, and computational performance.&lt;/p&gt;

&lt;p&gt;The objective is not simply to make smoke look more realistic.&lt;/p&gt;

&lt;p&gt;It is to create a game environment in which smoke changes in response to simulated fire conditions and player interactions.&lt;/p&gt;

&lt;p&gt;In the next development report, I will examine the underlying software architecture in greater detail:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Building a Stateful CFAST Worker in Fortran and Connecting It to Unity Through Inter-Process Communication.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That report will focus on the native calculation loop, DASSL state retention, communication protocols, asynchronous C# processing, and simulation result validation.&lt;/p&gt;

&lt;p&gt;This project is being developed as a game. It does not claim validated accuracy for real-world fire prediction or certified effectiveness as a professional firefighting training system.&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://pages.nist.gov/cfast/" rel="noopener noreferrer"&gt;NIST CFAST Official Website&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/firemodels/cfast" rel="noopener noreferrer"&gt;CFAST Official GitHub Repository&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://doi.org/10.6028/NIST.TN.1889v1" rel="noopener noreferrer"&gt;CFAST Version 7 Technical Reference Guide&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/firemodels/cfast/tree/b43e74e0f43c704582c5782f5446597ce729a07f" rel="noopener noreferrer"&gt;CFAST 7.7.7 — Development Baseline Source Code&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://pages.nist.gov/fds/" rel="noopener noreferrer"&gt;NIST Fire Dynamics Simulator and Smokeview&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  About the Project
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SOKYU: OPERATION RESCUE BLAZE SERIES&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An independently developed firefighting and disaster response game combining:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fire simulation&lt;/li&gt;
&lt;li&gt;Scientific computing&lt;/li&gt;
&lt;li&gt;Unity game development&lt;/li&gt;
&lt;li&gt;Real-time computer graphics&lt;/li&gt;
&lt;li&gt;Embedded systems&lt;/li&gt;
&lt;li&gt;Robotics&lt;/li&gt;
&lt;li&gt;Artificial intelligence&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Developed by &lt;strong&gt;Motomachi Digital Making Lab&lt;/strong&gt;, Yokohama, Japan.&lt;/p&gt;

&lt;h3&gt;
  
  
  Project Technical Website
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html" rel="noopener noreferrer"&gt;https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Stage02 Technical Validation
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html#stage02-validation" rel="noopener noreferrer"&gt;https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html#stage02-validation&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;CFAST × Unity Development Report #3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;November 26, 2026&lt;/p&gt;

</description>
      <category>cfast</category>
      <category>nist</category>
      <category>unity3d</category>
    </item>
    <item>
      <title>CFAST Unity Dev Report #1: Integrating NIST's Fire Simulator into a Game — Real-Time Smoke Rendering and Numerical Stability</title>
      <dc:creator>Hidenori Ishii</dc:creator>
      <pubDate>Thu, 26 Nov 2026 13:30:09 +0000</pubDate>
      <link>https://dev.to/47_robin_ebe9e47eb349d767/cfast-unity-dev-report-1-integrating-nists-fire-simulator-into-a-game-real-time-smoke-4j8a</link>
      <guid>https://dev.to/47_robin_ebe9e47eb349d767/cfast-unity-dev-report-1-integrating-nists-fire-simulator-into-a-game-real-time-smoke-4j8a</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;1. What Is CFAST?&lt;/li&gt;
&lt;li&gt;2. The Game Project&lt;/li&gt;
&lt;li&gt;3. Integrating CFAST with Unity&lt;/li&gt;
&lt;li&gt;4. Visualizing CFAST Results in Unity&lt;/li&gt;
&lt;li&gt;5. A Numerical Stability Problem in Stage02&lt;/li&gt;
&lt;li&gt;6. Investigating Horizontal Vents and Numerical Instability&lt;/li&gt;
&lt;li&gt;7. Fixing the Building Model Instead of the Solver&lt;/li&gt;
&lt;li&gt;8. Validation Results&lt;/li&gt;
&lt;li&gt;9. Optimizing Smoke Rendering Performance&lt;/li&gt;
&lt;li&gt;10. Dynamic Interior Doors and Smoke Transport&lt;/li&gt;
&lt;li&gt;11. AI-Assisted Development and Independent Code Review&lt;/li&gt;
&lt;li&gt;12. Interactive Technical Documentation&lt;/li&gt;
&lt;li&gt;13. What I Learned from This Project&lt;/li&gt;
&lt;li&gt;14. Future Development&lt;/li&gt;
&lt;li&gt;References&lt;/li&gt;
&lt;li&gt;About the Project&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;I am an independent developer working on a firefighting and disaster response game called &lt;strong&gt;SOKYU: OPERATION RESCUE BLAZE SERIES&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The project combines several technical disciplines, including game development, embedded systems, robotics, artificial intelligence, and fire simulation.&lt;/p&gt;

&lt;p&gt;In this development report, I would like to introduce how I integrated &lt;strong&gt;CFAST&lt;/strong&gt;, a fire simulator developed by the National Institute of Standards and Technology (NIST), with the Unity game engine.&lt;/p&gt;

&lt;p&gt;In many video games, fire and smoke are represented using particle systems, shaders, and other visual effects.&lt;/p&gt;

&lt;p&gt;For this project, however, I wanted to explore a different approach.&lt;/p&gt;

&lt;p&gt;Rather than simply creating visually convincing fire and smoke effects, I wanted to calculate the underlying fire conditions and visualize the results inside Unity.&lt;/p&gt;

&lt;p&gt;These conditions include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Smoke accumulation inside rooms&lt;/li&gt;
&lt;li&gt;Changes in smoke layer height&lt;/li&gt;
&lt;li&gt;Temperature changes&lt;/li&gt;
&lt;li&gt;Oxygen concentration&lt;/li&gt;
&lt;li&gt;Gas transport between compartments&lt;/li&gt;
&lt;li&gt;Smoke exhaust and air intake through doors and windows&lt;/li&gt;
&lt;li&gt;Changes in combustion conditions caused by player interactions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is to create an interactive game environment in which fire and smoke respond to changes in the simulated physical conditions.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. What Is CFAST?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;CFAST (Consolidated Fire and Smoke Transport)&lt;/strong&gt; is an open-source fire simulation program developed by NIST.&lt;/p&gt;

&lt;p&gt;Official website:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pages.nist.gov/cfast/" rel="noopener noreferrer"&gt;https://pages.nist.gov/cfast/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;CFAST calculates the evolution of fire-generated smoke, gases, and temperatures in buildings containing multiple compartments.&lt;/p&gt;

&lt;p&gt;It primarily uses a two-zone model, dividing each compartment into two gas layers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Upper layer:&lt;/strong&gt; A layer in which hot gases and smoke typically accumulate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lower layer:&lt;/strong&gt; A relatively cooler gas layer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a fire develops, the temperature, gas composition, optical density, and thickness of these layers change.&lt;/p&gt;

&lt;p&gt;CFAST also calculates gas transport through openings such as doors, windows, and horizontal vents.&lt;/p&gt;

&lt;p&gt;Compared with computational fluid dynamics (CFD) simulators such as FDS, CFAST does not directly resolve detailed three-dimensional flow fields throughout a room.&lt;/p&gt;

&lt;p&gt;Instead, it represents fire conditions at the compartment and gas-layer levels.&lt;/p&gt;

&lt;p&gt;This relatively lightweight computational model makes CFAST an interesting candidate for integration with an interactive game engine.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. The Game Project
&lt;/h2&gt;

&lt;p&gt;SOKYU: OPERATION RESCUE BLAZE SERIES is an independently developed game project focused on firefighting and disaster response.&lt;/p&gt;

&lt;p&gt;For the indoor firefighting experience, I am currently working with two residential environments:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage&lt;/th&gt;
&lt;th&gt;Building Layout&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Stage01&lt;/td&gt;
&lt;td&gt;One-bedroom apartment with a living, dining, and kitchen area (1LDK)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stage02&lt;/td&gt;
&lt;td&gt;Two-bedroom apartment with a living, dining, and kitchen area (2LDK)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Players take on the role of firefighters and perform activities such as entering buildings, operating firefighting equipment, opening doors, and extinguishing fires.&lt;/p&gt;

&lt;p&gt;These actions can change the conditions inside the building.&lt;/p&gt;

&lt;p&gt;For example, opening a door changes the available gas transport paths. Applying water to a fire changes its gameplay state and the heat release input sent to CFAST.&lt;/p&gt;

&lt;p&gt;The challenge is to connect these interactive gameplay events to a scientific simulation.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Integrating CFAST with Unity
&lt;/h2&gt;

&lt;p&gt;A conventional fire simulation workflow generally looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Building Model
    ↓
Fire and Ventilation Conditions
    ↓
Fire Simulation
    ↓
Simulation Results
    ↓
Analysis and Visualization
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The simulation conditions are defined before execution.&lt;/p&gt;

&lt;p&gt;A game, however, cannot determine every player action in advance.&lt;/p&gt;

&lt;p&gt;Players may:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open or close a door.&lt;/li&gt;
&lt;li&gt;Open a window.&lt;/li&gt;
&lt;li&gt;Apply water to a fire.&lt;/li&gt;
&lt;li&gt;Extinguish a fire.&lt;/li&gt;
&lt;li&gt;Change the ventilation conditions inside the building.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The simulation therefore needs to respond to changing input conditions during gameplay.&lt;/p&gt;

&lt;p&gt;To address this requirement, I developed a &lt;strong&gt;stateful derivative of CFAST&lt;/strong&gt; that communicates with Unity and advances the simulation incrementally.&lt;/p&gt;

&lt;h3&gt;
  
  
  System Architecture
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────┐
│              Unity              │
│                                 │
│  Player Input                   │
│  Fire State                     │
│  Door and Window State          │
│  Game Logic                     │
└───────────────┬─────────────────┘
                │
                │ STEP Request
                │ Fire and Opening Conditions
                ▼
┌─────────────────────────────────┐
│       CFAST Native Worker       │
│                                 │
│  Stateful Simulation            │
│  DASSL Numerical Solver         │
│  Compartment Gas Layers         │
│  Combustion and Gas Transport   │
└───────────────┬─────────────────┘
                │
                │ Simulation Results
                ▼
┌─────────────────────────────────┐
│        Unity Visualization      │
│                                 │
│  Fire Rendering                 │
│  Indoor Smoke Volume            │
│  Opening Smoke Particles        │
└─────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unity sends a request containing updated simulation conditions and a target simulation time.&lt;/p&gt;

&lt;p&gt;The CFAST worker advances the simulation to that time and returns the results.&lt;/p&gt;

&lt;p&gt;Unity then validates the received data and updates the fire and smoke visualization.&lt;/p&gt;

&lt;p&gt;This process is repeated throughout gameplay.&lt;/p&gt;

&lt;p&gt;The important point is that &lt;strong&gt;CFAST preserves its internal simulation state between requests&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It does not restart the entire simulation whenever the player opens a door or changes a fire condition.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Visualizing CFAST Results in Unity
&lt;/h2&gt;

&lt;p&gt;CFAST does not provide ready-to-render smoke particles or three-dimensional smoke meshes.&lt;/p&gt;

&lt;p&gt;Instead, it provides numerical information describing the state of the fire environment.&lt;/p&gt;

&lt;p&gt;I divide the smoke visualization into two separate rendering systems.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.1 Indoor Volumetric Smoke
&lt;/h3&gt;

&lt;p&gt;Indoor smoke is rendered using compartment geometry and the gas-layer information calculated by CFAST.&lt;/p&gt;

&lt;p&gt;The main inputs include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Upper-layer optical density&lt;/li&gt;
&lt;li&gt;Lower-layer optical density&lt;/li&gt;
&lt;li&gt;Gas-layer interface height&lt;/li&gt;
&lt;li&gt;Compartment geometry&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The upper and lower layers are visualized according to their calculated optical conditions.&lt;/p&gt;

&lt;p&gt;As smoke accumulates and the interface moves downward, Unity updates the visible smoke volume.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;          Ceiling
    ┌─────────────────────┐
    │                     │
    │  Upper Smoke Layer  │
    │                     │
    ├─────────────────────┤ ← Layer Interface
    │                     │
    │  Lower Gas Layer    │
    │                     │
    └─────────────────────┘
            Floor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach makes it possible to represent smoke accumulation without relying entirely on the lifetime of individual smoke particles.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.2 Smoke Transport Through Openings
&lt;/h3&gt;

&lt;p&gt;Smoke moving through doors and windows is rendered separately.&lt;/p&gt;

&lt;p&gt;The rendering system uses information such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Gas mass flow rate&lt;/li&gt;
&lt;li&gt;Flow direction&lt;/li&gt;
&lt;li&gt;Gas density&lt;/li&gt;
&lt;li&gt;Opening area&lt;/li&gt;
&lt;li&gt;Optical conditions of the source gas layer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The volumetric flow rate can be derived from mass flow rate and gas density:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Volumetric Flow Rate = |Mass Flow Rate| / Gas Density
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An average flow velocity can then be calculated using the relevant opening area:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Average Flow Velocity = Volumetric Flow Rate / Opening Area
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These values are used to drive the visualization of smoke moving through openings.&lt;/p&gt;

&lt;p&gt;The resulting architecture is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CFAST Simulation Results
          │
          ├── Compartment Layer Data
          │          │
          │          └── Volumetric Smoke Rendering
          │
          └── Opening Flow Data
                     │
                     └── Particle and Mesh Rendering
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CFAST is not calculating the position and velocity of every individual smoke particle.&lt;/p&gt;

&lt;p&gt;The particles in Unity are a visualization driven by compartment-level and opening-level simulation results.&lt;/p&gt;

&lt;p&gt;This distinction is important when using a zone model as the basis for real-time graphics.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. A Numerical Stability Problem in Stage02
&lt;/h2&gt;

&lt;p&gt;During development, I encountered a problem in which CFAST stopped returning new simulation results.&lt;/p&gt;

&lt;p&gt;Unity itself continued running.&lt;/p&gt;

&lt;p&gt;The player could still move and interact with the environment, but the indoor smoke and opening smoke could no longer receive updated simulation data.&lt;/p&gt;

&lt;p&gt;Initially, several possible causes were considered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unity rendering performance&lt;/li&gt;
&lt;li&gt;Asynchronous task management&lt;/li&gt;
&lt;li&gt;Inter-process communication&lt;/li&gt;
&lt;li&gt;File-based result handling&lt;/li&gt;
&lt;li&gt;The CFAST numerical solver&lt;/li&gt;
&lt;li&gt;Building geometry and simulation input conditions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To isolate the problem, previously recorded simulation inputs were replayed directly against the native CFAST worker, without Unity.&lt;/p&gt;

&lt;p&gt;The numerical stall could also be reproduced in the isolated native environment.&lt;/p&gt;

&lt;p&gt;One test produced the following result:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measurement&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Last accepted simulation time&lt;/td&gt;
&lt;td&gt;16.10 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requested simulation time&lt;/td&gt;
&lt;td&gt;16.15 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requested simulation interval&lt;/td&gt;
&lt;td&gt;0.05 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Response waiting time&lt;/td&gt;
&lt;td&gt;At least 112 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A request to advance the simulation by only 0.05 seconds failed to return a response within 112 seconds.&lt;/p&gt;

&lt;p&gt;This indicated that the problem was not simply a rendering performance issue inside Unity.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Investigating Horizontal Vents and Numerical Instability
&lt;/h2&gt;

&lt;p&gt;The Stage02 CFAST building model consists of seven indoor compartments and an attic compartment.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Compartment&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;R1&lt;/td&gt;
&lt;td&gt;Bathroom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R2&lt;/td&gt;
&lt;td&gt;Washroom and dressing area&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R3&lt;/td&gt;
&lt;td&gt;Left bedroom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R4&lt;/td&gt;
&lt;td&gt;Living, dining, and kitchen area&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R5&lt;/td&gt;
&lt;td&gt;Entrance hall&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R6&lt;/td&gt;
&lt;td&gt;Toilet compartment&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R7&lt;/td&gt;
&lt;td&gt;Right bedroom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R8&lt;/td&gt;
&lt;td&gt;Attic&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The investigation identified a problematic numerical condition associated with horizontal vent H4, which connected the living area (R4) to the attic (R8).&lt;/p&gt;

&lt;h3&gt;
  
  
  6.1 Discontinuous Gas Layer Assignment
&lt;/h3&gt;

&lt;p&gt;CFAST determines how gas entering a compartment through a horizontal vent should be assigned to its upper or lower layer.&lt;/p&gt;

&lt;p&gt;The investigated calculation includes a switching condition associated with a temperature difference of 1 K.&lt;/p&gt;

&lt;p&gt;Near this boundary, small changes in the numerical trial values can change the destination layer of the incoming gas.&lt;/p&gt;

&lt;p&gt;The following is a simplified conceptual representation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             Gas Inflow
                  │
                  ▼
        Layer Assignment Decision
                  │
         Temperature Boundary
                1 K
                  │
         ┌────────┴────────┐
         ▼                 ▼
    Upper Layer       Lower Layer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the gas flow rate is significant, switching the destination layer can abruptly change the contributions to the mass, energy, and volume balance equations.&lt;/p&gt;

&lt;p&gt;The problem becomes particularly important during iterative numerical calculations.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.2 DASSL and Newton Iteration
&lt;/h3&gt;

&lt;p&gt;CFAST uses &lt;strong&gt;DASSL&lt;/strong&gt;, a numerical solver for differential-algebraic equations (DAEs).&lt;/p&gt;

&lt;p&gt;A general DAE system can be represented as:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
F(t,y,\dot{y})=0&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;DASSL uses backward differentiation formulas and iterative methods to solve the resulting nonlinear equations.&lt;/p&gt;

&lt;p&gt;During the isolated investigation, I observed the following sequence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Predict the next simulation state
                ↓
Evaluate the residual equations
                ↓
Perform Newton iteration
                ↓
Cross the temperature switching boundary
                ↓
Change the destination gas layer
                ↓
Abrupt change in residual
                ↓
Convergence failure
                ↓
Reduce the internal time step
                ↓
Repeat the calculation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The repeated convergence failures and time-step reductions prevented the solver from efficiently reaching the requested simulation time.&lt;/p&gt;

&lt;p&gt;This behavior resembles threshold-induced chattering in embedded systems.&lt;/p&gt;

&lt;p&gt;However, it is important to clarify that the physical gas is not rapidly moving back and forth between layers.&lt;/p&gt;

&lt;p&gt;The switching occurs in the numerical assignment of gas flow during the solver's internal trial evaluations.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.3 Observed Numerical Evidence
&lt;/h3&gt;

&lt;p&gt;The isolated test produced the following observations:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measurement&lt;/th&gt;
&lt;th&gt;Observed Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Gas inflow through H4&lt;/td&gt;
&lt;td&gt;Approximately 12.49 kg/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change in R8 upper-layer volume residual&lt;/td&gt;
&lt;td&gt;Approximately +10.523 m³/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Increase in Newton correction norm&lt;/td&gt;
&lt;td&gt;67.3×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Internal time-step reduction&lt;/td&gt;
&lt;td&gt;To one-quarter&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Convergence rejections&lt;/td&gt;
&lt;td&gt;16,243&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rejections with layer switching observed in the same Newton pass&lt;/td&gt;
&lt;td&gt;16,150&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The co-occurrence rate was approximately:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
\frac{16150}{16243}\times100&lt;br&gt;
\approx99.43\%&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;In other words, layer switching was observed in the same Newton pass for approximately 99.43% of the recorded convergence rejections.&lt;/p&gt;

&lt;p&gt;The change in the upper-layer volume residual also matched the calculated contribution from H4.&lt;/p&gt;

&lt;p&gt;This provided evidence of the numerical mechanism connecting the layer assignment change to convergence rejection.&lt;/p&gt;

&lt;p&gt;However, this percentage is an observed co-occurrence rate, not the probability that H4 caused every numerical stall.&lt;/p&gt;

&lt;p&gt;The detailed mechanism was confirmed in an isolated test. It was not independently established for every unresponsive STEP observed during Unity gameplay.&lt;/p&gt;


&lt;h2&gt;
  
  
  7. Fixing the Building Model Instead of the Solver
&lt;/h2&gt;

&lt;p&gt;After investigating the numerical solver, I reconsidered the building model itself.&lt;/p&gt;

&lt;p&gt;In the Unity scene, the rooms are separated from the attic by structural ceilings.&lt;/p&gt;

&lt;p&gt;However, the original CFAST model contained open horizontal vents connecting the indoor compartments to the attic.&lt;/p&gt;

&lt;p&gt;The visual building and the simulation model were therefore inconsistent.&lt;/p&gt;

&lt;p&gt;Instead of modifying DASSL or changing the gas transport equations, I decided to correct the building model.&lt;/p&gt;
&lt;h3&gt;
  
  
  Before the Modification
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 R8 Attic
    ┌─────────────────────────────────┐
    │                                 │
    └───↑────↑────↑────↑────↑────↑────↑┘
        H1   H2   H3   H4   H5   H6   H7
        │    │    │    │    │    │    │
       R1   R2   R3   R4   R5   R6   R7

        Gas transport into the attic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  After the Modification
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 R8 Attic
    ┌─────────────────────────────────┐
    │                                 │
    └═════════════════════════════════┘
         Structural ceiling: sealed

       R1   R2   R3   R4   R5   R6   R7

          H1-H7 permanently closed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;All seven horizontal vents, H1 through H7, were permanently closed.&lt;/p&gt;

&lt;p&gt;The attic compartment itself was retained.&lt;/p&gt;

&lt;p&gt;By eliminating gas transport through these openings, the contribution of the affected flow assignment to the gas-layer balance equations was removed.&lt;/p&gt;

&lt;p&gt;The modification did not require changes to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The production CFAST worker&lt;/li&gt;
&lt;li&gt;DASSL&lt;/li&gt;
&lt;li&gt;The physical calculation equations&lt;/li&gt;
&lt;li&gt;Solver convergence tolerances&lt;/li&gt;
&lt;li&gt;The temperature switching condition&lt;/li&gt;
&lt;li&gt;Unity's shared smoke rendering system&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was a correction to the simulation input model, rather than a reduction in numerical accuracy.&lt;/p&gt;


&lt;h2&gt;
  
  
  8. Validation Results
&lt;/h2&gt;

&lt;p&gt;After applying the building model correction, previously recorded inputs were replayed against the existing production worker.&lt;/p&gt;

&lt;p&gt;The results were:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Validation Item&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Previously unresponsive conditions resolved&lt;/td&gt;
&lt;td&gt;3 / 3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Successful native STEP responses&lt;/td&gt;
&lt;td&gt;1,078 / 1,078&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Successful Unity tests&lt;/td&gt;
&lt;td&gt;37 / 37&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Failed Unity tests&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Skipped Unity tests&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gas flow through H1-H7&lt;/td&gt;
&lt;td&gt;Zero&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Independent code review&lt;/td&gt;
&lt;td&gt;PASS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Outstanding review findings&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The Unity scene tests covered three gameplay modes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AIM3D&lt;/li&gt;
&lt;li&gt;AIM3D2&lt;/li&gt;
&lt;li&gt;ZERO&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the tested scenes, the accepted CFAST simulation time advanced beyond 20 seconds, while indoor smoke and opening smoke continued receiving updated simulation results.&lt;/p&gt;

&lt;p&gt;Additional checks covered water damage state retention, entrance door operation in ZERO, and native worker release when returning to the title screen.&lt;/p&gt;

&lt;p&gt;The modifications were integrated into the production source code.&lt;/p&gt;

&lt;p&gt;These results establish that the previously identified unresponsive conditions were resolved within the tested scope.&lt;/p&gt;

&lt;p&gt;They do not guarantee stability for every possible fire scenario, building configuration, hardware platform, or gameplay sequence.&lt;/p&gt;


&lt;h2&gt;
  
  
  9. Optimizing Smoke Rendering Performance
&lt;/h2&gt;

&lt;p&gt;Numerical stability was not the only technical challenge.&lt;/p&gt;

&lt;p&gt;Real-time smoke rendering also introduces CPU and GPU workloads.&lt;/p&gt;

&lt;p&gt;During development, I identified unnecessary processing in Unity's opening smoke renderer.&lt;/p&gt;

&lt;p&gt;Previously, particle retrieval and mesh updates could still be performed even when an opening had no smoke particles to render.&lt;/p&gt;

&lt;p&gt;I introduced two optimization strategies.&lt;/p&gt;
&lt;h3&gt;
  
  
  9.1 Skip Unnecessary Operations for Empty Openings
&lt;/h3&gt;

&lt;p&gt;When an opening has no particles to render, the following unnecessary operations are skipped:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Particle data retrieval&lt;/li&gt;
&lt;li&gt;Vertex generation&lt;/li&gt;
&lt;li&gt;Mesh data transfer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Appearance and boundary buffer updates are preserved.&lt;/p&gt;

&lt;p&gt;If gas flow becomes zero while existing particles remain, their visualization continues according to the existing rendering behavior.&lt;/p&gt;
&lt;h3&gt;
  
  
  9.2 Reuse Existing Meshes
&lt;/h3&gt;

&lt;p&gt;When the rendering input is exactly identical to the previous input, the existing mesh is reused.&lt;/p&gt;

&lt;p&gt;The comparison includes information such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Particle position&lt;/li&gt;
&lt;li&gt;Particle size&lt;/li&gt;
&lt;li&gt;Particle rotation&lt;/li&gt;
&lt;li&gt;Optical appearance&lt;/li&gt;
&lt;li&gt;Transformation matrices&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the input changes, the mesh is updated normally.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Opening Smoke Rendering
          │
          ▼
    Particles Present?
       │        │
      No       Yes
       │        │
       ▼        ▼
 Skip Particle  Compare Rendering
 Retrieval and  Input with Previous
 Mesh Transfer        │
                ┌─────┴─────┐
                ▼           ▼
             Identical    Changed
                │           │
                ▼           ▼
             Reuse Mesh  Update Mesh
                │           │
                └─────┬─────┘
                      ▼
          Preserve Appearance and
           Boundary Buffer Updates
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No new approximation threshold or fixed mesh update interval was introduced.&lt;/p&gt;

&lt;p&gt;The objective was to eliminate redundant work without deliberately reducing rendering quality.&lt;/p&gt;

&lt;h3&gt;
  
  
  9.3 Performance Measurement
&lt;/h3&gt;

&lt;p&gt;A controlled comparison was performed in the Stage02 ZERO scene using the Unity Editor.&lt;/p&gt;

&lt;p&gt;The test covered 13 openings containing no smoke particles.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measurement&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Median CPU processing time&lt;/td&gt;
&lt;td&gt;0.09370 ms&lt;/td&gt;
&lt;td&gt;0.04965 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Particle retrieval calls per frame&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mesh write calls per frame&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The reduction in CPU processing time was approximately:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
\frac{0.09370-0.04965}{0.09370}\times100&lt;br&gt;
\approx47.01\%&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approximately 47% less CPU processing time for the measured operation.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a component-level performance measurement.&lt;/p&gt;

&lt;p&gt;It does not mean that the overall game frame rate increased by 47%.&lt;/p&gt;

&lt;p&gt;The effect on overall FPS in the production standalone Player has not yet been confirmed.&lt;/p&gt;


&lt;h2&gt;
  
  
  10. Dynamic Interior Doors and Smoke Transport
&lt;/h2&gt;

&lt;p&gt;Six interactive interior doors were added to Stage02.&lt;/p&gt;

&lt;p&gt;All six doors begin in the fully closed state.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Opening&lt;/th&gt;
&lt;th&gt;Connected Compartments&lt;/th&gt;
&lt;th&gt;Opening Direction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;V1&lt;/td&gt;
&lt;td&gt;Entrance Hall ↔ Toilet&lt;/td&gt;
&lt;td&gt;Toward the entrance hall&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;V3&lt;/td&gt;
&lt;td&gt;Bathroom ↔ Washroom&lt;/td&gt;
&lt;td&gt;Toward the washroom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;V4&lt;/td&gt;
&lt;td&gt;Living Area ↔ Left Bedroom&lt;/td&gt;
&lt;td&gt;Toward the living area&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;V5&lt;/td&gt;
&lt;td&gt;Entrance Hall ↔ Washroom&lt;/td&gt;
&lt;td&gt;Toward the washroom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;V6&lt;/td&gt;
&lt;td&gt;Entrance Hall ↔ Living Area&lt;/td&gt;
&lt;td&gt;Toward the living area&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;V7&lt;/td&gt;
&lt;td&gt;Living Area ↔ Right Bedroom&lt;/td&gt;
&lt;td&gt;Toward the living area&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The former opening V2 is permanently closed. V7 is the designated entrance to the right bedroom.&lt;/p&gt;

&lt;p&gt;When a player operates a door, Unity updates the opening condition and passes the relevant input to CFAST.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Player Opens or Closes a Door
              ↓
Unity Updates Door State
              ↓
Opening Conditions Sent to CFAST
              ↓
Gas Transport Calculation
              ↓
Updated Simulation Results
              ↓
Indoor and Opening Smoke Rendering
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, closing V6 prevents direct gas transport through that opening between the living area and entrance hall.&lt;/p&gt;

&lt;p&gt;Opening V6 establishes a possible transport path between the compartments.&lt;/p&gt;

&lt;p&gt;The actual flow rate and direction depend on the CFAST simulation results.&lt;/p&gt;

&lt;p&gt;Opening a door does not simply trigger a predefined smoke effect.&lt;/p&gt;

&lt;p&gt;It changes the input conditions of the fire simulation itself.&lt;/p&gt;

&lt;p&gt;This is an important part of the interactive fire environment I am developing.&lt;/p&gt;




&lt;h2&gt;
  
  
  11. AI-Assisted Development and Independent Code Review
&lt;/h2&gt;

&lt;p&gt;This project is being developed with the assistance of OpenAI Codex.&lt;/p&gt;

&lt;p&gt;The development process involves more than generating Unity C# scripts.&lt;/p&gt;

&lt;p&gt;It includes investigating Fortran source code, analyzing numerical simulation logs, implementing inter-process communication, and conducting regression tests.&lt;/p&gt;

&lt;p&gt;I use separate implementation and review roles.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Requirements and Design
          ↓
Developer Approval
          ↓
AI Implementation Agent
          ↓
Testing and Measurement
          ↓
Independent Review Agent
          ↓
Developer Acceptance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The developer remains responsible for defining the requirements, approving design decisions, and determining whether an implementation should be adopted.&lt;/p&gt;

&lt;p&gt;One important lesson from this project was that AI-generated testing can expand beyond the actual requirements.&lt;/p&gt;

&lt;p&gt;For example, an AI agent may introduce acceptance criteria for functionality that has never been designed or approved.&lt;/p&gt;

&lt;p&gt;This can lead to unnecessary investigations, repeated tests, and implementation changes outside the intended scope.&lt;/p&gt;

&lt;p&gt;I therefore established a development policy based on approved requirements.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PASS&lt;/td&gt;
&lt;td&gt;The approved requirements are satisfied.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;FAIL&lt;/td&gt;
&lt;td&gt;An approved requirement is not satisfied, or a regression exists.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BLOCKED&lt;/td&gt;
&lt;td&gt;A required verification cannot be completed due to a concrete blocker.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NOT_RUN&lt;/td&gt;
&lt;td&gt;An applicable test has not been executed.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;The functionality is outside the current scope.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PROPOSAL&lt;/td&gt;
&lt;td&gt;A proposed addition that requires approval.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The absence of an undesigned feature is not automatically a failure.&lt;/p&gt;

&lt;p&gt;Before introducing a new feature, its relevance to the game must first be evaluated.&lt;/p&gt;

&lt;p&gt;AI makes it possible to conduct extensive investigations and generate large numbers of tests.&lt;/p&gt;

&lt;p&gt;However, effective software development still requires clear engineering objectives, defined responsibilities, and controlled acceptance criteria.&lt;/p&gt;




&lt;h2&gt;
  
  
  12. Interactive Technical Documentation
&lt;/h2&gt;

&lt;p&gt;I have also prepared a technical explanation of the CFAST and Unity integration on the project website.&lt;/p&gt;

&lt;p&gt;The website is designed to explain the simulation architecture through visual diagrams, animations, and interactive content.&lt;/p&gt;

&lt;h3&gt;
  
  
  CFAST × Unity Technical Guide
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html" rel="noopener noreferrer"&gt;https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Stage02 Technical Validation
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html#stage02-validation" rel="noopener noreferrer"&gt;https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html#stage02-validation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The technical documentation covers topics such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CFAST's two-zone fire model&lt;/li&gt;
&lt;li&gt;Stateful simulation and Unity integration&lt;/li&gt;
&lt;li&gt;Indoor volumetric smoke rendering&lt;/li&gt;
&lt;li&gt;Smoke transport through openings&lt;/li&gt;
&lt;li&gt;Building compartment geometry&lt;/li&gt;
&lt;li&gt;Horizontal vents and numerical solver instability&lt;/li&gt;
&lt;li&gt;DASSL convergence rejection&lt;/li&gt;
&lt;li&gt;Smoke rendering optimization&lt;/li&gt;
&lt;li&gt;Dynamic interior doors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The project website is currently presented primarily in Japanese, with diagrams and visual explanations of the technical concepts.&lt;/p&gt;

&lt;p&gt;If you are interested in the intersection of scientific simulation, game development, and real-time graphics, please take a look.&lt;/p&gt;




&lt;h2&gt;
  
  
  13. What I Learned from This Project
&lt;/h2&gt;

&lt;p&gt;Integrating a scientific fire simulator with a game engine involves much more than importing simulation results.&lt;/p&gt;

&lt;p&gt;The project has required work across multiple engineering disciplines:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Technical Domain&lt;/th&gt;
&lt;th&gt;Application&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Numerical simulation&lt;/td&gt;
&lt;td&gt;CFAST and DASSL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Native software development&lt;/td&gt;
&lt;td&gt;Fortran&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Game programming&lt;/td&gt;
&lt;td&gt;C# and Unity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Systems engineering&lt;/td&gt;
&lt;td&gt;Inter-process communication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Geometry processing&lt;/td&gt;
&lt;td&gt;Compartment and opening models&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Computer graphics&lt;/td&gt;
&lt;td&gt;Volumetric smoke and particle rendering&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Performance engineering&lt;/td&gt;
&lt;td&gt;CPU and GPU optimization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Software quality assurance&lt;/td&gt;
&lt;td&gt;Regression testing and independent review&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AI-assisted development&lt;/td&gt;
&lt;td&gt;Codex&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One of the most significant lessons was that a numerical solver problem does not necessarily require a numerical solver modification.&lt;/p&gt;

&lt;p&gt;In this case, a mismatch between the visual building geometry and the simulation model introduced gas transport conditions associated with numerical instability.&lt;/p&gt;

&lt;p&gt;Correcting the building model resolved the previously identified unresponsive conditions without modifying the production solver.&lt;/p&gt;

&lt;p&gt;Another important lesson was the need to distinguish between the scientific simulation state and its visual representation.&lt;/p&gt;

&lt;p&gt;CFAST calculates the physical state of the environment at the compartment level. Unity transforms the available numerical information into an interactive game experience.&lt;/p&gt;

&lt;p&gt;The two systems serve different purposes, and understanding their respective responsibilities is essential.&lt;/p&gt;




&lt;h2&gt;
  
  
  14. Future Development
&lt;/h2&gt;

&lt;p&gt;I am continuing to explore fire simulation technologies for interactive game development.&lt;/p&gt;

&lt;p&gt;In addition to CFAST, I am working with another NIST fire simulation tool:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FDS (Fire Dynamics Simulator)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;FDS uses computational fluid dynamics to calculate spatially detailed fire-driven flows.&lt;/p&gt;

&lt;p&gt;The long-term development direction is to explore how these different simulation models can complement one another.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CFAST for compartment-level incremental simulation&lt;/li&gt;
&lt;li&gt;FDS for detailed fire and smoke analysis&lt;/li&gt;
&lt;li&gt;Unity for interactive gameplay and real-time visualization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The objective is not to replace every game effect with a scientific simulation.&lt;/p&gt;

&lt;p&gt;Instead, I want to explore how scientific computing can contribute to new forms of interactive game environments.&lt;/p&gt;

&lt;p&gt;This project is being developed as a game. It does not claim validated accuracy for real-world fire prediction or certified effectiveness as a professional firefighting training system.&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;NIST CFAST&lt;br&gt;&lt;br&gt;
&lt;a href="https://pages.nist.gov/cfast/" rel="noopener noreferrer"&gt;https://pages.nist.gov/cfast/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CFAST Official GitHub Repository&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/firemodels/cfast" rel="noopener noreferrer"&gt;https://github.com/firemodels/cfast&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CFAST Version 7 Technical Reference Guide&lt;br&gt;&lt;br&gt;
&lt;a href="https://doi.org/10.6028/NIST.TN.1889v1" rel="noopener noreferrer"&gt;https://doi.org/10.6028/NIST.TN.1889v1&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;NIST Fire Dynamics Simulator and Smokeview&lt;br&gt;&lt;br&gt;
&lt;a href="https://pages.nist.gov/fds/" rel="noopener noreferrer"&gt;https://pages.nist.gov/fds/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  About the Project
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SOKYU: OPERATION RESCUE BLAZE SERIES&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An independently developed firefighting and disaster response game combining:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fire simulation&lt;/li&gt;
&lt;li&gt;Unity game development&lt;/li&gt;
&lt;li&gt;Real-time graphics&lt;/li&gt;
&lt;li&gt;Embedded systems&lt;/li&gt;
&lt;li&gt;Robotics&lt;/li&gt;
&lt;li&gt;Artificial intelligence&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Developed by &lt;strong&gt;Motomachi Digital Making Lab&lt;/strong&gt;, Yokohama, Japan.&lt;/p&gt;

&lt;p&gt;Technical Guide:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html" rel="noopener noreferrer"&gt;https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;CFAST × Unity Development Report #1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;November 26, 2026&lt;/p&gt;

</description>
      <category>cfast</category>
      <category>fist</category>
      <category>unity3d</category>
    </item>
    <item>
      <title>CFAST Unity Dev Report #2: Managing Fire States, Fuel Consumption, and Extinguishing Events in an Asynchronous System</title>
      <dc:creator>Hidenori Ishii</dc:creator>
      <pubDate>Thu, 26 Nov 2026 13:29:56 +0000</pubDate>
      <link>https://dev.to/47_robin_ebe9e47eb349d767/cfast-x-unity-dev-report-2-managing-fire-states-fuel-consumption-and-extinguishing-events-in-an-45pi</link>
      <guid>https://dev.to/47_robin_ebe9e47eb349d767/cfast-x-unity-dev-report-2-managing-fire-states-fuel-consumption-and-extinguishing-events-in-an-45pi</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;1. Separating the Responsibilities of Unity and CFAST&lt;/li&gt;
&lt;li&gt;2. Stateful Simulation and Asynchronous Communication&lt;/li&gt;
&lt;li&gt;3. Managing Multiple Fire Sources&lt;/li&gt;
&lt;li&gt;4. Allocating Fuel Across Compartments&lt;/li&gt;
&lt;li&gt;5. Investigating Ceiling Fire Sources&lt;/li&gt;
&lt;li&gt;6. Requested HRR vs. Actual HRR&lt;/li&gt;
&lt;li&gt;7. Why Fuel Pyrolysis Can Continue After Combustion Stops&lt;/li&gt;
&lt;li&gt;8. Treating the Ceiling as a Structural Boundary&lt;/li&gt;
&lt;li&gt;9. The Asynchronous HP Overwrite Problem&lt;/li&gt;
&lt;li&gt;10. Fixing the State Management Problem&lt;/li&gt;
&lt;li&gt;11. Validation Results&lt;/li&gt;
&lt;li&gt;12. Extinguishing Events and Zero-HRR Commands&lt;/li&gt;
&lt;li&gt;13. Different Completion Conditions in Stage01 and Stage02&lt;/li&gt;
&lt;li&gt;14. Connecting Fire Sources, Doors, and Smoke Rendering&lt;/li&gt;
&lt;li&gt;15. AI-Assisted Development and Acceptance Criteria&lt;/li&gt;
&lt;li&gt;16. Current Implementation and Limitations&lt;/li&gt;
&lt;li&gt;17. Interactive Technical Documentation&lt;/li&gt;
&lt;li&gt;18. Conclusion&lt;/li&gt;
&lt;li&gt;References&lt;/li&gt;
&lt;li&gt;About the Project&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;I am an independent developer working on a firefighting and disaster response game called &lt;strong&gt;SOKYU: OPERATION RESCUE BLAZE SERIES&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In the first development report, I introduced how I integrated CFAST, a fire simulator developed by the National Institute of Standards and Technology (NIST), with the Unity game engine.&lt;/p&gt;

&lt;p&gt;The first report covered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stateful fire simulation&lt;/li&gt;
&lt;li&gt;Real-time smoke rendering&lt;/li&gt;
&lt;li&gt;Inter-process communication&lt;/li&gt;
&lt;li&gt;Numerical solver instability&lt;/li&gt;
&lt;li&gt;Building model corrections&lt;/li&gt;
&lt;li&gt;Smoke rendering optimization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this second report, I will focus on another engineering challenge:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How can a game engine and a scientific fire simulator manage combustion, fuel consumption, and extinguishing events without creating inconsistent states?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In a game, a player can apply water to a fire and reduce its health points (HP).&lt;/p&gt;

&lt;p&gt;Meanwhile, CFAST calculates heat release rates, oxygen concentrations, fuel pyrolysis, smoke generation, and gas transport.&lt;/p&gt;

&lt;p&gt;These two systems operate independently and update their states at different times.&lt;/p&gt;

&lt;p&gt;Connecting them requires more than simply exchanging numerical data. It requires careful management of state ownership, asynchronous communication, and simulation consistency.&lt;/p&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;1. Separating the Responsibilities of Unity and CFAST&lt;/li&gt;
&lt;li&gt;2. Stateful Simulation and Asynchronous Communication&lt;/li&gt;
&lt;li&gt;3. Managing Multiple Fire Sources&lt;/li&gt;
&lt;li&gt;4. Allocating Fuel Across Compartments&lt;/li&gt;
&lt;li&gt;5. Investigating Ceiling Fire Sources&lt;/li&gt;
&lt;li&gt;6. Requested HRR vs. Actual HRR&lt;/li&gt;
&lt;li&gt;7. Why Fuel Pyrolysis Can Continue After Combustion Stops&lt;/li&gt;
&lt;li&gt;8. Treating the Ceiling as a Structural Boundary&lt;/li&gt;
&lt;li&gt;9. The Asynchronous HP Overwrite Problem&lt;/li&gt;
&lt;li&gt;10. Fixing the State Management Problem&lt;/li&gt;
&lt;li&gt;11. Validation Results&lt;/li&gt;
&lt;li&gt;12. Extinguishing Events and Zero-HRR Commands&lt;/li&gt;
&lt;li&gt;13. Different Completion Conditions in Stage01 and Stage02&lt;/li&gt;
&lt;li&gt;14. Connecting Fire Sources, Doors, and Smoke Rendering&lt;/li&gt;
&lt;li&gt;15. AI-Assisted Development and Acceptance Criteria&lt;/li&gt;
&lt;li&gt;16. Current Implementation and Limitations&lt;/li&gt;
&lt;li&gt;17. Interactive Technical Documentation&lt;/li&gt;
&lt;li&gt;18. Conclusion&lt;/li&gt;
&lt;li&gt;References&lt;/li&gt;
&lt;li&gt;About the Project&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1. Separating the Responsibilities of Unity and CFAST
&lt;/h2&gt;

&lt;p&gt;Unity is a game engine, while CFAST is a scientific fire simulation program.&lt;/p&gt;

&lt;p&gt;Although they exchange information, their responsibilities are fundamentally different.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;th&gt;Unity&lt;/th&gt;
&lt;th&gt;CFAST&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Player input&lt;/td&gt;
&lt;td&gt;Managed&lt;/td&gt;
&lt;td&gt;Not applicable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Water application&lt;/td&gt;
&lt;td&gt;Managed&lt;/td&gt;
&lt;td&gt;Receives corresponding fire input&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Water hit detection&lt;/td&gt;
&lt;td&gt;Managed&lt;/td&gt;
&lt;td&gt;Not applicable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fire HP&lt;/td&gt;
&lt;td&gt;Managed&lt;/td&gt;
&lt;td&gt;Not applicable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requested heat release rate&lt;/td&gt;
&lt;td&gt;Generates input&lt;/td&gt;
&lt;td&gt;Receives input&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Actual heat release rate&lt;/td&gt;
&lt;td&gt;Uses simulation results&lt;/td&gt;
&lt;td&gt;Calculates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fuel pyrolysis&lt;/td&gt;
&lt;td&gt;Uses simulation results&lt;/td&gt;
&lt;td&gt;Calculates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Oxygen concentration&lt;/td&gt;
&lt;td&gt;Uses simulation results&lt;/td&gt;
&lt;td&gt;Calculates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Smoke optical density&lt;/td&gt;
&lt;td&gt;Uses for rendering&lt;/td&gt;
&lt;td&gt;Calculates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Door and window state&lt;/td&gt;
&lt;td&gt;Managed&lt;/td&gt;
&lt;td&gt;Receives input&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gas transport&lt;/td&gt;
&lt;td&gt;Uses for visualization&lt;/td&gt;
&lt;td&gt;Calculates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stage completion&lt;/td&gt;
&lt;td&gt;Managed&lt;/td&gt;
&lt;td&gt;Not applicable&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;CFAST does not understand gameplay concepts such as health points, player actions, or mission completion.&lt;/p&gt;

&lt;p&gt;Similarly, Unity's gameplay state alone does not calculate compartment-level fire dynamics.&lt;/p&gt;

&lt;p&gt;The architecture therefore separates gameplay responsibilities from scientific simulation responsibilities.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UNITY
─────────────────────────────────
Player Input
Water Hit Detection
Fire HP
Door and Window State
Game Progression
         │
         │ Simulation Input
         ▼
CFAST NATIVE WORKER
─────────────────────────────────
Combustion
Heat Release Rate
Fuel Pyrolysis
Oxygen Concentration
Smoke and Gas Transport
         │
         │ Simulation Results
         ▼
UNITY VISUALIZATION
─────────────────────────────────
Fire Rendering
Indoor Smoke Volume
Opening Smoke Particles
Fuel State Updates
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The objective is not to make both systems independently manage the same information.&lt;/p&gt;

&lt;p&gt;Instead, each system is responsible for the information it is designed to manage.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Stateful Simulation and Asynchronous Communication
&lt;/h2&gt;

&lt;p&gt;As introduced in the previous report, I developed a stateful derivative of CFAST that runs as an independent native worker.&lt;/p&gt;

&lt;p&gt;Unity sends a STEP request containing updated fire and opening conditions.&lt;/p&gt;

&lt;p&gt;The CFAST worker advances the simulation from its previously accepted state to the requested simulation time.&lt;/p&gt;

&lt;p&gt;Once the calculation is complete, the worker returns a new observation to Unity.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Unity                         CFAST Worker
  │                                │
  │──── STEP Request ─────────────&amp;gt;│
  │                                │
  │ Player movement continues      │ Numerical
  │ Water application continues    │ calculation
  │ Fire HP may change              │
  │                                │
  │&amp;lt;──── Simulation Results ───────│
  │                                │
  │ Validate and accept results    │
  │ Update fire and smoke           │
  │                                │
  │──── Next STEP Request ────────&amp;gt;│
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The game does not need to block its main thread while waiting for CFAST.&lt;/p&gt;

&lt;p&gt;However, this introduces a state management challenge.&lt;/p&gt;

&lt;p&gt;The gameplay state may change after a simulation request has been submitted but before its response arrives.&lt;/p&gt;

&lt;p&gt;An asynchronous response must therefore be interpreted in the context of the request that generated it.&lt;/p&gt;

&lt;p&gt;It cannot automatically be treated as the latest gameplay state.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Managing Multiple Fire Sources
&lt;/h2&gt;

&lt;p&gt;Stage02 is based on a Japanese 2LDK residential layout.&lt;/p&gt;

&lt;p&gt;The CFAST building model consists of the following compartments:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Compartment&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;R1&lt;/td&gt;
&lt;td&gt;Bathroom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R2&lt;/td&gt;
&lt;td&gt;Washroom and dressing area&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R3&lt;/td&gt;
&lt;td&gt;Left bedroom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R4&lt;/td&gt;
&lt;td&gt;Living, dining, and kitchen area&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R5&lt;/td&gt;
&lt;td&gt;Entrance hall&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R6&lt;/td&gt;
&lt;td&gt;Toilet compartment&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R7&lt;/td&gt;
&lt;td&gt;Right bedroom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R8&lt;/td&gt;
&lt;td&gt;Attic&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;During development, I extended the CFAST integration to include the entrance hall floor and wallpaper as additional fuel sources.&lt;/p&gt;

&lt;p&gt;The challenge was that Unity's combustible objects did not always correspond to a single CFAST compartment.&lt;/p&gt;

&lt;p&gt;A single combustible surface could extend across multiple gas calculation regions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mapping Unity Fire Objects to CFAST Fire Sources
&lt;/h3&gt;

&lt;p&gt;The resulting Stage02 model contains five native fire sources.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fire ID&lt;/th&gt;
&lt;th&gt;Combustible Object&lt;/th&gt;
&lt;th&gt;Compartment&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;F1&lt;/td&gt;
&lt;td&gt;Dedicated propane fire source&lt;/td&gt;
&lt;td&gt;R4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;F2&lt;/td&gt;
&lt;td&gt;Hall floor&lt;/td&gt;
&lt;td&gt;R5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;F3&lt;/td&gt;
&lt;td&gt;Hall floor&lt;/td&gt;
&lt;td&gt;R6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;F4&lt;/td&gt;
&lt;td&gt;Hall wallpaper&lt;/td&gt;
&lt;td&gt;R5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;F5&lt;/td&gt;
&lt;td&gt;Hall wallpaper&lt;/td&gt;
&lt;td&gt;R6&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The Unity-side representation is different from the CFAST representation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Unity Combustible Objects          CFAST Fire Sources

Hall Floor ───────────────────┬──&amp;gt; F2 / R5
                              │
                              └──&amp;gt; F3 / R6


Hall Wallpaper ───────────────┬──&amp;gt; F4 / R5
                              │
                              └──&amp;gt; F5 / R6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unity manages the floor and wallpaper as two individual combustible objects.&lt;/p&gt;

&lt;p&gt;CFAST represents them using four fire sources distributed across two compartments.&lt;/p&gt;

&lt;p&gt;The integration must therefore maintain a mapping between gameplay objects and native simulation fire sources.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Allocating Fuel Across Compartments
&lt;/h2&gt;

&lt;p&gt;When a single combustible surface is associated with multiple CFAST compartments, its fuel must be distributed without duplicating the original fuel quantity.&lt;/p&gt;

&lt;p&gt;For this implementation, the allocation ratios were calculated from the contact areas between the combustible surface and the corresponding CFAST gas regions.&lt;/p&gt;

&lt;p&gt;The allocation ratio is defined as:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
r_i=\frac{A_i}{\sum_j A_j}&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;$A_i$ is the contact area associated with compartment $i$.&lt;/li&gt;
&lt;li&gt;$r_i$ is the fuel allocation ratio for compartment $i$.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the original fuel quantity is $M$, the allocated quantity is:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
M_i=r_iM&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;The total allocated fuel must satisfy:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
\sum_i M_i=M&lt;br&gt;
$$&lt;/p&gt;
&lt;h3&gt;
  
  
  Stage02 Fuel Allocation Results
&lt;/h3&gt;

&lt;p&gt;The following allocation ratios were calculated from the existing building geometry.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Combustible Object&lt;/th&gt;
&lt;th&gt;R5 Allocation&lt;/th&gt;
&lt;th&gt;R6 Allocation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hall floor&lt;/td&gt;
&lt;td&gt;73.587%&lt;/td&gt;
&lt;td&gt;26.413%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hall wallpaper&lt;/td&gt;
&lt;td&gt;23.609%&lt;/td&gt;
&lt;td&gt;76.391%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The original fuel quantity is distributed rather than duplicated.&lt;/p&gt;

&lt;p&gt;The allocation was also checked to ensure that the total initial fuel budget remained unchanged.&lt;/p&gt;

&lt;p&gt;The displayed percentages are rounded. The implementation uses the original calculated values.&lt;/p&gt;

&lt;p&gt;This approach is a geometric approximation used to map gameplay fuel objects to compartment-level simulation sources.&lt;/p&gt;

&lt;p&gt;It is not a material combustion model calibrated against experimental fire tests.&lt;/p&gt;


&lt;h2&gt;
  
  
  5. Investigating Ceiling Fire Sources
&lt;/h2&gt;

&lt;p&gt;Initially, I also considered connecting the ceiling to CFAST as an independent combustible source.&lt;/p&gt;

&lt;p&gt;However, tests involving fire sources positioned near the ceiling revealed an interesting limitation of the two-zone model.&lt;/p&gt;
&lt;h3&gt;
  
  
  The Initial Upper Gas Layer
&lt;/h3&gt;

&lt;p&gt;CFAST represents a compartment using upper and lower gas layers.&lt;/p&gt;

&lt;p&gt;In the investigated Stage02 model, the initial upper layer occupied approximately 0.01% of the compartment volume.&lt;/p&gt;

&lt;p&gt;For a compartment approximately 2.7 meters high, this corresponded to an initial upper-layer thickness of approximately 0.27 millimeters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;              Ceiling
┌────────────────────────────────┐
│ Upper Gas Layer                │
│ Approx. 0.27 mm initially      │
├────────────────────────────────┤
│                                │
│                                │
│                                │
│ Lower Gas Layer                │
│                                │
│ Approx. 99.99% of volume       │
│                                │
│                                │
└────────────────────────────────┘
                Floor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The diagram exaggerates the upper-layer thickness for readability.&lt;/p&gt;

&lt;p&gt;A ceiling fire source placed inside this extremely thin upper layer may have access to only a small amount of oxygen through the modeled plume entrainment process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Initial Oxygen Inventory
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Compartment and Layer&lt;/th&gt;
&lt;th&gt;Initial Oxygen Mass&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;R5 upper layer&lt;/td&gt;
&lt;td&gt;Approximately 0.377 g&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R5 lower layer&lt;/td&gt;
&lt;td&gt;Approximately 3.766 kg&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R6 upper layer&lt;/td&gt;
&lt;td&gt;Approximately 0.131 g&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R6 lower layer&lt;/td&gt;
&lt;td&gt;Approximately 1.309 kg&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Although the compartment as a whole contained a substantial amount of oxygen, the fire source was located in a layer with a very small initial oxygen inventory.&lt;/p&gt;

&lt;p&gt;This distinction became important during the combustion tests.&lt;/p&gt;

&lt;p&gt;The issue was not simply whether oxygen existed somewhere inside the room.&lt;/p&gt;

&lt;p&gt;It was whether oxygen was available to the modeled fire source through the relevant gas transport and entrainment processes.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Requested HRR vs. Actual HRR
&lt;/h2&gt;

&lt;p&gt;HRR stands for Heat Release Rate.&lt;/p&gt;

&lt;p&gt;In the Unity integration, a requested HRR is sent to CFAST as an input condition.&lt;/p&gt;

&lt;p&gt;However, the requested heat release rate is not necessarily equal to the actual heat release rate calculated by the simulator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Requested Heat Release Rate
                │
                ▼
       CFAST Combustion Model
                │
     ┌──────────┼──────────┐
     │          │          │
 Oxygen      Source      Plume
 Conditions  Position   Entrainment
     │          │          │
     └──────────┼──────────┘
                ▼
       Actual Heat Release Rate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CFAST can limit combustion according to oxygen availability and other modeled conditions.&lt;/p&gt;

&lt;p&gt;During the ceiling fire investigation, I used a candidate input with a total requested HRR of approximately 520 kW.&lt;/p&gt;

&lt;p&gt;The test also revealed an argument-order issue in the upper-layer plume calculation.&lt;/p&gt;

&lt;p&gt;A corrected experimental worker was built separately to investigate the effect of this issue.&lt;/p&gt;

&lt;h3&gt;
  
  
  Comparison of Initial Actual HRR
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Test Condition&lt;/th&gt;
&lt;th&gt;Initial Actual HRR&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Before the argument-order correction&lt;/td&gt;
&lt;td&gt;Approximately 520 kW&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;After the argument-order correction&lt;/td&gt;
&lt;td&gt;Approximately 4.25 kW&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;After the correction, the initial actual HRR was significantly lower than the requested value.&lt;/p&gt;

&lt;p&gt;Furthermore, under the tested constant-input conditions, actual HRR reached zero within approximately 0.1 seconds.&lt;/p&gt;

&lt;p&gt;Tests with different exterior opening conditions produced similar early behavior.&lt;/p&gt;

&lt;p&gt;This result did not establish that a real ceiling fire would behave in the same way.&lt;/p&gt;

&lt;p&gt;Instead, it revealed a limitation of the particular fire source representation, initial layer configuration, and combustion input used in this model.&lt;/p&gt;

&lt;p&gt;The corrected experimental worker was used for investigation. Its use should not be confused with deployment of a replacement production worker.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Why Fuel Pyrolysis Can Continue After Combustion Stops
&lt;/h2&gt;

&lt;p&gt;Another interesting result was that the calculated actual HRR could reach zero while fuel pyrolysis continued.&lt;/p&gt;

&lt;p&gt;At first, this seemed inconsistent.&lt;/p&gt;

&lt;p&gt;However, combustion and pyrolysis are not the same physical process.&lt;/p&gt;

&lt;p&gt;Pyrolysis refers to the thermal decomposition of fuel material.&lt;/p&gt;

&lt;p&gt;Combustion requires suitable conditions for the released fuel to react with oxygen and release heat.&lt;/p&gt;

&lt;p&gt;In the investigated CFAST configuration, the prescribed fuel pyrolysis rate continued even when oxygen limitations reduced the actual heat release rate.&lt;/p&gt;

&lt;p&gt;The unburned fuel gases accumulated in the upper layer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Requested Heat Release Rate and Prescribed Pyrolysis
&lt;/h3&gt;

&lt;p&gt;The native input processing uses the relationship:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
\dot{m}&lt;em&gt;{fuel}=\frac{\dot{Q}&lt;/em&gt;{requested}}{\Delta H_c}&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;$\dot{m}_{fuel}$ is the prescribed fuel mass flow rate.&lt;/li&gt;
&lt;li&gt;$\dot{Q}_{requested}$ is the requested heat release rate.&lt;/li&gt;
&lt;li&gt;$\Delta H_c$ is the heat of combustion.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The prescribed pyrolysis rate and actual combustion rate must therefore be distinguished.&lt;/p&gt;
&lt;h3&gt;
  
  
  Observed Behavior
&lt;/h3&gt;

&lt;p&gt;After correcting the plume argument order, the initial oxygen reduction was no longer primarily caused by extremely rapid combustion.&lt;/p&gt;

&lt;p&gt;Instead, the continued supply of unburned pyrolysis gases diluted the oxygen mass fraction in the very thin upper layer.&lt;/p&gt;

&lt;p&gt;In the investigated partial-opening condition, the upper layers retained most of their initial oxygen mass, but their oxygen mass fractions still fell below the combustion threshold.&lt;/p&gt;

&lt;p&gt;This explains why examining oxygen concentration alone is insufficient.&lt;/p&gt;

&lt;p&gt;The total oxygen mass, total gas mass, combustion consumption, and incoming fuel gases must also be considered.&lt;/p&gt;
&lt;h3&gt;
  
  
  Residual Smoke
&lt;/h3&gt;

&lt;p&gt;Smoke can also remain after actual HRR becomes zero.&lt;/p&gt;

&lt;p&gt;Soot generated during earlier combustion does not automatically disappear when the fire stops releasing heat.&lt;/p&gt;

&lt;p&gt;Consequently, the following assumptions would be inappropriate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Zero actual HRR means zero smoke.&lt;/li&gt;
&lt;li&gt;Zero actual HRR always means zero prescribed pyrolysis.&lt;/li&gt;
&lt;li&gt;An open door guarantees sufficient oxygen at every fire source.&lt;/li&gt;
&lt;li&gt;A stopped fire source implies that all previously generated combustion products have disappeared.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding the meaning of each simulation output is essential before connecting it to gameplay logic.&lt;/p&gt;


&lt;h2&gt;
  
  
  8. Treating the Ceiling as a Structural Boundary
&lt;/h2&gt;

&lt;p&gt;CFAST allows thermal material properties to be assigned to compartment boundaries.&lt;/p&gt;

&lt;p&gt;For example, ceiling materials can be used in heat transfer calculations involving conduction, convection, and radiation.&lt;/p&gt;

&lt;p&gt;However, assigning a ceiling material does not automatically create a complete model of ceiling ignition, material pyrolysis, and flame spread across the ceiling surface.&lt;/p&gt;

&lt;p&gt;Representing such combustion requires additional fire source definitions and suitable material-dependent combustion data.&lt;/p&gt;

&lt;p&gt;During the Stage02 investigation, the ceiling object was identified as part of the existing structural ceiling.&lt;/p&gt;

&lt;p&gt;No separate combustible ceiling finish was identified.&lt;/p&gt;

&lt;p&gt;I therefore adopted the following design:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Object&lt;/th&gt;
&lt;th&gt;Representation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hall floor&lt;/td&gt;
&lt;td&gt;CFAST fuel source&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hall wallpaper&lt;/td&gt;
&lt;td&gt;CFAST fuel source&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Structural ceiling slab&lt;/td&gt;
&lt;td&gt;CFAST thermal boundary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Existing Unity ceiling fire object&lt;/td&gt;
&lt;td&gt;Retained as a gameplay object&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The ceiling was not connected as an independent native fuel source.&lt;/p&gt;

&lt;p&gt;I also avoided introducing arbitrary source position offsets or artificial oxygen and HRR corrections merely to keep the ceiling fire burning.&lt;/p&gt;

&lt;p&gt;The objective of this project is to develop a game with simulation-driven fire behavior, not to construct an experimentally validated ceiling material combustion model.&lt;/p&gt;

&lt;p&gt;Understanding the limitations of a simulation model is just as important as implementing its capabilities.&lt;/p&gt;


&lt;h2&gt;
  
  
  9. The Asynchronous HP Overwrite Problem
&lt;/h2&gt;

&lt;p&gt;After connecting the Hall floor and wallpaper to CFAST, another problem emerged.&lt;/p&gt;

&lt;p&gt;Water damage applied by the player was sometimes lost while waiting for a simulation response.&lt;/p&gt;

&lt;p&gt;The cause was an asynchronous state management conflict.&lt;/p&gt;
&lt;h3&gt;
  
  
  Behavior Before the Fix
&lt;/h3&gt;

&lt;p&gt;Consider the following simplified example.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A fire object has 100 HP.&lt;/li&gt;
&lt;li&gt;Unity submits a simulation request.&lt;/li&gt;
&lt;li&gt;CFAST begins calculating.&lt;/li&gt;
&lt;li&gt;The player applies water to the fire.&lt;/li&gt;
&lt;li&gt;Unity reduces the fire HP.&lt;/li&gt;
&lt;li&gt;CFAST returns a result associated with the earlier request.&lt;/li&gt;
&lt;li&gt;The previous fuel-related state overwrites the newly reduced HP.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Time ──────────────────────────────────&amp;gt;

Unity
HP = 100
   │
   ├── Submit STEP request
   │
   ├── Apply water
   │
   ├── HP decreases
   │
   ├── Receive earlier simulation result
   │
   └── HP overwritten by older state


CFAST
   │
   ├── Receive STEP request
   │
   ├── Calculate previous input conditions
   │
   └── Return simulation result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The result was that repeated water application did not always accumulate correctly.&lt;/p&gt;

&lt;p&gt;This was not a failure of the CFAST combustion equations.&lt;/p&gt;

&lt;p&gt;It was a software state management problem caused by updating related information at different times.&lt;/p&gt;

&lt;p&gt;Similar problems occur in embedded systems, asynchronous network communication, distributed applications, and multi-threaded software.&lt;/p&gt;


&lt;h2&gt;
  
  
  10. Fixing the State Management Problem
&lt;/h2&gt;

&lt;p&gt;The solution was to distinguish between the current gameplay state and the accepted simulation state.&lt;/p&gt;

&lt;p&gt;The following information must be managed separately:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Current Unity fire HP&lt;/li&gt;
&lt;li&gt;Latest water damage&lt;/li&gt;
&lt;li&gt;Accepted CFAST fuel state&lt;/li&gt;
&lt;li&gt;Submitted STEP request&lt;/li&gt;
&lt;li&gt;Corresponding accepted STEP response&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A CFAST response belongs to the simulation request that generated it.&lt;/p&gt;

&lt;p&gt;It must not overwrite newer gameplay changes simply because it arrives later.&lt;/p&gt;
&lt;h3&gt;
  
  
  Revised State Ownership
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UNITY GAMEPLAY STATE
──────────────────────────
Current Fire HP
Latest Water Damage
Extinguishing State
          │
          │ Fire Input
          ▼
CFAST SIMULATION STATE
──────────────────────────
Requested HRR
Actual HRR
Pyrolysis
Accepted Fuel State
          │
          │ Accepted Response
          ▼
STATE RECONCILIATION
──────────────────────────
Validate Request Identity
Update Accepted Fuel State
Preserve Current Fire HP
Preserve Extinguishing State
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In the revised implementation, Unity retains the HP changes caused by water application.&lt;/p&gt;

&lt;p&gt;The accepted CFAST response updates the corresponding confirmed fuel state without discarding newer water damage.&lt;/p&gt;

&lt;p&gt;This also prevents an outdated response from restoring a fire that has already been extinguished.&lt;/p&gt;
&lt;h3&gt;
  
  
  Required Behaviors
&lt;/h3&gt;

&lt;p&gt;The implementation was designed to satisfy the following conditions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Water damage accumulates while a simulation request is pending.&lt;/li&gt;
&lt;li&gt;Older responses do not restore previous HP values.&lt;/li&gt;
&lt;li&gt;Duplicate responses do not apply the same update twice.&lt;/li&gt;
&lt;li&gt;A fire with zero HP is not restored by an outdated response.&lt;/li&gt;
&lt;li&gt;Existing reignition behavior is preserved.&lt;/li&gt;
&lt;li&gt;Accepted simulation results remain associated with their corresponding requests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The purpose of the change was to preserve the existing gameplay behavior while integrating asynchronous scientific calculation results.&lt;/p&gt;


&lt;h2&gt;
  
  
  11. Validation Results
&lt;/h2&gt;

&lt;p&gt;The revised state management implementation was tested in an isolated Stage02 ZERO scene.&lt;/p&gt;

&lt;p&gt;During the test, the acceptance of a CFAST response was deliberately delayed.&lt;/p&gt;

&lt;p&gt;Two water applications were then performed on each of the selected combustible objects.&lt;/p&gt;
&lt;h3&gt;
  
  
  Fire HP Retention
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Combustible Object&lt;/th&gt;
&lt;th&gt;Initial HP&lt;/th&gt;
&lt;th&gt;HP After Water Application&lt;/th&gt;
&lt;th&gt;HP After STEP Acceptance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hall floor&lt;/td&gt;
&lt;td&gt;100&lt;/td&gt;
&lt;td&gt;86.5&lt;/td&gt;
&lt;td&gt;86.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hall wallpaper&lt;/td&gt;
&lt;td&gt;180&lt;/td&gt;
&lt;td&gt;166.5&lt;/td&gt;
&lt;td&gt;166.5&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The reduced HP values remained unchanged after the corresponding CFAST response was accepted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hall Floor

Before water:       100.0
After water:         86.5
After CFAST reply:   86.5


Hall Wallpaper

Before water:       180.0
After water:        166.5
After CFAST reply:  166.5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This confirmed that the asynchronous response no longer erased the water damage in the tested conditions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Additional Validation
&lt;/h3&gt;

&lt;p&gt;A separate EditMode test suite covered the state management behavior.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Validation Item&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;EditMode tests&lt;/td&gt;
&lt;td&gt;49 passed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Older response handling&lt;/td&gt;
&lt;td&gt;Passed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Duplicate response handling&lt;/td&gt;
&lt;td&gt;Passed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Final extinguishing state&lt;/td&gt;
&lt;td&gt;Passed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Existing reignition behavior&lt;/td&gt;
&lt;td&gt;Passed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Independent code review&lt;/td&gt;
&lt;td&gt;PASS&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The tests were performed against the relevant implementation candidate.&lt;/p&gt;

&lt;p&gt;The subsequent Hall integration was incorporated into the production source code.&lt;/p&gt;

&lt;p&gt;These results establish the behavior within the tested scope rather than guaranteeing every possible gameplay sequence or hardware configuration.&lt;/p&gt;




&lt;h2&gt;
  
  
  12. Extinguishing Events and Zero-HRR Commands
&lt;/h2&gt;

&lt;p&gt;Another important design decision concerns the meaning of extinguishing a fire.&lt;/p&gt;

&lt;p&gt;In Stage02, Unity manages water hit detection, fire HP, and the final gameplay extinguishing decision.&lt;/p&gt;

&lt;p&gt;When the HP of a fire object reaches zero, Unity immediately records that object as extinguished.&lt;/p&gt;

&lt;p&gt;The next available STEP request specifies a requested HRR of zero watts for the corresponding CFAST fire sources.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Player Applies Water
          │
          ▼
Unity Water Hit Detection
          │
          ▼
Reduce Fire HP
          │
          ▼
     Is HP Zero?
       │     │
      No    Yes
       │     │
       │     ▼
       │   Confirm Gameplay
       │   Extinguishing State
       │     │
       │     ▼
       │   Send 0 W to CFAST
       │   in the Next STEP
       │     │
       └─────┴──&amp;gt; Continue State Updates
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Mapping an Extinguishing Event to Multiple Fire Sources
&lt;/h3&gt;

&lt;p&gt;The Hall floor is represented by two native fire sources.&lt;/p&gt;

&lt;p&gt;When Unity extinguishes the Hall floor, both corresponding fire source inputs are set to zero.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Unity Hall Floor
HP = 0
        │
        ├──&amp;gt; F2: Requested HRR = 0 W
        │
        └──&amp;gt; F3: Requested HRR = 0 W
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same principle applies to the Hall wallpaper.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Unity Hall Wallpaper
HP = 0
        │
        ├──&amp;gt; F4: Requested HRR = 0 W
        │
        └──&amp;gt; F5: Requested HRR = 0 W
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The zero-HRR command changes the prescribed fire and pyrolysis input.&lt;/p&gt;

&lt;p&gt;It does not represent a detailed simulation of water droplets, water evaporation, or direct cooling of the combustible material.&lt;/p&gt;

&lt;p&gt;Those phenomena would require additional physical models and corresponding input data.&lt;/p&gt;




&lt;h2&gt;
  
  
  13. Different Completion Conditions in Stage01 and Stage02
&lt;/h2&gt;

&lt;p&gt;During development, I also identified a difference between the existing Stage01 and Stage02 implementations.&lt;/p&gt;

&lt;p&gt;Stage01 contains a completion-wait mechanism for selected native fire sources.&lt;/p&gt;

&lt;p&gt;For example, after Unity records an extinguishing event for the sofa fire source, the game waits for a corresponding CFAST response confirming that the relevant actual and theoretical HRR values have reached zero.&lt;/p&gt;

&lt;p&gt;Stage02 uses a different completion condition.&lt;/p&gt;

&lt;p&gt;Its gameplay completion logic is based on the number of remaining active game fire objects.&lt;/p&gt;

&lt;p&gt;The CFAST zero-HRR response is not a mandatory stage completion condition.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Behavior&lt;/th&gt;
&lt;th&gt;Stage01 Selected Sources&lt;/th&gt;
&lt;th&gt;Stage02&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Unity water hit detection&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gameplay extinguishing state&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Zero-HRR input to CFAST&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Waiting for native fire-stop confirmation&lt;/td&gt;
&lt;td&gt;Yes, for selected sources&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gameplay completion&lt;/td&gt;
&lt;td&gt;Includes the relevant native confirmation&lt;/td&gt;
&lt;td&gt;Based on remaining game fire objects&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These differences are currently preserved.&lt;/p&gt;

&lt;p&gt;The existence of different implementations does not automatically mean that one of them is defective.&lt;/p&gt;

&lt;p&gt;Before introducing a unified completion mechanism, I would first need to determine whether that change is required by the game design.&lt;/p&gt;

&lt;p&gt;This became an important lesson in defining the scope of software development and acceptance testing.&lt;/p&gt;




&lt;h2&gt;
  
  
  14. Connecting Fire Sources, Doors, and Smoke Rendering
&lt;/h2&gt;

&lt;p&gt;The fire state is only one part of the simulated environment.&lt;/p&gt;

&lt;p&gt;Opening conditions also influence gas transport, smoke distribution, and oxygen availability.&lt;/p&gt;

&lt;p&gt;Stage02 now includes six interactive interior doors.&lt;/p&gt;

&lt;p&gt;The opening conditions are sent from Unity to CFAST, where the resulting compartment and gas transport calculations are performed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 PLAYER
                    │
       ┌────────────┴────────────┐
       │                         │
Water Application           Door Operation
       │                         │
       ▼                         ▼
Unity Fire State          Unity Opening State
       │                         │
       └────────────┬────────────┘
                    │
                    ▼
             CFAST WORKER
                    │
       ┌────────────┼────────────┐
       │            │            │
 Combustion      Gas Layers    Gas Transport
 Fuel State      Optical       Flow Rate
 Actual HRR      Density       Flow Direction
       │            │            │
       ▼            ▼            ▼
 Fire Rendering  Indoor Smoke  Opening Smoke
 Fuel Updates    Rendering     Rendering
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The objective is to make gameplay interactions change the simulation inputs rather than merely triggering predefined effects.&lt;/p&gt;

&lt;p&gt;For example, opening a door creates a possible gas transport path between compartments.&lt;/p&gt;

&lt;p&gt;The actual amount and direction of gas transport are determined by the CFAST calculation.&lt;/p&gt;

&lt;p&gt;Applying water changes the gameplay fire state and subsequently changes the corresponding fire input.&lt;/p&gt;

&lt;p&gt;The calculated smoke and gas conditions are then visualized in Unity.&lt;/p&gt;

&lt;p&gt;This provides a connection between gameplay events and the evolving simulated environment.&lt;/p&gt;




&lt;h2&gt;
  
  
  15. AI-Assisted Development and Acceptance Criteria
&lt;/h2&gt;

&lt;p&gt;This project is being developed with the assistance of OpenAI Codex.&lt;/p&gt;

&lt;p&gt;I use separate implementation and review roles to support software development, investigation, and testing.&lt;/p&gt;

&lt;p&gt;However, integrating a scientific simulation into a game revealed an additional challenge in AI-assisted engineering.&lt;/p&gt;

&lt;p&gt;AI agents can introduce validation requirements for functionality that has never been designed or approved.&lt;/p&gt;

&lt;p&gt;For example, the following behaviors were initially considered during testing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Smoke exhaust after complete extinguishment&lt;/li&gt;
&lt;li&gt;Post-fire cooling&lt;/li&gt;
&lt;li&gt;Oxygen recovery after extinguishment&lt;/li&gt;
&lt;li&gt;Waiting for every zero-HRR response before allowing stage completion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Although some of these phenomena may be relevant to scientific fire simulation, they were not all defined as independent gameplay acceptance requirements.&lt;/p&gt;

&lt;p&gt;Treating their absence as an implementation failure caused unnecessary investigation and repeated testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Revised Development Policy
&lt;/h3&gt;

&lt;p&gt;I therefore established a clearer distinction between approved requirements and proposed functionality.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PASS&lt;/td&gt;
&lt;td&gt;An approved requirement is satisfied.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;FAIL&lt;/td&gt;
&lt;td&gt;An approved requirement is not satisfied, or a regression exists.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BLOCKED&lt;/td&gt;
&lt;td&gt;A required verification cannot be completed because of a concrete blocker.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NOT_RUN&lt;/td&gt;
&lt;td&gt;An applicable verification has not been executed.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;The functionality is outside the current scope.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PROPOSAL&lt;/td&gt;
&lt;td&gt;A proposed feature or design change requiring approval.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;An undesigned feature should not automatically result in a failed acceptance test.&lt;/p&gt;

&lt;p&gt;However, if an unexpected behavior prevents an existing approved feature from working, that impact must still be investigated.&lt;/p&gt;

&lt;h3&gt;
  
  
  Development Workflow
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Potential Requirement or Issue
              │
              ▼
     Is It Required by the Game?
              │
        ┌─────┴─────┐
        │           │
       No          Yes
        │           │
        ▼           ▼
  Outside Scope   Additional Design
                    │
                    ▼
             Developer Approval
                    │
                    ▼
              Implementation
                    │
                    ▼
                  Testing
                    │
                    ▼
            Independent Review
                    │
                    ▼
              Final Acceptance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;AI makes it possible to perform extensive source code investigations and generate large numbers of tests.&lt;/p&gt;

&lt;p&gt;But the number of tests is not itself a measure of software quality.&lt;/p&gt;

&lt;p&gt;The engineering objective must remain clear.&lt;/p&gt;

&lt;p&gt;The purpose of testing is to validate the intended software behavior, not to expand the project indefinitely.&lt;/p&gt;




&lt;h2&gt;
  
  
  16. Current Implementation and Limitations
&lt;/h2&gt;

&lt;p&gt;The following table summarizes the development results discussed in this report.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Development Item&lt;/th&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Stateful CFAST integration&lt;/td&gt;
&lt;td&gt;Implemented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multiple native fire source mapping&lt;/td&gt;
&lt;td&gt;Implemented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Geometry-based fuel allocation&lt;/td&gt;
&lt;td&gt;Implemented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hall floor integration&lt;/td&gt;
&lt;td&gt;Integrated into production source&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hall wallpaper integration&lt;/td&gt;
&lt;td&gt;Integrated into production source&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Structural ceiling treatment&lt;/td&gt;
&lt;td&gt;Implemented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Independent native ceiling fuel source&lt;/td&gt;
&lt;td&gt;Not adopted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Asynchronous HP retention&lt;/td&gt;
&lt;td&gt;Implemented and validated&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Zero-HRR fire input&lt;/td&gt;
&lt;td&gt;Implemented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dynamic interior opening conditions&lt;/td&gt;
&lt;td&gt;Implemented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Independent code review&lt;/td&gt;
&lt;td&gt;Passed for the adopted Hall integration&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;There are also important limitations.&lt;/p&gt;

&lt;p&gt;The current implementation does not claim to reproduce every aspect of combustion or firefighting physics.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Water droplets and direct material cooling are not explicitly simulated by this CFAST input mechanism.&lt;/li&gt;
&lt;li&gt;The ceiling combustion investigation does not establish a validated physical ceiling fire model.&lt;/li&gt;
&lt;li&gt;The fuel allocation ratios are based on game geometry rather than material combustion experiments.&lt;/li&gt;
&lt;li&gt;Successful asynchronous state management tests do not guarantee every possible gameplay sequence.&lt;/li&gt;
&lt;li&gt;The corrected experimental plume worker must be distinguished from the existing production worker.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The purpose of this implementation is to improve simulation-driven gameplay and fire visualization.&lt;/p&gt;

&lt;p&gt;It is not a certified firefighting training system or a validated real-world fire prediction model.&lt;/p&gt;




&lt;h2&gt;
  
  
  17. Interactive Technical Documentation
&lt;/h2&gt;

&lt;p&gt;I have also prepared technical documentation on the project website.&lt;/p&gt;

&lt;p&gt;The website presents the CFAST and Unity integration through diagrams, animations, and interactive technical explanations.&lt;/p&gt;

&lt;h3&gt;
  
  
  CFAST × Unity Technical Guide
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html" rel="noopener noreferrer"&gt;CFAST and Unity Fire Simulation Technical Guide&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Stage02 Technical Validation
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html#stage02-validation" rel="noopener noreferrer"&gt;Stage02 — Numerical Stability, Smoke Rendering, and Opening Control&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The technical documentation covers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CFAST's two-zone simulation model&lt;/li&gt;
&lt;li&gt;Stateful communication between Unity and CFAST&lt;/li&gt;
&lt;li&gt;Compartment and opening geometry&lt;/li&gt;
&lt;li&gt;Indoor volumetric smoke rendering&lt;/li&gt;
&lt;li&gt;Smoke transport through openings&lt;/li&gt;
&lt;li&gt;DASSL numerical solver instability&lt;/li&gt;
&lt;li&gt;Building model corrections&lt;/li&gt;
&lt;li&gt;Smoke rendering optimization&lt;/li&gt;
&lt;li&gt;Interactive interior door control&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The website is primarily presented in Japanese, but includes visual diagrams and animations to explain the technical concepts.&lt;/p&gt;

&lt;p&gt;If you are interested in scientific computing, simulation-driven gameplay, real-time graphics, or AI-assisted software engineering, please take a look.&lt;/p&gt;




&lt;h2&gt;
  
  
  18. Conclusion
&lt;/h2&gt;

&lt;p&gt;Integrating a fire simulator into a game engine is not simply a matter of obtaining numerical data and displaying smoke.&lt;/p&gt;

&lt;p&gt;The integration must account for differences in system responsibilities, execution timing, state ownership, and physical modeling.&lt;/p&gt;

&lt;p&gt;The main engineering challenges discussed in this report were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mapping Unity combustible objects to multiple CFAST fire sources&lt;/li&gt;
&lt;li&gt;Allocating fuel without duplicating the original fuel budget&lt;/li&gt;
&lt;li&gt;Understanding the difference between requested and actual HRR&lt;/li&gt;
&lt;li&gt;Distinguishing combustion from prescribed fuel pyrolysis&lt;/li&gt;
&lt;li&gt;Investigating the limitations of ceiling fire source modeling&lt;/li&gt;
&lt;li&gt;Preventing asynchronous responses from overwriting current gameplay states&lt;/li&gt;
&lt;li&gt;Maintaining consistent extinguishing events&lt;/li&gt;
&lt;li&gt;Defining appropriate acceptance criteria for AI-assisted development&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As someone with experience in embedded software development, I find many similarities between this project and embedded systems engineering.&lt;/p&gt;

&lt;p&gt;Asynchronous communication, state machines, ownership boundaries, data consistency, and resource management are all important in both fields.&lt;/p&gt;

&lt;p&gt;Unity provides the interactive environment.&lt;/p&gt;

&lt;p&gt;CFAST provides the compartment-level fire simulation.&lt;/p&gt;

&lt;p&gt;The integration architecture connects these two systems while preserving their individual responsibilities.&lt;/p&gt;

&lt;p&gt;In the next development report, I will focus on how CFAST's numerical outputs are transformed into real-time smoke rendering inside Unity.&lt;/p&gt;

&lt;p&gt;That report will cover volumetric smoke, optical density, opening flow visualization, particle systems, and rendering performance optimization.&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://pages.nist.gov/cfast/" rel="noopener noreferrer"&gt;NIST CFAST Official Website&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/firemodels/cfast" rel="noopener noreferrer"&gt;CFAST Official GitHub Repository&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://doi.org/10.6028/NIST.TN.1889v1" rel="noopener noreferrer"&gt;CFAST Version 7 Technical Reference Guide&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/firemodels/cfast/tree/b43e74e0f43c704582c5782f5446597ce729a07f" rel="noopener noreferrer"&gt;CFAST Version 7.7.7 — Source Code Revision Used as the Development Baseline&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://pages.nist.gov/fds/" rel="noopener noreferrer"&gt;NIST Fire Dynamics Simulator and Smokeview&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  About the Project
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SOKYU: OPERATION RESCUE BLAZE SERIES&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An independently developed firefighting and disaster response game combining:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fire simulation&lt;/li&gt;
&lt;li&gt;Unity game development&lt;/li&gt;
&lt;li&gt;Scientific computing&lt;/li&gt;
&lt;li&gt;Real-time computer graphics&lt;/li&gt;
&lt;li&gt;Embedded systems&lt;/li&gt;
&lt;li&gt;Robotics&lt;/li&gt;
&lt;li&gt;Artificial intelligence&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Developed by &lt;strong&gt;Motomachi Digital Making Lab&lt;/strong&gt;, Yokohama, Japan.&lt;/p&gt;

&lt;p&gt;Project Technical Website:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html" rel="noopener noreferrer"&gt;https://ronsard.sakura.ne.jp/sokyu/cfast-guide.html&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;CFAST × Unity Development Report #2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;November 26, 2026&lt;/p&gt;

</description>
      <category>cfast</category>
      <category>nist</category>
      <category>unity3d</category>
    </item>
  </channel>
</rss>
