Skip to content

Commit

Permalink
work on standards (#805)
Browse files Browse the repository at this point in the history
* work on standards

* add getter for number of elements

* update

* update

* update

* update
  • Loading branch information
EvenSol authored Aug 7, 2023
1 parent 2250f53 commit b4367be
Show file tree
Hide file tree
Showing 12 changed files with 150 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class PressureDrop extends ThrottlingValve {
* <p>
* Constructor for PressureDrop.
* </p>
*
* @param name the name of the pressure drop unit
*/
public PressureDrop(String name) {
super(name);
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/neqsim/standards/Standard.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public abstract class Standard extends NamedBaseClass implements StandardInterfa
protected SystemInterface thermoSystem;
protected ThermodynamicOperations thermoOps;
private String referenceState = "real"; // "ideal"real
private double referencePressure = 70.0;

/**
* Constructor for Standard.
Expand Down Expand Up @@ -197,4 +198,12 @@ public String getReferenceState() {
public void setReferenceState(String referenceState) {
this.referenceState = referenceState;
}

public void setReferencePressure(double referencePressure) {
this.referencePressure = referencePressure;
}

public double getReferencePressure(){
return referencePressure;
}
}
2 changes: 2 additions & 0 deletions src/main/java/neqsim/standards/StandardInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,6 @@ public interface StandardInterface {
* @param resultTable an array of {@link java.lang.String} objects
*/
public void setResultTable(String[][] resultTable);

public void setReferencePressure(double referencePressure);
}
6 changes: 2 additions & 4 deletions src/main/java/neqsim/standards/gasQuality/Draft_ISO18453.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
public class Draft_ISO18453 extends neqsim.standards.Standard {
private static final long serialVersionUID = 1L;
static Logger logger = LogManager.getLogger(Draft_ISO18453.class);

String dewPointTemperatureUnit = "C";
String pressureUnit = "bar";
double dewPointTemperature = 273.0;
double dewPointTemperatureSpec = -12.0;
double specPressure = 70.0;
double initTemperature = 273.15;
SystemInterface thermoSystem;
ThermodynamicOperations thermoOps;
Expand All @@ -41,7 +39,7 @@ public Draft_ISO18453(SystemInterface thermoSystem) {
this.thermoSystem = thermoSystem;
} else {
// System.out.println("setting model GERG water...");
this.thermoSystem = new SystemGERGwaterEos(initTemperature, specPressure);
this.thermoSystem = new SystemGERGwaterEos(initTemperature, getReferencePressure());
for (int i = 0; i < thermoSystem.getPhase(0).getNumberOfComponents(); i++) {
this.thermoSystem.addComponent(thermoSystem.getPhase(0).getComponent(i).getName(),
thermoSystem.getPhase(0).getComponent(i).getNumberOfmoles());
Expand All @@ -61,7 +59,7 @@ public Draft_ISO18453(SystemInterface thermoSystem) {
@Override
public void calculate() {
this.thermoSystem.setTemperature(initTemperature);
this.thermoSystem.setPressure(specPressure);
this.thermoSystem.setPressure(getReferencePressure());

try {
this.thermoOps.waterDewPointTemperatureFlash();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
*/
public class GasChromotograpyhBase extends neqsim.standards.Standard {
private static final long serialVersionUID = 1L;
String componentName = "", unit = "mol%";
String unit = "mol%";

/**
* <p>
* Constructor for GasChromotograpyhBase.
* </p>
*
* @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object
* @param component a {@link java.lang.String} object
*
*/
public GasChromotograpyhBase(SystemInterface thermoSystem, String component) {
super("gas cromotography", "Gas composition", thermoSystem);
this.componentName = component;
public GasChromotograpyhBase(SystemInterface thermoSystem) {
super("gas chromotography", "Gas composition", thermoSystem);
}


/** {@inheritDoc} */
@Override
public void calculate() {
Expand All @@ -36,7 +36,7 @@ public void calculate() {

/** {@inheritDoc} */
@Override
public double getValue(String returnParameter, java.lang.String returnUnit) {
public double getValue(String componentName, java.lang.String returnUnit) {
unit = returnUnit;
if (returnUnit.equals("mol%")) {
return 100 * thermoSystem.getPhase(0).getComponent(componentName).getz();
Expand All @@ -50,7 +50,7 @@ public double getValue(String returnParameter, java.lang.String returnUnit) {

/** {@inheritDoc} */
@Override
public double getValue(String returnParameter) {
public double getValue(String componentName) {
return thermoSystem.getPhase(0).getComponent(componentName).getz();
}

Expand Down
27 changes: 27 additions & 0 deletions src/main/java/neqsim/standards/gasQuality/Standard_ISO6974.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package neqsim.standards.gasQuality;

import neqsim.thermo.system.SystemInterface;

/**
* <p>
* Standard_ISO6974 class.
* </p>
*
* @author ESOL
* @version $Id: $Id
*/
public class Standard_ISO6974 extends GasChromotograpyhBase {
private static final long serialVersionUID = 1L;

/**
* <p>
* Constructor for Standard_ISO6974.
* </p>
*
* @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object
*/
public Standard_ISO6974(SystemInterface thermoSystem) {
super(thermoSystem);
setName("ISO6974");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
public class SulfurSpecificationMethod extends neqsim.standards.Standard {
private static final long serialVersionUID = 1L;
SystemInterface thermoSystem;
String unit = "ppm";
double H2Scontent = 0.0;

Expand All @@ -37,12 +36,24 @@ public void calculate() {
@Override
public double getValue(String returnParameter, java.lang.String returnUnit) {
thermoSystem.init(0);
if (thermoSystem.getPhase(0).hasComponent("H2S")) {
if (returnParameter.equals("H2S content")) {
if (returnParameter.equals("H2S")) {
if (thermoSystem.getPhase(0).hasComponent("H2S")) {
H2Scontent = thermoSystem.getPhase(0).getComponent("H2S").getx() * 1e6;
return H2Scontent;
} else {
return 0.0;
}
}
if (returnParameter.equals("Total sulfur")) {
double sulfurcontent = 0.0;
if (thermoSystem.getPhase(0).hasComponent("H2S")) {
sulfurcontent += thermoSystem.getPhase(0).getComponent("H2S").getx() * 1e6;
}
if (thermoSystem.getPhase(0).hasComponent("SO2")) {
sulfurcontent += thermoSystem.getPhase(0).getComponent("So2").getx() * 1e6;
}
return sulfurcontent;
}
return 0.0;
}

Expand Down
27 changes: 14 additions & 13 deletions src/main/java/neqsim/standards/salesContract/BaseContract.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import neqsim.standards.gasQuality.BestPracticeHydrocarbonDewPoint;
import neqsim.standards.gasQuality.Draft_ISO18453;
import neqsim.standards.gasQuality.GasChromotograpyhBase;
import neqsim.standards.gasQuality.Standard_ISO6974;
import neqsim.standards.gasQuality.Standard_ISO6976;
import neqsim.standards.gasQuality.SulfurSpecificationMethod;
import neqsim.standards.gasQuality.UKspecifications_ICF_SI;
Expand Down Expand Up @@ -82,13 +83,14 @@ public BaseContract(SystemInterface system, String terminal, String country) {
while (dataSet.next()) {
numb++;
StandardInterface method = getMethod(system, dataSet.getString("METHOD"));
double referencePressure = Double.parseDouble(dataSet.getString("ReferencePbar"));
method.setReferencePressure(referencePressure);
spesifications.add(getSpecification(method, dataSet.getString("NAME"),
dataSet.getString("SPECIFICATION"), dataSet.getString("COUNTRY"),
dataSet.getString("TERMINAL"), Double.parseDouble(dataSet.getString("MINVALUE")),
Double.parseDouble(dataSet.getString("MAXVALUE")), dataSet.getString("UNIT"),
Double.parseDouble(dataSet.getString("ReferenceTdegC")),
Double.parseDouble(dataSet.getString("ReferenceTdegC")),
Double.parseDouble(dataSet.getString("ReferencePbar")), ""));// dataSet.getString("Comments"));
Double.parseDouble(dataSet.getString("ReferenceTdegC")), referencePressure, ""));// dataSet.getString("Comments"));
System.out.println(dataSet.getString("Comments"));
System.out.println("specification added..." + numb);
}
Expand All @@ -110,19 +112,18 @@ public BaseContract(SystemInterface system, String terminal, String country) {
*/
public StandardInterface getMethod(SystemInterface system, String methodName) {
if (methodName.equals("ISO18453")) {
Draft_ISO18453 standard = new Draft_ISO18453(system);
standard.setReferencePressure(specificationsNumber);
return new Draft_ISO18453(system);
}
if (methodName.equals("CO2")) {
return new GasChromotograpyhBase(system, "CO2");
}
if (methodName.equals("H2S")) {
return new GasChromotograpyhBase(system, "H2S");
if (methodName.equals("ISO6974")) {
return new Standard_ISO6974(system);
}
if (methodName.equals("Total sulphur")) {
return new GasChromotograpyhBase(system, "H2S");
return new GasChromotograpyhBase(system);
}
if (methodName.equals("oxygen")) {
return new GasChromotograpyhBase(system, "oxygen");
return new Standard_ISO6974(system);
}
if (methodName.equals("ISO6976")) {
return new Standard_ISO6976(system);
Expand Down Expand Up @@ -180,12 +181,12 @@ public void runCheck() {
logger.error(ex.getMessage(), ex);
}
spesification.getStandard().setSalesContract(this);
System.out.println("Type: " + spesification.getDescription() + " Standard "
System.out.println("Type: " + spesification.getSpecification() + " Standard "
+ spesification.getStandard().getName() + " : "
+ spesification.getStandard().isOnSpec());
getResultTable()[j][0] = spesification.getDescription();
getResultTable()[j][1] = Double.toString(
spesification.getStandard().getValue(spesification.getName(), spesification.getUnit()));
getResultTable()[j][0] = spesification.getSpecification();
getResultTable()[j][1] = Double.toString(spesification.getStandard()
.getValue(spesification.getSpecification(), spesification.getUnit()));
getResultTable()[j][2] = spesification.getCountry();
getResultTable()[j][3] = spesification.getTerminal();
getResultTable()[j][4] = Double.toString(spesification.getMinValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class ContractSpecification extends NamedBaseClass {
private static final long serialVersionUID = 1L;
StandardInterface standard = null;
String description = "dew point temperature specification";
String specification = "dew point temperature specification";
private String country = "";
private String terminal = "";
private double minValue = 0;
Expand All @@ -31,7 +31,9 @@ public class ContractSpecification extends NamedBaseClass {

@Deprecated
/**
* <p>Constructor for ContractSpecification.</p>
* <p>
* Constructor for ContractSpecification.
* </p>
*/
public ContractSpecification() {
super("ContractSpecification");
Expand All @@ -43,7 +45,7 @@ public ContractSpecification() {
* </p>
*
* @param name a {@link java.lang.String} object
* @param description a {@link java.lang.String} object
* @param specification a {@link java.lang.String} object
* @param country a {@link java.lang.String} object
* @param terminal a {@link java.lang.String} object
* @param standard a {@link neqsim.standards.StandardInterface} object
Expand All @@ -55,14 +57,14 @@ public ContractSpecification() {
* @param referencePressure a double
* @param comments a {@link java.lang.String} object
*/
public ContractSpecification(String name, String description, String country, String terminal,
public ContractSpecification(String name, String specification, String country, String terminal,
StandardInterface standard, double minValue, double maxValue, String unit,
double referenceTemperature, double referenceTemperatureComb, double referencePressure,
String comments) {
super(name);
this.country = country;
this.terminal = terminal;
this.description = description;
this.specification = specification;
this.standard = standard;
this.unit = unit;
this.setReferenceTemperatureMeasurement(referenceTemperature);
Expand Down Expand Up @@ -92,21 +94,21 @@ public void setStandard(neqsim.standards.StandardInterface standard) {
}

/**
* Getter for property description.
* Getter for property specification.
*
* @return Value of property description.
* @return Value of property specification.
*/
public java.lang.String getDescription() {
return description;
public java.lang.String getSpecification() {
return specification;
}

/**
* Setter for property description.
* Setter for property specification.
*
* @param description New value of property description.
* @param specification New value of property description.
*/
public void setDescription(java.lang.String description) {
this.description = description;
public void setSpecification(java.lang.String specification) {
this.specification = specification;
}

/**
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/neqsim/thermo/atomElement/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ public String[] getElementNames() {
return nameArray;
}

/**
* GetNumberOfElements.
*
* @param elementName name of element
* @return NumberOfElements of a given type.
*/
public double getNumberOfElements(String elementName) {
for (int i = 0; i < nameArray.length; i++) {
if (nameArray[i].equals(elementName)) {
return coefArray[i];
}
}
return 0.0;
}

/**
* Getter for property coefArray.
*
Expand Down
12 changes: 10 additions & 2 deletions src/main/resources/commercial/GASCONTRACTSPECIFICATIONS.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
1,"Contract1","NORWAY",,"hydrocarbondewpointTemperature",-1000.000000000,-10.000000000,"degC","StatoilBestPracticeHydrocarbonDewPoint",0.000000000,70.000000000,"",
2,"Contract1","NORWAY",,"GCV",30000.000000000,40000.000000000,"kJ/Sm^3","ISO6976",0.000000000,1.013250000,"reference temperature of compustion=0C and reference temperature volume=15C"
3,"Contract1","NORWAY",,"H2S content",0.000000000,5.000000000,"ppm","SulfurSpecificationMethod",0.000000000,1.013250000,"",
4,"Contract1","NORWAY",,"Total sulfur content",0.000000000,30.000000000,"microg/Sm3","SulfurSpecificationMethod",0.000000000,1.013250000,"",
4,"Contract1","NORWAY",,"Total sulfur",0.000000000,30.000000000,"microg/Sm3","SulfurSpecificationMethod",0.000000000,1.013250000,"",
5,"Contract1","NORWAY",,"SuperiorWobbeIndex",20000.000000000,40000.000000000,"kJ/Sm^3","ISO6976",0.000000000,1.013250000,"",
6,"Contract1","NORWAY",,"RelativeDensity",0.600000000,1.000000000,"kg/Sm^3","ISO6976",0.000000000,1.013250000,"",
7,"Contract1","UK","UK-GSMR1996","waterdewpointTemperature",-1000.000000000,-10.000000000,"degC","ISO18453",0.000000000,70.000000000,"",
7,"Contract1","UK","UK-GSMR1996","waterdewpointTemperature",-1000.000000000,-10.000000000,"degC","ISO18453",0.000000000,70.000000000,"",
8,"ANP","Brazil","central","waterdewpointTemperature",-1000,-45.000000000,"degC","ISO18453",0.000000000,1.000000000,"ISO6327/ASTM5454",
9,"ANP","Brazil","central","CO2",0.0,3.0,"mol%","ISO6974",0.000000000,1.000000000,"ASTM1945",
10,"ANP","Brazil","central","methane",85.0,100.0,"mol%","ISO6974",0.000000000,1.000000000,"ASTM1945",
11,"ANP","Brazil","central","ethane",0.0,12.0,"mol%","ISO6974",0.000000000,1.000000000,"ASTM1945",
12,"ANP","Brazil","central","propane",0.0,5.0,"mol%","ISO6974",0.000000000,1.000000000,"ASTM1945",
13,"ANP","Brazil","central","GCV",30000.000000000,40000.000000000,"kJ/Sm^3","ISO6976",0.000000000,1.013250000,"reference temperature of compustion=0C and reference temperature volume=15C"
3,"ANP","Brazil","central","H2S",0.000000000,5.000000000,"ppm","SulfurSpecificationMethod",0.000000000,1.013250000,"",
4,"ANP","Brazil","central","Total sulfur",0.000000000,30.000000000,"microg/Sm3","SulfurSpecificationMethod",0.000000000,1.013250000,"",
Loading

0 comments on commit b4367be

Please sign in to comment.