Class JsonProcessExporter
java.lang.Object
neqsim.process.processmodel.JsonProcessExporter
Exports a
ProcessSystem to the JSON schema consumed by JsonProcessBuilder.
The exported JSON is round-trippable: ProcessSystem -> toJson() -> JsonProcessBuilder ->
ProcessSystem. Streams are serialized first, followed by equipment in topological order. Each
equipment unit references its inlet stream(s) by name using dot-notation for specific outlet
ports (e.g. "HP Sep.gasOut").
- Version:
- 1.0
- Author:
- Even Solbraa
-
Field Summary
FieldsModifier and TypeFieldDescriptionMap from equipment name to processed flag.private final IdentityHashMap<StreamInterface, String> Map from stream identity to the reference string that reaches it. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidBuilds a mapping from stream object identity to string reference.private voidexportBinaryInteractionParameters(com.google.gson.JsonObject fluidJson, SystemInterface fluid) Exports binary interaction parameters (kij) from the fluid's mixing rule.private com.google.gson.JsonObjectexportFluid(SystemInterface fluid) Exports a fluid (SystemInterface) to a JSON object matching the JsonProcessBuilder schema.private voidexportHeatExchangerInlets(com.google.gson.JsonObject json, HeatExchanger hx) Exports HeatExchanger inlets as an "inlets" array (shell-side + tube-side).private voidexportMixerInlets(com.google.gson.JsonObject json, Mixer mixer) Exports Mixer inlets as an "inlets" array.private com.google.gson.JsonObjectExports equipment-specific design properties (outlet pressure, efficiency, split factors etc.).private voidexportStreamProperties(com.google.gson.JsonObject json, StreamInterface stream) Exports Stream-specific properties: flowRate, temperature, pressure.private com.google.gson.JsonObjectExports a single equipment unit to a JSON object.private SystemInterfaceFinds the first feed stream's fluid for the fluid section.private StringGets the type name string for an equipment unit matching the JsonProcessBuilder type names.private StringmapModelName(String modelName) Maps internal NeqSim model names to the short identifiers used by JsonProcessBuilder.private voidMaps outlet streams of an equipment unit to their reference strings.toJson(ProcessSystem process) Exports a ProcessSystem to a JSON string that can be consumed byJsonProcessBuilder.build(String).toJson(ProcessSystem process, boolean prettyPrint) Exports a ProcessSystem to a JSON string.com.google.gson.JsonObjecttoJsonObject(ProcessSystem process) Exports a ProcessSystem to a JsonObject.
-
Field Details
-
streamRefMap
Map from stream identity to the reference string that reaches it. -
processed
-
-
Constructor Details
-
JsonProcessExporter
public JsonProcessExporter()
-
-
Method Details
-
toJson
Exports a ProcessSystem to a JSON string that can be consumed byJsonProcessBuilder.build(String).- Parameters:
process- the process system to export- Returns:
- JSON string in the JsonProcessBuilder schema
-
toJson
Exports a ProcessSystem to a JSON string.- Parameters:
process- the process system to exportprettyPrint- whether to format the JSON with indentation- Returns:
- JSON string in the JsonProcessBuilder schema
-
toJsonObject
Exports a ProcessSystem to a JsonObject.- Parameters:
process- the process system to export- Returns:
- JsonObject in the JsonProcessBuilder schema
-
buildStreamRefMap
Builds a mapping from stream object identity to string reference. Feed streams (top-level Stream objects) map to their name. Outlet streams from equipment map to "equipmentName.portName".- Parameters:
units- the ordered list of unit operations
-
mapOutletStreams
Maps outlet streams of an equipment unit to their reference strings.- Parameters:
unit- the equipment unit
-
findFeedFluid
Finds the first feed stream's fluid for the fluid section.- Parameters:
units- the ordered list of unit operations- Returns:
- the fluid from the first Stream, or null
-
exportFluid
Exports a fluid (SystemInterface) to a JSON object matching the JsonProcessBuilder schema.For characterized (TBP/plus) fractions, exports critical properties (Tc, Pc, acentric factor, molar mass, density) so the fluid can be reconstructed without the original E300/PVT source file. Binary interaction parameters (BICs) are exported when any non-zero value is present.
- Parameters:
fluid- the fluid to export- Returns:
- JsonObject with model, temperature, pressure, mixingRule, components, and optionally characterizedComponents and binaryInteractionParameters
-
exportBinaryInteractionParameters
private void exportBinaryInteractionParameters(com.google.gson.JsonObject fluidJson, SystemInterface fluid) Exports binary interaction parameters (kij) from the fluid's mixing rule. Only exports non-zero BICs to keep the JSON compact. The builder uses these to override the default database BICs when reconstructing the fluid.- Parameters:
fluidJson- the fluid JSON object to add BICs tofluid- the fluid system
-
mapModelName
-
exportUnit
Exports a single equipment unit to a JSON object.- Parameters:
unit- the equipment to export- Returns:
- JsonObject describing the unit, or null if the unit should be skipped
-
getTypeName
Gets the type name string for an equipment unit matching the JsonProcessBuilder type names.- Parameters:
unit- the equipment- Returns:
- the type name string
-
exportStreamProperties
Exports Stream-specific properties: flowRate, temperature, pressure.- Parameters:
json- the unit JSON object to populatestream- the stream to export
-
exportMixerInlets
Exports Mixer inlets as an "inlets" array.- Parameters:
json- the unit JSON objectmixer- the mixer
-
exportHeatExchangerInlets
Exports HeatExchanger inlets as an "inlets" array (shell-side + tube-side).- Parameters:
json- the unit JSON objecthx- the heat exchanger
-
exportProperties
Exports equipment-specific design properties (outlet pressure, efficiency, split factors etc.).- Parameters:
unit- the equipment- Returns:
- JsonObject with properties, or null if no properties to export
-