agentleFS
equinorequinor/neqsim/.github/skills/design-flash-benchmark/SKILL.md

design-flash-benchmark

Skill167 starsChanged 7 months agoApache-2.0View on GitHub

Create a structured test matrix for comparing flash algorithm performance

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create a structured test matrix for comparing flash algorithm performance across fluid types, thermodynamic conditions, and difficulty …

    line 11
  2. Distinctive:

    Add cases specifically designed to challenge the algorithm:

    line 65
  3. Distinctive:

    Use Dirichlet sampling to generate composition variants:

    line 77
  4. Distinctive:

    Every benchmark case must record:

    line 98

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skill: Design Flash Benchmark

Purpose

Create a structured test matrix for comparing flash algorithm performance across fluid types, thermodynamic conditions, and difficulty levels.

When to Use

  • Starting a new flash algorithm comparison study
  • Extending an existing benchmark to new fluid families
  • Designing stress tests for near-critical or multi-phase regions

Benchmark Design Procedure

Step 1: Select Fluid Families

Choose from these standard families:

FamilyComponentsMole FractionsCharacteristics
Lean gasCH4(0.90), C2(0.05), C3(0.03), N2(0.01), CO2(0.01)Fixed or ±10%Easy, mostly single-phase
Rich gasCH4(0.70), C2(0.10), C3(0.08), nC4(0.05), nC5(0.03), N2(0.02), CO2(0.02)Fixed or ±15%Moderate, clear two-phase
Gas condensateCH4(0.65), C2(0.08), C3(0.06), nC4(0.04), nC5(0.03), nC6(0.02), nC7(0.02), nC10(0.05), N2(0.02), CO2(0.03)±20%Near-critical behavior
CO2-richCO2(0.80), CH4(0.10), N2(0.05), H2S(0.03), C2(0.02)±15%Strong non-ideality
Wide-boilingCH4(0.50), nC4(0.15), nC10(0.15), nC16(0.10), nC20(0.10)±20%Large volatility range
Sour gasCH4(0.60), CO2(0.15), H2S(0.10), C2(0.08), C3(0.05), N2(0.02)±15%Acid gas behavior

Step 2: Define PT Space

For each family, define the pressure-temperature sampling grid:

import numpy as np

def generate_pt_grid(T_min_K, T_max_K, P_min_bara, P_max_bara, n_T=20, n_P=20):
    """Generate a regular PT grid."""
    T_values = np.linspace(T_min_K, T_max_K, n_T)
    P_values = np.logspace(np.log10(P_min_bara), np.log10(P_max_bara), n_P)
    cases = []
    for T in T_values:
        for P in P_values:
            cases.append({"T_K": float(T), "P_bara": float(P)})
    return cases

Standard ranges by family:

FamilyT range (K)P range (bara)Focus region
Lean gas200–4001–200Dew point region
Rich gas220–4505–300Two-phase dome
Gas condensate250–50010–500Near cricondenbar
CO2-rich250–40010–200CO2 critical region
Wide-boiling300–6001–100Large T range

Step 3: Add Stress Cases

Add cases specifically designed to challenge the algorithm:

  1. Near bubble point: T slightly above Tbub at given P
  2. Near dew point: T slightly below Tdew at given P
  3. Near critical: T ≈ Tc ± 5K, P ≈ Pc ± 5 bar
  4. Very low vapor fraction: β ≈ 0.001
  5. Very high vapor fraction: β ≈ 0.999
  6. Single phase (verification): Known single-phase conditions
  7. Trace components: One component at < 1e-6 mole fraction

Step 4: Define Composition Perturbation

Use Dirichlet sampling to generate composition variants:

from numpy.random import dirichlet

def perturb_composition(base_comp, n_variants=10, concentration=50):
    """Generate composition variants around a base composition.

    Higher concentration = less perturbation.
    """
    names = list(base_comp.keys())
    alpha = np.array([base_comp[n] for n in names]) * concentration
    variants = []
    for _ in range(n_variants):
        x = dirichlet(alpha)
        variants.append(dict(zip(names, x.tolist())))
    return variants

Step 5: Define Metrics

Every benchmark case must record:

MetricTypeUnitHow to Measure
convergedbool—Did the flash converge?
iterationsint—Total iterations (SS + NR)
ss_iterationsint—Successive substitution iterations only
nr_iterationsint—Newton-Raphson iterations only
cpu_time_msfloatmsWall-clock time (median of 3 runs)
residual_normfloat—Final norm of equilibrium residuals
stability_testedbool—Was stability analysis triggered?
stability_itersint—TPD minimization iterations
n_phasesint—Number of phases at equilibrium
beta_vaporfloat—Vapor phase fraction
phase_id_correctbool—Correct phase identification?

Step 6: Estimate Total Cases

Target: 500–2000 cases per algorithm version.

ComponentCases
6 families × 20 PT points120 base cases
10 composition variants each1200 cases
50 stress cases50 cases
Total~1250 cases

Step 7: Generate Config File

Output benchmark_config.json:

{
  "benchmark_id": "tpflash_2026_01",
  "created": "2026-03-31",
  "algorithms": ["baseline", "candidate_eigenvalue_switch"],
  "eos_models": ["SRK"],
  "timing_repeats": 3,
  "families": [
    {
      "name": "lean_gas",
      "base_composition": {"methane": 0.90, "ethane": 0.05, "propane": 0.03, "nitrogen": 0.01, "CO2": 0.01},
      "n_composition_variants": 10,
      "dirichlet_concentration": 50,
      "T_range_K": [200, 400],
      "P_range_bara": [1, 200],
      "n_T": 20,
      "n_P": 20
    }
  ],
  "stress_cases": {
    "near_critical": 20,
    "near_bubble": 10,
    "near_dew": 10,
    "trace_component": 10
  }
}

Checklist

  • All components available in NeqSim database
  • PT ranges cover the two-phase region for each family
  • Stress cases are well-defined
  • Metrics list is complete
  • Total case count is between 500 and 2000
  • Random seed is fixed for reproducibility

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.