-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce StateOfMatter enum (#672)
- Loading branch information
1 parent
d638646
commit fad41cf
Showing
3 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package neqsim.thermo.phase; | ||
|
||
/** | ||
* States of matter, a way of relating the PhaseTypes to classical states of matter. | ||
*/ | ||
public enum StateOfMatter { | ||
GAS, LIQUID, SOLID; | ||
|
||
/** | ||
* Get StateOfMatter value from Phasetype object. | ||
* | ||
* @param pt PhaseType object | ||
* @return StateOfMatter object | ||
*/ | ||
public static StateOfMatter fromPhaseType(PhaseType pt) { | ||
switch (pt) { | ||
case GAS: | ||
return StateOfMatter.GAS; | ||
case LIQUID: | ||
case OIL: | ||
case AQUEOUS: | ||
return StateOfMatter.LIQUID; | ||
case SOLID: | ||
case SOLIDCOMPLEX: | ||
case WAX: | ||
return StateOfMatter.LIQUID; | ||
default: | ||
new RuntimeException(new neqsim.util.exception.InvalidInputException(StateOfMatter.class, | ||
"fromPhaseType", "pt", "Conversion not configured for")); | ||
} | ||
return null; | ||
} | ||
|
||
/** | ||
* Check if PhaseType object is a gas state of matter. | ||
* | ||
* @param pt PhaseType object to check. | ||
* @return True if pt converts to StateOfMatter.GAS | ||
*/ | ||
public static boolean isGas(PhaseType pt) { | ||
return StateOfMatter.fromPhaseType(pt) == StateOfMatter.GAS; | ||
} | ||
|
||
/** | ||
* Check if PhaseType object is a liquid state of matter. | ||
* | ||
* @param pt PhaseType object to check. | ||
* @return True if pt converts to StateOfMatter.LIQUID | ||
*/ | ||
public static boolean isLiquid(PhaseType pt) { | ||
return StateOfMatter.fromPhaseType(pt) == StateOfMatter.LIQUID; | ||
} | ||
|
||
/** | ||
* Check if PhaseType object is a solid state of matter. | ||
* | ||
* @param pt PhaseType object to check. | ||
* @return True if pt converts to StateOfMatter.SOLID | ||
*/ | ||
public static boolean isSolid(PhaseType pt) { | ||
return StateOfMatter.fromPhaseType(pt) == StateOfMatter.SOLID; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters