Skip to content

Commit

Permalink
add more elements in element database (#808)
Browse files Browse the repository at this point in the history
* gas turbine update

* update

* update

* fix error method name
  • Loading branch information
EvenSol authored Aug 8, 2023
1 parent b4367be commit 9b5fbe4
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ public void run(UUID id) {
locHeater.run(id);

double moleMethane = outStreamAir.getFluid().getComponent("methane").getNumberOfmoles();
// double moleEthane = outStreamAir.getFluid().getComponent("ethane").getNumberOfmoles();
// double molePropane = outStreamAir.getFluid().getComponent("propane").getNumberOfmoles();
// double moleEthane =
// outStreamAir.getFluid().getComponent("ethane").getNumberOfmoles();
// double molePropane =
// outStreamAir.getFluid().getComponent("propane").getNumberOfmoles();
locHeater.getOutletStream().getFluid().addComponent("CO2", moleMethane);
locHeater.getOutletStream().getFluid().addComponent("water", moleMethane * 2.0);
locHeater.getOutletStream().getFluid().addComponent("methane", -moleMethane);
Expand All @@ -192,4 +194,46 @@ public void run(UUID id) {
this.heat = cooler1.getDuty();
setCalculationIdentifier(id);
}

/**
*
*
* <p>
* calcIdealAirGasRatio
* </p>
* Calculates ideal air fuel ratio [kg air/kg fuel]
*/
public double calcIdealAirFuelRatio() {
thermoSystem = inStream.getThermoSystem().clone();
double elementsH = 0.0;
double elementsC = 0.0;
double sumHC = 0.0;
double molMassHC = 0.0;
double wtFracHC = 0.0;
for (int i = 0; i < thermoSystem.getNumberOfComponents(); i++) {
if (thermoSystem.getComponent(i).isHydrocarbon()) {
sumHC += thermoSystem.getComponent(i).getz();
molMassHC +=
thermoSystem.getComponent(i).getz() * thermoSystem.getComponent(i).getMolarMass();
elementsC += thermoSystem.getComponent(i).getz()
* thermoSystem.getComponent(i).getElements().getNumberOfElements("C");
elementsH += thermoSystem.getComponent(i).getz()
* thermoSystem.getComponent(i).getElements().getNumberOfElements("H");
}

}
if (sumHC < 1e-100) {
return 0.0;
} else {
wtFracHC = molMassHC / thermoSystem.getMolarMass();
molMassHC /= sumHC;
elementsC /= sumHC;
elementsH /= sumHC;
}
double A = elementsC + elementsH / 4;

double AFR = A * (32.0 + 3.76 * 28.0) / 1000.0 / molMassHC * wtFracHC;
return AFR;
}

}
6 changes: 6 additions & 0 deletions src/main/java/neqsim/thermo/atomElement/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ public String[] getElementNames() {
* @return NumberOfElements of a given type.
*/
public double getNumberOfElements(String elementName) {
if (nameArray == null) {
neqsim.util.exception.InvalidInputException ex =
new neqsim.util.exception.InvalidInputException(this, "getNumberOfElements", elementName,
"component not in element database..");
throw new RuntimeException(ex);
}
for (int i = 0; i < nameArray.length; i++) {
if (nameArray[i].equals(elementName)) {
return coefArray[i];
Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/data/element.csv
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,18 @@
73,"methane","C",1
74,"methane","H",4
75,"oxygen","O",2
76,"ethane","C",2
77,"ethane","H",6
78,"propane","C",3
79,"propane","H",8
80,"n-butane","C",4
81,"n-butane","H",10
82,"i-butane","C",4
83,"i-butane","H",10
82,"n-pentane","C",5
83,"n-pentane","H",12
82,"i-pentane","C",5
83,"i-pentane","H",12
82,"n-hexane","C",6
83,"n-hexane","H",14
82,"nitrogen","N",2
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package neqsim.processSimulation.processEquipment.powerGeneration;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.Assertions;
Expand Down Expand Up @@ -35,8 +36,7 @@ void testSetInletStream() {
}

@Test
void testGetMechanicalDesign() {
}
void testGetMechanicalDesign() {}

@Disabled
@Test
Expand All @@ -51,4 +51,31 @@ void testRun() {
logger.info("power generated " + gasturb.getPower() / 1.0e6);
logger.info("heat generated " + gasturb.getHeat() / 1.0e6);
}

@Test
void testIdealAiFuelRatio() {

testSystem = new SystemSrkEos(298.15, 1.0);
testSystem.addComponent("nitrogen", 1.0);
testSystem.addComponent("CO2", 2.0);
testSystem.addComponent("methane", 92.0);
testSystem.addComponent("ethane", 4.0);
testSystem.addComponent("propane", 2.0);
testSystem.addComponent("i-butane", 0.5);
testSystem.addComponent("n-butane", 0.5);
testSystem.addComponent("n-pentane", 0.01);
testSystem.addComponent("i-pentane", 0.01);
testSystem.addComponent("n-hexane", 0.001);

gasStream = new Stream("turbine stream", testSystem);
gasStream.setFlowRate(1.0, "MSm3/day");
gasStream.setTemperature(50.0, "C");
gasStream.setPressure(2.0, "bara");

GasTurbine gasturb = new GasTurbine("turbine");
gasturb.setInletStream(gasStream);
double AFR = gasturb.calcIdealAirFuelRatio();
assertEquals(15.8430086719654, AFR, 0.0001);

}
}

0 comments on commit 9b5fbe4

Please sign in to comment.