Class EclipseFluidReadWrite
EclipseFluidReadWrite class.
- Version:
- $Id: $Id
- Author:
- asmund
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static org.apache.logging.log4j.LoggerLogger object for class.static StringConstantpseudoName="" -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddWaterToFluid(SystemInterface fluid, double waterKij) Add a water component to an existing fluid with specified binary interaction parameters.private static voidapplyLBCViscosityModel(SystemInterface fluid, double[] lbcParams) Apply LBC viscosity model with custom parameters to fluid.private static voidApply PFCT (Pedersen) viscosity model to all phases.private static double[][]Gets binary interaction parameters from fluid.private static StringgetEOSType(SystemInterface fluid) Determines the EOS type string for the fluid.private static double[]Get LBC parameters from fluid if LBC viscosity model is active.private static booleanCheck if PFCT (Pedersen) viscosity model is active on any phase.private static StringmapE300ComponentName(String name) Maps common E300 component aliases to NeqSim database component names.static SystemInterfaceread.static SystemInterfaceRead an Eclipse E300 fluid file and optionally add a water component.static SystemInterfaceRead an Eclipse E300 fluid file and optionally add a water component with a custom kij value.static SystemInterfaceread.static SystemInterfaceread.static SystemInterfaceRead an Eclipse E300 fluid file with a pseudo-name suffix and optionally add a water component.static SystemInterfaceRead an Eclipse E300 fluid file with a pseudo-name suffix and optionally add a water component with a custom kij value.static SystemInterfaceread(String inputFile, SystemInterface targetFluid) Read an Eclipse E300 fluid file and load components into the supplied fluid system, ignoring the EOS keyword in the file.static SystemInterfacereadE300File(String inputFile) readE300File.private static SystemInterfacereadImpl(String inputFile, SystemInterface forcedFluid) Internal implementation.private static StringReads a line from the given reader and strips '/' delimiter characters.static voidsetComposition(SystemInterface fluid, String inputFile) setComposition.static voidsetComposition(SystemInterface fluid, String inputFile, String pseudoNameIn) setComposition.private static StringshortenComponentName(String name) Shortens component names to E300 compatible format.static StringtoE300String(SystemInterface fluid) Convert a NeqSim fluid to Eclipse E300 format string.static StringtoE300String(SystemInterface fluid, double reservoirTempC) Convert a NeqSim fluid to Eclipse E300 format string.static voidwrite(SystemInterface fluid, String outputFile) Write a NeqSim fluid to Eclipse E300 compositional EOS file format.static voidwrite(SystemInterface fluid, String outputFile, double reservoirTempC) Write a NeqSim fluid to Eclipse E300 compositional EOS file format.static voidwrite(SystemInterface fluid, Path outputPath, double reservoirTempC) Write a NeqSim fluid to Eclipse E300 compositional EOS file format.private static voidwriteToWriter(SystemInterface fluid, Writer writer, double reservoirTempC) Internal method to write E300 content to a Writer.
-
Field Details
-
logger
static org.apache.logging.log4j.Logger loggerLogger object for class. -
pseudoName
ConstantpseudoName=""
-
-
Constructor Details
-
EclipseFluidReadWrite
public EclipseFluidReadWrite()
-
-
Method Details
-
mapE300ComponentName
Maps common E300 component aliases to NeqSim database component names.- Parameters:
name- component name read from the E300CNAMESsection- Returns:
- NeqSim database component name, or
nullwhen the component should be treated as a characterized TBP pseudo-fraction
-
setComposition
setComposition.
- Parameters:
fluid- aSystemInterfaceobjectinputFile- aStringobjectpseudoNameIn- aStringobject
-
setComposition
setComposition.
- Parameters:
fluid- aSystemInterfaceobjectinputFile- aStringobject
-
read
read.
- Parameters:
inputFile- aStringobjectpseudoNameIn- aStringobject- Returns:
- a
SystemInterfaceobject
-
read
Read an Eclipse E300 fluid file and load components into the supplied fluid system, ignoring the EOS keyword in the file. This allows any NeqSim EOS (e.g. SystemPrLeeKeslerEos) to be used with an E300 composition file that was written for a different EOS.Usage example:
SystemInterface fluid = new SystemPrLeeKeslerEos(288.15, 1.01325); EclipseFluidReadWrite.read(e300Path, fluid);
- Parameters:
inputFile- aStringobject — path to the E300 filetargetFluid- a pre-createdSystemInterfaceto populate- Returns:
- the same
targetFluidinstance, now populated with components and BIPs - Throws:
IllegalArgumentException- if the input file cannot be read
-
read
read.
- Parameters:
inputFile- aStringobject- Returns:
- a
SystemInterfaceobject - Throws:
IllegalArgumentException- if the input file does not exist or cannot be read
-
readLineClean
Reads a line from the given reader and strips '/' delimiter characters. Returns null if end-of-stream is reached, preventing NPE from calling replace on a null readLine() result.- Parameters:
br- the BufferedReader to read from- Returns:
- the line with '/' characters removed, or null at end of stream
- Throws:
IOException- if an I/O error occurs
-
readImpl
Internal implementation. IfforcedFluidis non-null it is used as the target (EOS keyword in file is ignored). Otherwise the EOS keyword drives fluid creation.- Parameters:
inputFile- path to the Eclipse E300 fluid fileforcedFluid- optional pre-created fluid to populate (null to auto-create from EOS keyword)- Returns:
- the populated fluid system
-
read
Read an Eclipse E300 fluid file and optionally add a water component.When
addWateris true and the fluid does not already contain water, a water component is added with zero mole fraction and binary interaction parameters (kij) of 0.5 against all other components. This matches the water parameterization used in PVTsim-generated E300 files (e.g., osebergfluid_water.e300). Multi-phase check is also enabled so that an aqueous phase can form.- Parameters:
inputFile- path to the Eclipse E300 fluid fileaddWater- if true, add a water component with default kij = 0.5- Returns:
- a
SystemInterfaceobject - Throws:
IllegalArgumentException- if the input file does not exist or cannot be read
-
read
Read an Eclipse E300 fluid file and optionally add a water component with a custom kij value.When
addWateris true and the fluid does not already contain water, a water component is added with zero mole fraction and the specified binary interaction parameter (kij) against all other components. Multi-phase check is enabled so that an aqueous phase can form.- Parameters:
inputFile- path to the Eclipse E300 fluid fileaddWater- if true, add a water componentwaterKij- binary interaction parameter between water and all other components (typical value: 0.5)- Returns:
- a
SystemInterfaceobject - Throws:
IllegalArgumentException- if the input file does not exist or cannot be read
-
read
Read an Eclipse E300 fluid file with a pseudo-name suffix and optionally add a water component.- Parameters:
inputFile- path to the Eclipse E300 fluid filepseudoNameIn- pseudo-name suffix appended to pseudo-component namesaddWater- if true, add a water component with default kij = 0.5- Returns:
- a
SystemInterfaceobject - Throws:
IllegalArgumentException- if the input file does not exist or cannot be read
-
read
public static SystemInterface read(String inputFile, String pseudoNameIn, boolean addWater, double waterKij) Read an Eclipse E300 fluid file with a pseudo-name suffix and optionally add a water component with a custom kij value.- Parameters:
inputFile- path to the Eclipse E300 fluid filepseudoNameIn- pseudo-name suffix appended to pseudo-component namesaddWater- if true, add a water componentwaterKij- binary interaction parameter between water and all other components- Returns:
- a
SystemInterfaceobject - Throws:
IllegalArgumentException- if the input file does not exist or cannot be read
-
addWaterToFluid
Add a water component to an existing fluid with specified binary interaction parameters.This method adds water as a component with zero mole fraction to a fluid that was typically read from an E300 file without water. The water component is added with standard NeqSim water properties from the component database, a specified kij value against all other components (default: 0.5), a volume correction constant of 0.084004, and a parachor parameter of 10.0 (matching PVTsim water calibration). Multi-phase check is enabled so that an aqueous phase can be identified.
If the fluid already contains a water component, this method does nothing.
- Parameters:
fluid- the fluid to add water towaterKij- binary interaction parameter between water and all other components (typical value: 0.5)
-
read
read.
- Parameters:
inputFile- aStringobject representing the path to the input filefluidNames- an array ofStringobjects representing the names of the fluids- Returns:
- a
SystemInterfaceobject representing the thermodynamic system - Throws:
IllegalArgumentException- if the input file does not exist or cannot be read
-
readE300File
readE300File.
- Parameters:
inputFile- aStringobject- Returns:
- a
SystemInterfaceobject - Throws:
IllegalArgumentException- if the input file does not exist or cannot be read
-
write
Write a NeqSim fluid to Eclipse E300 compositional EOS file format.The exported file contains all EOS parameters needed to recreate the fluid in Eclipse 300 or read it back into NeqSim, including: component names, critical properties, acentric factors, molecular weights, volume shifts, parachors, mole fractions, and binary interaction coefficients.
- Parameters:
fluid- the fluid to exportoutputFile- path to output file (e.g., "myfluid.e300")- Throws:
IOException- if writing fails
-
write
public static void write(SystemInterface fluid, String outputFile, double reservoirTempC) throws IOException Write a NeqSim fluid to Eclipse E300 compositional EOS file format.- Parameters:
fluid- the fluid to exportoutputFile- path to output filereservoirTempC- reservoir temperature in Celsius for RTEMP keyword- Throws:
IOException- if writing fails
-
write
public static void write(SystemInterface fluid, Path outputPath, double reservoirTempC) throws IOException Write a NeqSim fluid to Eclipse E300 compositional EOS file format.- Parameters:
fluid- the fluid to exportoutputPath- output file pathreservoirTempC- reservoir temperature in Celsius- Throws:
IOException- if writing fails
-
toE300String
Convert a NeqSim fluid to Eclipse E300 format string.- Parameters:
fluid- the fluid to export- Returns:
- E300 format content as string
-
toE300String
Convert a NeqSim fluid to Eclipse E300 format string.- Parameters:
fluid- the fluid to exportreservoirTempC- reservoir temperature in Celsius- Returns:
- E300 format content as string
-
writeToWriter
private static void writeToWriter(SystemInterface fluid, Writer writer, double reservoirTempC) throws IOException Internal method to write E300 content to a Writer.- Parameters:
fluid- the fluid to exportwriter- output writerreservoirTempC- reservoir temperature in Celsius- Throws:
IOException- if writing fails
-
isPFCTViscosityModelActive
Check if PFCT (Pedersen) viscosity model is active on any phase.- Parameters:
fluid- the fluid- Returns:
- true if PFCT viscosity model is active
-
getEOSType
Determines the EOS type string for the fluid.- Parameters:
fluid- the fluid- Returns:
- EOS type string (SRK, PR, etc.)
-
shortenComponentName
-
getBinaryInteractionParameters
Gets binary interaction parameters from fluid.- Parameters:
fluid- the fluid- Returns:
- 2D array of kij values
-
applyLBCViscosityModel
Apply LBC viscosity model with custom parameters to fluid.- Parameters:
fluid- the fluid to configurelbcParams- array of 5 LBC dense contribution parameters
-
applyPFCTViscosityModel
Apply PFCT (Pedersen) viscosity model to all phases.- Parameters:
fluid- the fluid to configure
-
getLBCParametersFromFluid
Get LBC parameters from fluid if LBC viscosity model is active.- Parameters:
fluid- the fluid- Returns:
- array of 5 LBC parameters, or null if not using LBC model
-