Skip to content

Commit

Permalink
Formatting (#541)
Browse files Browse the repository at this point in the history
* refact: autoformatting and fix of checkstyle violations
  • Loading branch information
asmfstatoil authored and EvenSol committed Oct 4, 2022
1 parent bce8f2b commit 12eb1b9
Show file tree
Hide file tree
Showing 10 changed files with 371 additions and 340 deletions.
18 changes: 11 additions & 7 deletions src/main/java/neqsim/thermodynamicOperations/flashOps/PHflash.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,18 @@ public double calcdQdT() {
* @return a double
*/
public double solveQ() {
double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature();
double oldTemp = 1.0 / system.getTemperature();
double nyTemp = 1.0 / system.getTemperature();
double iterations = 1;
double error = 1.0, erorOld = 1.0e10;
double error = 1.0;
double erorOld = 1.0e10;
double factor = 0.8;
double newCorr = 1.0;
system.init(2);
boolean correctFactor = true;

double maxTemperature = 1e10, minTemperature = 0.0;

double maxTemperature = 1e10;
double minTemperature = 0.0;
do {
if (Math.abs(error) > Math.abs(erorOld) && factor > 0.1 && correctFactor) {
factor *= 0.5;
Expand Down Expand Up @@ -144,9 +146,11 @@ public double solveQ() {
* @return a double
*/
public double solveQ2() {
double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature();
double oldTemp = 1.0 / system.getTemperature();
double nyTemp = 1.0 / system.getTemperature();
double iterations = 1;
double error = 1.0, erorOld = 1.0e10;
double error = 1.0;
double erorOld = 1.0e10;
double factor = 0.8;
double newCorr = 1.0;
system.init(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,18 @@ public double calcdQdT() {
* @return a double
*/
public double solveQ() {
double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature();
double oldTemp = 1.0 / system.getTemperature();
double nyTemp = 1.0 / system.getTemperature();
double iterations = 1;
double error = 1.0, erorOld = 1.0e10;
double error = 1.0;
double erorOld = 1.0e10;
double factor = 0.8;
double newCorr = 1.0;
system.init(2);
boolean correctFactor = true;

double maxTemperature = 1e10, minTemperature = 0.0;

double maxTemperature = 1e10;
double minTemperature = 0.0;
do {
if (Math.abs(error) > Math.abs(erorOld) && factor > 0.1 && correctFactor) {
factor *= 0.5;
Expand All @@ -97,8 +99,7 @@ public double solveQ() {
oldTemp = nyTemp;
double[] gergProps = system.getPhase(0).getProperties_GERG2008();
cP_GERG2008 = gergProps[10] * system.getPhase(0).getNumberOfMolesInPhase(); // J/mol K
enthalpy_GERG2008 = gergProps[7] * system.getPhase(0).getNumberOfMolesInPhase(); // J/mol
// K
enthalpy_GERG2008 = gergProps[7] * system.getPhase(0).getNumberOfMolesInPhase(); // J/mol K
newCorr = factor * calcdQdT() / calcdQdTT();
nyTemp = oldTemp - newCorr;
if (Math.abs(system.getTemperature() - 1.0 / nyTemp) > 10.0) {
Expand Down Expand Up @@ -152,9 +153,11 @@ public double solveQ() {
* @return a double
*/
public double solveQ2() {
double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature();
double oldTemp = 1.0 / system.getTemperature();
double nyTemp = 1.0 / system.getTemperature();
double iterations = 1;
double error = 1.0, erorOld = 1.0e10;
double error = 1.0;
double erorOld = 1.0e10;
double factor = 0.8;
double newCorr = 1.0;
system.init(2);
Expand Down
194 changes: 98 additions & 96 deletions src/main/java/neqsim/thermodynamicOperations/flashOps/PUflash.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,109 +11,111 @@
* @version $Id: $Id
*/
public class PUflash extends Flash {
private static final long serialVersionUID = 1000;
private static final long serialVersionUID = 1000;

double Uspec = 0;
Flash tpFlash;
double Uspec = 0;
Flash tpFlash;

/**
* <p>
* Constructor for PUflash.
* </p>
*/
public PUflash() {}
/**
* <p>
* Constructor for PUflash.
* </p>
*/
public PUflash() {}

/**
* <p>
* Constructor for PUflash.
* </p>
*
* @param system a {@link neqsim.thermo.system.SystemInterface} object
* @param Uspec a double
*/
public PUflash(SystemInterface system, double Uspec) {
this.system = system;
this.tpFlash = new TPflash(system);
this.Uspec = Uspec;
}
/**
* <p>
* Constructor for PUflash.
* </p>
*
* @param system a {@link neqsim.thermo.system.SystemInterface} object
* @param Uspec a double
*/
public PUflash(SystemInterface system, double Uspec) {
this.system = system;
this.tpFlash = new TPflash(system);
this.Uspec = Uspec;
}

/**
* <p>
* calcdQdTT.
* </p>
*
* @return a double
*/
public double calcdQdTT() {
double dQdTT = -system.getTemperature() * system.getTemperature() * system.getCv();
return dQdTT;
}
/**
* <p>
* calcdQdTT.
* </p>
*
* @return a double
*/
public double calcdQdTT() {
double dQdTT = -system.getTemperature() * system.getTemperature() * system.getCv();
return dQdTT;
}

/**
* <p>
* calcdQdT.
* </p>
*
* @return a double
*/
public double calcdQdT() {
double dQ = system.getInternalEnergy() - Uspec;
return dQ;
}
/**
* <p>
* calcdQdT.
* </p>
*
* @return a double
*/
public double calcdQdT() {
double dQ = system.getInternalEnergy() - Uspec;
return dQ;
}

/**
* <p>
* solveQ.
* </p>
*
* @return a double
*/
public double solveQ() {
double oldTemp = 1.0 / system.getTemperature(), nyTemp = 1.0 / system.getTemperature();
double iterations = 1;
double error = 1.0, erorOld = 10.0e10;
double factor = 0.8;
do {
if (error > erorOld) {
factor /= 2.0;
} else if (error < erorOld && factor < 0.8) {
factor *= 1.1;
}
iterations++;
oldTemp = nyTemp;
system.init(2);
nyTemp = oldTemp - factor * calcdQdT() / calcdQdTT();
// f(Math.abs(1.0/nyTemp-1.0/oldTemp)>5.0) nyTemp = 1.0/(1.0/oldTemp +
// Math.signum(1.0/nyTemp-1.0/oldTemp)*5.0);
if (Double.isNaN(nyTemp)) {
nyTemp = oldTemp + 1.0;
}
system.setTemperature(1.0 / nyTemp);
tpFlash.run();
erorOld = error;
error = Math.abs((1.0 / nyTemp - 1.0 / oldTemp) / (1.0 / oldTemp));
// System.out.println("error " + error);
// System.out.println("temperature " + system.getTemperature() + " " +
// iterations);
} while (error > 1e-8 && iterations < 500);
/**
* <p>
* solveQ.
* </p>
*
* @return a double
*/
public double solveQ() {
double oldTemp = 1.0 / system.getTemperature();
double nyTemp = 1.0 / system.getTemperature();
double iterations = 1;
double error = 1.0;
double erorOld = 10.0e10;
double factor = 0.8;
do {
if (error > erorOld) {
factor /= 2.0;
} else if (error < erorOld && factor < 0.8) {
factor *= 1.1;
}
iterations++;
oldTemp = nyTemp;
system.init(2);
nyTemp = oldTemp - factor * calcdQdT() / calcdQdTT();
// f(Math.abs(1.0/nyTemp-1.0/oldTemp)>5.0) nyTemp = 1.0/(1.0/oldTemp +
// Math.signum(1.0/nyTemp-1.0/oldTemp)*5.0);
if (Double.isNaN(nyTemp)) {
nyTemp = oldTemp + 1.0;
}
system.setTemperature(1.0 / nyTemp);
tpFlash.run();
erorOld = error;
error = Math.abs((1.0 / nyTemp - 1.0 / oldTemp) / (1.0 / oldTemp));
// System.out.println("error " + error);
// System.out.println("temperature " + system.getTemperature() + " " +
// iterations);
} while (error > 1e-8 && iterations < 500);

return 1.0 / nyTemp;
}
return 1.0 / nyTemp;
}

/** {@inheritDoc} */
@Override
public void run() {
tpFlash.run();
// System.out.println("internal energy start: " + system.getInternalEnergy());
solveQ();
// System.out.println("internal energy end: " + system.getInternalEnergy());
// System.out.println("enthalpy: " + system.getEnthalpy());
// System.out.println("Temperature: " + system.getTemperature());
}
/** {@inheritDoc} */
@Override
public void run() {
tpFlash.run();
// System.out.println("internal energy start: " + system.getInternalEnergy());
solveQ();
// System.out.println("internal energy end: " + system.getInternalEnergy());
// System.out.println("enthalpy: " + system.getEnthalpy());
// System.out.println("Temperature: " + system.getTemperature());
}

/** {@inheritDoc} */
@Override
public org.jfree.chart.JFreeChart getJFreeChart(String name) {
return null;
}
/** {@inheritDoc} */
@Override
public org.jfree.chart.JFreeChart getJFreeChart(String name) {
return null;
}
}
Loading

0 comments on commit 12eb1b9

Please sign in to comment.