Skip to content

Commit

Permalink
ref + docfix
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Jan 11, 2025
1 parent 08b95a3 commit 09c710d
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,5 @@ public void solve() {
} while (Math.abs((oldHeatFlux - heatFlux) / heatFlux) > 1e-6 && heatTransferCalc
&& iterInner < 50);
init();
// System.out.println("iterInner " +iterInner + " temp gas " +
// interphaseSystem.getTemperature(0)+ " temp liq " +
// interphaseSystem.getTemperature(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ public default boolean needRecalculation() {
* setController.
* </p>
*
* @param controller a {@link neqsim.process.controllerdevice.ControllerDeviceInterface}
* object
* @param controller a {@link neqsim.process.controllerdevice.ControllerDeviceInterface} object
*/
public void setController(ControllerDeviceInterface controller);

Expand Down Expand Up @@ -166,8 +165,7 @@ public default SystemInterface getFluid() {
* runConditionAnalysis.
* </p>
*
* @param refExchanger a
* {@link neqsim.process.equipment.ProcessEquipmentInterface} object
* @param refExchanger a {@link neqsim.process.equipment.ProcessEquipmentInterface} object
*/
public void runConditionAnalysis(ProcessEquipmentInterface refExchanger);

Expand Down Expand Up @@ -216,10 +214,10 @@ public default SystemInterface getFluid() {

/**
* <p>
* toJson.
* Serializes the Process Equipment along with its state to a JSON string.
* </p>
*
* @return a String
* @return json string.
*/
public String toJson();

Expand Down
33 changes: 26 additions & 7 deletions src/main/java/neqsim/process/equipment/tank/Tank.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package neqsim.process.equipment.tank;

import java.util.UUID;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.process.equipment.ProcessEquipmentBaseClass;
import neqsim.process.equipment.mixer.Mixer;
import neqsim.process.equipment.stream.Stream;
Expand All @@ -20,6 +22,8 @@
public class Tank extends ProcessEquipmentBaseClass {
/** Serialization version UID. */
private static final long serialVersionUID = 1000;
/** Logger object for class. */
static Logger logger = LogManager.getLogger(Tank.class);

SystemInterface thermoSystem;
SystemInterface gasSystem;
Expand Down Expand Up @@ -148,14 +152,29 @@ public StreamInterface getLiquid() {
return getLiquidOutStream();
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* <p>
* Calculates the following properties:
* <ul>
* <li>steelWallTemperature</li>
* <li>gasOutStream</li>
* <li>liquidOutStream</li>
* <li><code>thermoSystem</code> including properties</li>.
* <li>liquidLevel</li>
* <li>liquidVolume</li>
* <li>gasVolume</li>
* </ul>
* </p>
*/
@Override
public void run(UUID id) {
inletStreamMixer.run(id);
SystemInterface thermoSystem2 = inletStreamMixer.getOutletStream().getThermoSystem().clone();
ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem2);
ops.VUflash(thermoSystem2.getVolume(), thermoSystem2.getInternalEnergy());
System.out.println("Volume " + thermoSystem2.getVolume() + " internalEnergy "
logger.info("Volume " + thermoSystem2.getVolume() + " internalEnergy "
+ thermoSystem2.getInternalEnergy());
steelWallTemperature = thermoSystem2.getTemperature();
if (thermoSystem2.hasPhaseType("gas")) {
Expand All @@ -172,7 +191,7 @@ public void run(UUID id) {
thermoSystem = thermoSystem2.clone();
thermoSystem.setTotalNumberOfMoles(1.0e-10);
thermoSystem.init(1);
System.out.println("number of phases " + thermoSystem.getNumberOfPhases());
logger.info("number of phases " + thermoSystem.getNumberOfPhases());
for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) {
double relFact = gasVolume / (thermoSystem.getPhase(j).getVolume() * 1.0e-5);
if (j == 1) {
Expand All @@ -191,10 +210,10 @@ public void run(UUID id) {
thermoSystem.setBeta(1.0 - 1e-10);
}
thermoSystem.init(3);
System.out.println("moles in separator " + thermoSystem.getNumberOfMoles());
logger.info("moles in separator " + thermoSystem.getNumberOfMoles());
double volume1 = thermoSystem.getVolume();
System.out.println("volume1 bef " + volume1);
System.out.println("beta " + thermoSystem.getBeta());
logger.info("volume1 bef " + volume1);
logger.info("beta " + thermoSystem.getBeta());

if (thermoSystem2.getNumberOfPhases() == 2) {
liquidLevel = thermoSystem.getPhase(1).getVolume() * 1e-5 / (liquidVolume + gasVolume);
Expand All @@ -205,7 +224,7 @@ public void run(UUID id) {
getLiquidLevel() * 3.14 / 4.0 * separatorDiameter * separatorDiameter * separatorLength;
gasVolume = (1.0 - getLiquidLevel()) * 3.14 / 4.0 * separatorDiameter * separatorDiameter
* separatorLength;
System.out.println("moles out" + liquidOutStream.getThermoSystem().getTotalNumberOfMoles());
logger.info("moles out" + liquidOutStream.getThermoSystem().getTotalNumberOfMoles());

setCalculationIdentifier(id);
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/neqsim/thermo/component/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ public abstract class Component implements ComponentInterface {
/** Mole fraction of Component in Phase. */
protected double x = 0;
/**
* Number of moles of Component in System. <code>numberOfMoles = totalNumberOfMoles * z</code>.
* Number of moles of Component in System. Ideally
* <code>numberOfMoles = totalNumberOfMoles * z</code>.
*/
protected double numberOfMoles = 0.0;
/** Number of moles of Component in Phase. <code>totalNumberOfMoles * x * beta</code>. */
/** Number of moles of Component in Phase. Ideally <code>totalNumberOfMoles * x * beta</code>. */
protected double numberOfMolesInPhase = 0.0;
protected double K;

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/neqsim/thermo/phase/PhaseEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public abstract class PhaseEos extends Phase implements PhaseEosInterface {
public double delta1 = 0;
public double delta2 = 0;

protected EosMixingRules mixSelect = null;
protected EosMixingRules mixSelect = new EosMixingRules();
protected EosMixingRulesInterface mixRule = null;
double uEOS = 0;
double wEOS = 0;
Expand All @@ -63,7 +63,6 @@ public PhaseEos clone() {
* </p>
*/
public PhaseEos() {
mixSelect = new EosMixingRules();
componentArray = new ComponentEosInterface[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
mixRule = mixSelect.getMixingRule(1);
// solver = new newtonRhapson();
Expand Down
23 changes: 13 additions & 10 deletions src/main/java/neqsim/thermo/phase/PhaseInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public interface PhaseInterface extends ThermodynamicConstantsInterface, Cloneab

/**
* <p>
* setMoleFractions.
* Set <code>x</code> and normalize for all Components in phase.
* </p>
*
* @param x an array of type double
* @param x Mole fractions of component in a phase.
*/
public void setMoleFractions(double[] x);

Expand Down Expand Up @@ -690,8 +690,11 @@ public default void initPhysicalProperties(String name) {
public double getpH();

/**
* Normalize property <code>x</code>.
*
* <p>
* normalize.
* Property <code>x</code> is the mole fraction of a component in a specific phase. Normalizing,
* means that the sum of <code>x</code> for all Components in a phase equal 1.0.
* </p>
*/
public void normalize();
Expand Down Expand Up @@ -1280,10 +1283,10 @@ public default void setMixingRule(int mr) {

/**
* <p>
* getNumberOfMolesInPhase.
* Get the number of moles the phase contains.
* </p>
*
* @return a double
* @return The number of moles in the phase.
*/
public double getNumberOfMolesInPhase();

Expand Down Expand Up @@ -1723,7 +1726,7 @@ public default void setMixingRule(int mr) {

/**
* <p>
* dFdT.
* Calculate derivative of F per Temperature, i.e., dF/dT.
* </p>
*
* @return a double
Expand All @@ -1732,7 +1735,7 @@ public default void setMixingRule(int mr) {

/**
* <p>
* dFdV.
* Calculate derivative of F per Volume, i.e., dF/dV.
* </p>
*
* @return a double
Expand All @@ -1741,7 +1744,7 @@ public default void setMixingRule(int mr) {

/**
* <p>
* dFdTdV.
* Calculate derivative of F per Temperature and Volume, i.e., dF/dT * 1/dV.
* </p>
*
* @return a double
Expand Down Expand Up @@ -1818,8 +1821,8 @@ public default void setMixingRule(int mr) {
public double getLogInfiniteDiluteFugacity(int k);

/**
* Get mixing rule
*
* Get mixing rule.
*
* @return a MixingRulesInterface
*/
public MixingRulesInterface getMixingRule();
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/neqsim/thermo/system/SystemInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ public default int getPhaseNumberOfPhase(String phaseTypeName) {

/**
* <p>
* Getter for property <code>TC</code>.
* Get critical temperature.
* </p>
*
* @return Critical temperature
Expand All @@ -1488,13 +1488,14 @@ public default int getPhaseNumberOfPhase(String phaseTypeName) {

/**
* <p>
* method to return temperature.
* method to return temperature from a specific phase.
* </p>
*
* @param phaseNumber phase to get temperature of
* @return temperature in unit Kelvin
*/
public double getTemperature(int phaseNumber);
public double getTemperature(int phaseNumber); // TODO: is it possible for the phases to have
// different temperatures?

/**
* method to return temperature in a specified unit.
Expand Down Expand Up @@ -2119,9 +2120,10 @@ public default void prettyPrint() {
public void setAttractiveTerm(int i);

/**
* Setter for property <code>beta</code>.
* <p>
* Setter for property <code>beta</code>. NB! Sets beta = b for first phase and 1-b for second
* phase, not for multiphase systems.
* NB! Sets beta = b for first (heaviest) phase and 1-b for second (lightest) phase, not for
* multiphase systems.
* </p>
*
* @param b Beta value to set.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ public static SystemInterface read(String inputFile) {
}
}

// System.out.println(st);
fluid.setMixingRule(2);
fluid.useVolumeCorrection(true);
fluid.init(0);
Expand All @@ -385,8 +384,6 @@ public static SystemInterface read(String inputFile) {
}
}
}

// fluid.display();
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void TPSolidflash() {
}

/**
* Method to perform a flash at given temperature, pressure and specified volume The number of
* Method to perform a flash at given temperature, pressure and specified volume. The number of
* moles in the system are changed to match the specified volume.
*
* @param volumeSpec is the specified volume
Expand Down Expand Up @@ -1380,6 +1380,7 @@ public void constantPhaseFractionTemperatureFlash(double fraction) throws IsNaNE
fraction = 1.0 - 1.0e-10;
}
ConstantDutyFlashInterface operation = new ConstantDutyTemperatureFlash(system);
// TODO: bug, sum of beta will not equal 1
system.setBeta(1, fraction);
system.setBeta(0, fraction);
operation.run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void testGetTotalFlowRate() {
}

@Test
public void nmVOCFlowRateTest() {
public void testnmVOCFlowRate() {
process1.run();
Assertions.assertEquals(vocanalyser1.getMeasuredValue(), 10555.540704);
Assertions.assertEquals(vocanalyser1.getMeasuredValue("tonnes/year"), 10555.540704);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ public ProcessSystem createExpanderProcessModel(Separator dewPointScrubber2,
}

@Test
public void tesExpanderProcess() {
public void testExpanderProcess() {
// wellFluid.setMultiPhaseCheck(true);
ProcessSystem wellprocess = getWellStreamAndManifoldModel(wellFluid);
wellprocess.run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import neqsim.process.equipment.compressor.Compressor;
import neqsim.process.equipment.expander.Expander;
Expand All @@ -20,13 +21,11 @@ public class SalesGasAndStableOilTest extends neqsim.NeqSimTest {
File file = new File("src/test/java/neqsim/process/processmodel");
String fileFluid1 = file.getAbsolutePath() + "/feedfluid.e300";

@Disabled("No assertions")
@Test
public void testProcess() {
SystemInterface wellFluid = neqsim.thermo.util.readwrite.EclipseFluidReadWrite.read(fileFluid1);
// wellFluid.setMultiPhaseCheck(true);

neqsim.process.equipment.stream.Stream wellStream =
new neqsim.process.equipment.stream.Stream("HP well stream", wellFluid);
SystemInterface LPwellFLuid = wellFluid.clone();

Stream wellStreamHP = new neqsim.process.equipment.stream.Stream("HP well stream", wellFluid);
Expand Down

0 comments on commit 09c710d

Please sign in to comment.