Skip to content

Update: Refactor Mixture and ChemicalSystem architecture for shared systems and faster thermo evaluation#1127

Merged
AlbertoCuadra merged 6 commits into
developfrom
update/core-arquitecture
Jun 1, 2026
Merged

Update: Refactor Mixture and ChemicalSystem architecture for shared systems and faster thermo evaluation#1127
AlbertoCuadra merged 6 commits into
developfrom
update/core-arquitecture

Conversation

@AlbertoCuadra
Copy link
Copy Markdown
Member

This update refactors the interaction between Mixture, ChemicalSystem, and the equilibrium solver to reduce unnecessary object copying, remove dependence on temperature-updated property matrices, and make mixture state handling more explicit. Mixture now owns its composition state in ChemicalSystem species order, while ChemicalSystem provides static species properties and stateless cached thermo evaluation routines.

1. Refactored ChemicalSystem static species data

ChemicalSystem now stores static species properties directly as vectors, avoiding repeated access through propertiesMatrix for data that does not depend on temperature.

  • Added static vectors for molecular weight, phase, formation enthalpy, formation internal energy, and temperature limits.
  • Renamed the initialization helper to setStaticSpeciesProperties.
  • Removed the temperature-dependent propertiesMatrix update path.
  • Added cached stateless thermo evaluators for the internal thermo combinations used by mixture and equilibrium calculations.

2. Refactored Mixture composition state

Mixture now stores composition internally as systemMoles, in full ChemicalSystem species order. Fuel and oxidizer compositions are also stored in full system order through systemMolesFuel and systemMolesOxidizer.

This avoids rebuilding composition from the old property matrix path and makes the state ownership clearer:

  • Mixture owns moles and thermodynamic state.
  • ChemicalSystem owns species data and thermo functions.
  • Public mole access remains through moles(mix), consistent with existing utility-style APIs.

3. Shared ChemicalSystem across mixture copies

Mixture copies no longer deep-copy the full ChemicalSystem. The copied mixture keeps its own state while sharing the same chemical system object.

This removes a major bottleneck in batch calculations, especially when many mixtures use the same species database and static thermo data.

4. Added productSpeciesSet for equilibrium calculations

Equilibrium calculations now use a compact product species set instead of copying or mutating a product-specific ChemicalSystem.

The new productSpeciesSet stores solver-local product species data and maps results back to full ChemicalSystem order using productVectorToSystemVector.

This also removes the need for post-equilibrium reshaping through copied systems and keeps the equilibrium solver working directly with compact local indices.

5. Improved thermo fast paths

Thermo evaluation now uses specific cached paths for the combinations required internally, such as h/cp/s, cp/s, h, and h/g. This avoids repeated property-name checks and unnecessary curve lookups in performance-critical equilibrium and mixture-update paths.

6. Benchmarking

𝗕𝗘𝗡𝗖𝗛𝗠𝗔𝗥𝗞 𝗥𝗘𝗣𝗢𝗥𝗧

𝗦𝘆𝘀𝘁𝗲𝗺 𝗜𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻

CT version    MATLAB version    OS version      CPU name      Clock speed    Cache L2    Cores
__________    ______________    __________    ____________    ___________    ________    _____

  1.2.9           R2025b          15.7.3      Apple M2 Pro        N/A         65536       10  

𝗕𝗲𝗻𝗰𝗵𝗺𝗮𝗿𝗸𝗶𝗻𝗴

 Module           Solver                Problem                             Filename                       Cases    Species    Tolerance    AvgTime
_________    _________________    ___________________    ______________________________________________    _____    _______    _________    _______

CT-EQUIL     EquilibriumSolver    TP                     run_validation_TP_Cantera_1                        100        17      1.00e-06     0.99623
CT-EQUIL     EquilibriumSolver    TP                     run_validation_TP_TEA_1                            300        12      1.00e-06      1.0656
CT-EQUIL     EquilibriumSolver    TP                     run_validation_TP_TEA_2                             90        26      1.00e-06     0.85821
CT-EQUIL     EquilibriumSolver    TP                     run_validation_TP_TEA_3                             90        26      1.00e-06     0.84749
CT-EQUIL     EquilibriumSolver    TP                     run_validation_TP_TEA_4                             90        26      1.00e-06       0.845
CT-EQUIL     EquilibriumSolver    TP                     run_validation_TP_CEA_1                            351        95      1.00e-06      1.2704
CT-EQUIL     EquilibriumSolver    TP                     run_validation_TP_CEA_2                            351        95      1.00e-06      1.1602
CT-EQUIL     EquilibriumSolver    TP                     run_validation_TP_CEA_3                            351        95      1.00e-06      1.0963
CT-EQUIL     EquilibriumSolver    TP                     run_validation_TP_CEA_4                            351        95      1.00e-06      1.0674
CT-EQUIL     EquilibriumSolver    TP                     run_validation_TP_CEA_5                            181       247      1.00e-06      1.1149
CT-EQUIL     EquilibriumSolver    TP                     run_validation_TP_CEA_6                            481       177      1.00e-06      2.4088
CT-EQUIL     EquilibriumSolver    TV                     run_validation_TV_CEA_1                            351        95      1.00e-06      1.1476
CT-EQUIL     EquilibriumSolver    TV                     run_validation_TV_CEA_2                            351       213      1.00e-06      1.3036
CT-EQUIL     EquilibriumSolver    HP                     run_validation_HP_CEA_1                            351        95      1.00e-03      1.7325
CT-EQUIL     EquilibriumSolver    HP                     run_validation_HP_CEA_2                            351        95      1.00e-03      1.5765
CT-EQUIL     EquilibriumSolver    HP                     run_validation_HP_CEA_3                            351        95      1.00e-03      1.5768
CT-EQUIL     EquilibriumSolver    HP                     run_validation_HP_CEA_4                            351        95      1.00e-03      1.5181
CT-EQUIL     EquilibriumSolver    EV                     run_validation_EV_CEA_1                            351        95      1.00e-03      1.5598
CT-EQUIL     EquilibriumSolver    SP                     run_validation_SP_CEA_1                            351        95      1.00e-03      2.3036
CT-EQUIL     EquilibriumSolver    SV                     run_validation_SV_CEA_1                            351        95      1.00e-03      2.1191
CT-SD        ShockSolver          SHOCK_I                run_validation_SHOCK_IONIZATION_CEA_1              260        51      1.00e-05      1.4967
CT-SD        ShockSolver          SHOCK_I                run_validation_SHOCK_IONIZATION_CEA_2              260        61      1.00e-05      1.4007
CT-SD        ShockSolver          SHOCK_R                run_validation_SHOCK_R_IONIZATION_CEA_1            225        51      1.00e-05      1.6958
CT-SD        ShockSolver          SHOCK_R                run_validation_SHOCK_R_IONIZATION_CEA_2            225        61      1.00e-05      1.7053
CT-SD        ShockSolver          SHOCK_POLAR            run_validation_SHOCK_POLAR_SDToolbox_1               4        11      1.00e-05      1.9753
CT-SD        ShockSolver          SHOCK_POLAR            run_validation_SHOCK_POLAR_SDToolbox_2               4        13      1.00e-05      2.0647
CT-SD        ShockSolver          SHOCK_PRANDTL_MEYER    run_validation_SHOCK_PRANDTL_MEYER_SDToolbox_1       1        11      1.00e-05      1.0363
CT-SD        ShockSolver          SHOCK_PRANDTL_MEYER    run_validation_SHOCK_PRANDTL_MEYER_SDToolbox_2      81        11      1.00e-05     0.86553
CT-SD        DetonationSolver     DET                    run_validation_DET_CEA_1                           351        95      1.00e-05      1.8997
CT-SD        DetonationSolver     DET                    run_validation_DET_CEA_2                           351       157      1.00e-05       2.239
CT-SD        DetonationSolver     DET                    run_validation_DET_CEA_3                           351        95      1.00e-05      1.6058
CT-SD        DetonationSolver     DET                    run_validation_DET_CEA_4                           351        95      1.00e-05      1.5008
CT-SD        DetonationSolver     DET_OVERDRIVEN         run_validation_DET_OVERDRIVEN_SDToolbox_1           91        25      1.00e-05       1.013
CT-SD        DetonationSolver     DET_POLAR              run_validation_DET_POLAR_SDToolbox_1                 5        30      1.00e-05      2.6464
CT-ROCKET    RocketSolver         ROCKET_FAC             run_validation_ROCKET_CEA_20                       351        97      1.00e-04      11.904
CT-ROCKET    RocketSolver         ROCKET_FAC             run_validation_ROCKET_CEA_21                       351        97      1.00e-04      10.227
CT-ROCKET    RocketSolver         ROCKET_FAC             run_validation_ROCKET_CEA_22                       351        12      1.00e-04      5.5691
CT-ROCKET    RocketSolver         ROCKET_FAC             run_validation_ROCKET_CEA_23                       351        97      1.00e-04      10.565
CT-ROCKET    RocketSolver         ROCKET_IAC             run_validation_ROCKET_CEA_24                       351        12      1.00e-04      2.8097
CT-ROCKET    RocketSolver         ROCKET_IAC             run_validation_ROCKET_CEA_25                       351        12      1.00e-04       1.745

𝗦𝘂𝗺𝗺𝗮𝗿𝘆 𝗕𝗲𝗻𝗰𝗵𝗺𝗮𝗿𝗸𝗶𝗻𝗴

 Module            Problem          GroupCount    sum_Cases    mean_Cases    sum_Species    mean_Species    sum_AvgTime    mean_AvgTime
_________    ___________________    __________    _________    __________    ___________    ____________    ___________    ____________

CT-EQUIL     TP                         11          2736         248.73          911           82.818         12.731          1.1573   
CT-EQUIL     TV                          2           702            351          308              154         2.4511          1.2256   
CT-EQUIL     HP                          4          1404            351          380               95          6.404           1.601   
CT-EQUIL     EV                          1           351            351           95               95         1.5598          1.5598   
CT-EQUIL     SP                          1           351            351           95               95         2.3036          2.3036   
CT-EQUIL     SV                          1           351            351           95               95         2.1191          2.1191   
CT-SD        SHOCK_I                     2           520            260          112               56         2.8974          1.4487   
CT-SD        SHOCK_R                     2           450            225          112               56         3.4011          1.7005   
CT-SD        SHOCK_POLAR                 2             8              4           24               12         4.0399            2.02   
CT-SD        SHOCK_PRANDTL_MEYER         2            82             41           22               11         1.9018          0.9509   
CT-SD        DET                         4          1404            351          442            110.5         7.2453          1.8113   
CT-SD        DET_OVERDRIVEN              1            91             91           25               25          1.013           1.013   
CT-SD        DET_POLAR                   1             5              5           30               30         2.6464          2.6464   
CT-ROCKET    ROCKET_FAC                  4          1404            351          303            75.75         38.265          9.5663   
CT-ROCKET    ROCKET_IAC                  2           702            351           24               12         4.5546          2.2773   

Add: include `non-ideal ` EoS capabilities and solve error bad initial guess
Solve: error updating thermo state with chemical equilibrium mixtures and error initial guess with ionized species at very low temperature
Update: improve performance `simplexDual` and solve minor bugs
@AlbertoCuadra AlbertoCuadra added the enhancement New feature or request label Jun 1, 2026
@github-project-automation github-project-automation Bot moved this to In progress in v2.0.0 Jun 1, 2026
@AlbertoCuadra AlbertoCuadra moved this to 2026 Q3 – Jul-Sep in Roadmap Jun 1, 2026
@AlbertoCuadra AlbertoCuadra moved this from 2026 Q3 – Jul-Sep to 2026 Q2 – Apr-Jun in Roadmap Jun 1, 2026
@AlbertoCuadra AlbertoCuadra merged commit b5a441a into develop Jun 1, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in v2.0.0 Jun 1, 2026
@AlbertoCuadra AlbertoCuadra deleted the update/core-arquitecture branch June 1, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: 2026 Q2 – Apr-Jun
Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant