Class DexpiSimulationBuilder
java.lang.Object
neqsim.process.processmodel.dexpi.DexpiSimulationBuilder
High-level builder that converts a DEXPI P&ID XML file into a runnable NeqSim
ProcessSystem.
Usage:
SystemInterface fluid = new SystemSrkEos(298.15, 50.0);
fluid.addComponent("methane", 0.9);
fluid.addComponent("ethane", 0.1);
fluid.setMixingRule("classic");
ProcessSystem process = new DexpiSimulationBuilder(new File("plant.xml")).setFluidTemplate(fluid)
.setFeedPressure(50.0, "bara").setFeedTemperature(30.0, "C").setFeedFlowRate(1.0, "MSm3/day")
.build();
process.run();
The builder performs these steps:
- Parse the DEXPI XML document securely (XXE protection)
- Resolve topology (nozzle/connection graph)
- Identify equipment and piping components with their sizing attributes
- Create a feed stream from the fluid template
- Walk the topology in upstream-to-downstream order, instantiating real NeqSim equipment via
DexpiEquipmentFactory - Wire outlet streams of upstream equipment to inlet of downstream equipment
- Optionally auto-instrument the process with transmitters and PID controllers
- Version:
- 1.0
- Author:
- NeqSim
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate final Fileprivate doubleprivate Stringprivate doubleprivate Stringprivate doubleprivate Stringprivate SystemInterfaceprivate static final org.apache.logging.log4j.Loggerprivate boolean -
Constructor Summary
ConstructorsConstructorDescriptionDexpiSimulationBuilder(File dexpiFile) Creates a new simulation builder for the given DEXPI XML file. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidapplyAutoInstrumentation(ProcessSystem processSystem, List<DexpiInstrumentInfo> dexpiInstruments) Applies auto-instrumentation using the DynamicProcessHelper, then logs associations between DEXPI instrument tags and auto-generated transmitters/controllers.build()Builds the NeqSimProcessSystemfrom the DEXPI XML file.private Map<String, DexpiProcessUnit> buildUnitMap(Document document, DexpiTopologyResolver.ResolvedTopology topology) Builds a map of equipment ID to DexpiProcessUnit with sizing attributes populated.private static StringgetGenericAttribute(Element element, String attributeName) Reads a GenericAttribute value from the given element.private SystemInterfaceReturns the fluid template, creating a default if none was set.private StreamInterfacegetOutletStream(ProcessEquipmentInterface equipment) Gets the outlet stream from a process equipment instance.private List<DexpiInstrumentInfo> parseDexpiInstruments(Document document) Parses DEXPI instrument info from the XML document.private static DocumentparseDocument(InputStream inputStream, boolean nsAware) Parses a DEXPI XML document with security hardening.setAutoInstrument(boolean autoInstrument) Enables automatic instrumentation (transmitters and PID controllers) on separators, compressors, and heat exchangers.setFeedFlowRate(double flowRate, String unit) Sets the feed stream flow rate.setFeedPressure(double pressure, String unit) Sets the feed stream pressure.setFeedTemperature(double temperature, String unit) Sets the feed stream temperature.setFluidTemplate(SystemInterface fluidTemplate) Sets the thermodynamic fluid template to use for all streams.setNamespaceAware(boolean namespaceAware) Enables namespace-aware XML parsing.
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger -
dexpiFile
-
fluidTemplate
-
feedPressure
private double feedPressure -
feedPressureUnit
-
feedTemperature
private double feedTemperature -
feedTemperatureUnit
-
feedFlowRate
private double feedFlowRate -
feedFlowRateUnit
-
autoInstrument
private boolean autoInstrument -
namespaceAware
private boolean namespaceAware
-
-
Constructor Details
-
DexpiSimulationBuilder
Creates a new simulation builder for the given DEXPI XML file.- Parameters:
dexpiFile- the DEXPI XML file to process
-
-
Method Details
-
setFluidTemplate
Sets the thermodynamic fluid template to use for all streams. If not set, a default methane/ethane system with SRK EOS is used.- Parameters:
fluidTemplate- the fluid system to clone for each stream- Returns:
- this builder for chaining
-
setFeedPressure
Sets the feed stream pressure.- Parameters:
pressure- the pressure valueunit- the pressure unit (e.g. "bara", "barg", "psia")- Returns:
- this builder for chaining
-
setFeedTemperature
Sets the feed stream temperature.- Parameters:
temperature- the temperature valueunit- the temperature unit (e.g. "C", "K", "F")- Returns:
- this builder for chaining
-
setFeedFlowRate
Sets the feed stream flow rate.- Parameters:
flowRate- the flow rate valueunit- the flow rate unit (e.g. "MSm3/day", "kg/hr")- Returns:
- this builder for chaining
-
setAutoInstrument
Enables automatic instrumentation (transmitters and PID controllers) on separators, compressors, and heat exchangers.- Parameters:
autoInstrument- true to enable auto-instrumentation- Returns:
- this builder for chaining
-
setNamespaceAware
Enables namespace-aware XML parsing. When enabled, the parser will respect namespace prefixes in element names. By default, namespace awareness is disabled for compatibility with DEXPI files that may use local names without namespace declarations.- Parameters:
namespaceAware- true to enable namespace-aware parsing- Returns:
- this builder for chaining
-
build
Builds the NeqSimProcessSystemfrom the DEXPI XML file.- Returns:
- a fully wired ProcessSystem ready for
process.run() - Throws:
IOException- if the file cannot be readDexpiXmlReaderException- if the XML cannot be parsed
-
buildUnitMap
private Map<String, DexpiProcessUnit> buildUnitMap(Document document, DexpiTopologyResolver.ResolvedTopology topology) Builds a map of equipment ID to DexpiProcessUnit with sizing attributes populated.- Parameters:
document- the parsed XML documenttopology- the resolved topology- Returns:
- map of equipment ID to DexpiProcessUnit
-
getOutletStream
Gets the outlet stream from a process equipment instance.- Parameters:
equipment- the equipment- Returns:
- the outlet stream, or null if not available
-
applyAutoInstrumentation
private void applyAutoInstrumentation(ProcessSystem processSystem, List<DexpiInstrumentInfo> dexpiInstruments) Applies auto-instrumentation using the DynamicProcessHelper, then logs associations between DEXPI instrument tags and auto-generated transmitters/controllers.- Parameters:
processSystem- the process system to instrumentdexpiInstruments- the DEXPI instrument info list (may be empty)
-
parseDexpiInstruments
Parses DEXPI instrument info from the XML document.- Parameters:
document- the parsed XML document- Returns:
- list of DEXPI instrument info records (may be empty)
-
getOrCreateFluidTemplate
Returns the fluid template, creating a default if none was set.- Returns:
- the fluid template
-
parseDocument
private static Document parseDocument(InputStream inputStream, boolean nsAware) throws DexpiXmlReaderException Parses a DEXPI XML document with security hardening.- Parameters:
inputStream- the input streamnsAware- whether to enable namespace-aware parsing- Returns:
- the parsed Document
- Throws:
DexpiXmlReaderException- if parsing fails
-
getGenericAttribute
-