Class StandardsRunner

java.lang.Object
neqsim.mcp.runners.StandardsRunner

public class StandardsRunner extends Object
Stateless standards calculation runner for MCP integration.

Supports gas quality standards (ISO 6976, AGA, GPA, EN) and oil quality standards (ASTM, BSW). Each standard returns its results (heating value, Wobbe index, density, distillation curve, etc.) in the standard JSON envelope format.

Version:
1.0
Author:
Even Solbraa
  • Field Details

    • GSON

      private static final com.google.gson.Gson GSON
    • SUPPORTED_STANDARDS

      private static final List<String> SUPPORTED_STANDARDS
  • Constructor Details

    • StandardsRunner

      private StandardsRunner()
      Private constructor — all methods are static.
  • Method Details

    • getSupportedStandards

      public static List<String> getSupportedStandards()
      Returns the list of supported standard calculation types.
      Returns:
      unmodifiable list of standard names
    • run

      public static String run(String json)
      Runs a standards calculation from a JSON input string.
      Parameters:
      json - the JSON specification with fluid and standard selection
      Returns:
      a JSON string with status and calculations per the selected standard
    • runStandard

      private static com.google.gson.JsonObject runStandard(SystemInterface fluid, String standard, com.google.gson.JsonObject input)
      Routes to the appropriate standard calculation.
      Parameters:
      fluid - the initialized fluid system
      standard - the standard name
      input - the full JSON input for standard-specific parameters
      Returns:
      JSON object with standard results
    • runISO6976

      private static com.google.gson.JsonObject runISO6976(SystemInterface fluid, com.google.gson.JsonObject input, boolean use2016)
      Runs ISO 6976 gas quality calculation.
      Parameters:
      fluid - the initialized fluid
      input - the JSON input with optional reference conditions
      use2016 - whether to use the 2016 edition
      Returns:
      JSON with calorific values, Wobbe index, density
    • runAGA3

      private static com.google.gson.JsonObject runAGA3(SystemInterface fluid, com.google.gson.JsonObject input)
      Runs AGA 3 orifice metering calculation.
      Parameters:
      fluid - the initialized fluid
      input - the JSON input with metering parameters
      Returns:
      JSON with flow rate and metering results
    • runASTM_D86

      private static com.google.gson.JsonObject runASTM_D86(SystemInterface fluid, com.google.gson.JsonObject input)
      Runs ASTM D86 distillation curve calculation.
      Parameters:
      fluid - the initialized fluid
      input - the JSON input
      Returns:
      JSON with distillation curve and temperatures
    • runGenericGasStandard

      private static com.google.gson.JsonObject runGenericGasStandard(SystemInterface fluid, String standardName)
      Runs a generic gas quality standard calculation.
      Parameters:
      fluid - the initialized fluid
      standardName - the standard name for factory lookup
      Returns:
      JSON with standard results
    • runGenericOilStandard

      private static com.google.gson.JsonObject runGenericOilStandard(SystemInterface fluid, String standardName)
      Runs a generic oil quality standard calculation.
      Parameters:
      fluid - the initialized fluid
      standardName - the standard name suffix (e.g. D445, D2500, BSW)
      Returns:
      JSON with standard results
    • createFluid

      private static SystemInterface createFluid(String model, double tempK, double pBara)
      Creates a fluid system for the given EOS model.
      Parameters:
      model - EOS model name
      tempK - temperature in Kelvin
      pBara - pressure in bara
      Returns:
      the fluid system
    • parseTemperature

      private static double parseTemperature(com.google.gson.JsonElement element)
      Parses temperature from JSON element.
      Parameters:
      element - the JSON element
      Returns:
      temperature in Kelvin
    • parsePressure

      private static double parsePressure(com.google.gson.JsonElement element)
      Parses pressure from JSON element.
      Parameters:
      element - the JSON element
      Returns:
      pressure in bara
    • errorJson

      private static String errorJson(String code, String message, String remediation)
      Creates a standard error JSON string.
      Parameters:
      code - the error code
      message - the error message
      remediation - the fix suggestion
      Returns:
      the error JSON string
    • createGasStandard

      private static StandardInterface createGasStandard(String name, SystemInterface fluid)
      Creates a gas quality standard instance by name.
      Parameters:
      name - the standard name (e.g. "ISO6976", "AGA3")
      fluid - the fluid system
      Returns:
      the standard instance, or null if not found
    • createOilStandard

      private static StandardInterface createOilStandard(String name, SystemInterface fluid)
      Creates an oil quality standard instance by name.
      Parameters:
      name - the standard name (e.g. "ASTM_D86", "BSW")
      fluid - the fluid system
      Returns:
      the standard instance, or null if not found