mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Initial commit for v5, but this time with the right line endings
Signed-off-by: Ian bell <ian.h.bell@gmail.com>
This commit is contained in:
101
Web/examples/Java/Example.java
Normal file
101
Web/examples/Java/Example.java
Normal file
@@ -0,0 +1,101 @@
|
||||
// Example for Java
|
||||
// Ian Bell, 2013
|
||||
|
||||
public class Example {
|
||||
static {
|
||||
System.loadLibrary("CoolProp");
|
||||
}
|
||||
|
||||
public static void main(String argv[]){
|
||||
|
||||
double T, h, p, D;
|
||||
int SI,KSI;
|
||||
System.out.println("CoolProp version: " + CoolProp.get_global_param_string("version"));
|
||||
System.out.println("CoolProp gitrevision: " + CoolProp.get_global_param_string("gitrevision"));
|
||||
System.out.println("CoolProp fluids: " + CoolProp.get_global_param_string("FluidsList"));
|
||||
|
||||
System.out.println(" ");
|
||||
System.out.println("************ USING EOS *************");
|
||||
System.out.println(" ");
|
||||
System.out.println("FLUID STATE INDEPENDENT INPUTS");
|
||||
System.out.println("Critical Density Propane: " + CoolProp.Props1("Propane", "rhocrit") + "kg/m^3");
|
||||
System.out.println("TWO PHASE INPUTS (Pressure)");
|
||||
System.out.println("Density of saturated liquid Propane at 101.325 kPa: " + CoolProp.Props("D", 'P', 101.325, 'Q', 0, "Propane") + " kg/m^3");
|
||||
System.out.println("Density of saturated vapor R290 at 101.325 kPa: " + CoolProp.Props("D", 'P', 101.325, 'Q', 1, "R290") + " kg/m^3");
|
||||
System.out.println("TWO PHASE INPUTS (Temperature)");
|
||||
System.out.println("Density of saturated liquid Propane at 300 K: " + CoolProp.Props("D", 'T', 300, 'Q', 0, "Propane") + " kg/m^3");
|
||||
System.out.println("Density of saturated vapor R290 at 300 K: " + CoolProp.Props("D", 'T', 300, 'Q', 1, "R290") + " kg/m^3");
|
||||
System.out.println("SINGLE PHASE CYCLE (propane)");
|
||||
p = CoolProp.Props("P", 'T', 300, 'D', 1, "Propane");
|
||||
h = CoolProp.Props("H", 'T', 300, 'D', 1, "Propane");
|
||||
System.out.println("T,D -> P,H " + 300 + "," + 1 + " --> " + p + ',' + h);
|
||||
T = CoolProp.Props("T", 'P', p, 'H', h, "Propane");
|
||||
D = CoolProp.Props("D", 'P', p, 'H', h, "Propane");
|
||||
System.out.println("P,H -> T,D " + p + ',' + h + " --> " + T + ',' + D);
|
||||
|
||||
System.out.println(" ");
|
||||
System.out.println("************ USING TTSE ***************");
|
||||
System.out.println(" ");
|
||||
CoolProp.enable_TTSE_LUT("Propane");
|
||||
System.out.println("TWO PHASE INPUTS (Pressure)");
|
||||
System.out.println("Density of saturated liquid Propane at 101.325 kPa: " + CoolProp.Props("D", 'P', 101.325, 'Q', 0, "Propane") + " kg/m^3");
|
||||
System.out.println("Density of saturated vapor R290 at 101.325 kPa: " + CoolProp.Props("D", 'P', 101.325, 'Q', 1, "R290") + " kg/m^3");
|
||||
System.out.println("TWO PHASE INPUTS (Temperature)");
|
||||
System.out.println("Density of saturated liquid Propane at 300 K: " + CoolProp.Props("D", 'T', 300, 'Q', 0, "Propane") + " kg/m^3");
|
||||
System.out.println("Density of saturated vapor R290 at 300 K: " + CoolProp.Props("D", 'T', 300, 'Q', 1, "R290") + " kg/m^3");
|
||||
System.out.println("SINGLE PHASE CYCLE (propane)");
|
||||
p = CoolProp.Props("P", 'T', 300, 'D', 1, "Propane");
|
||||
h = CoolProp.Props("H", 'T', 300, 'D', 1, "Propane");
|
||||
System.out.println("T,D -> P,H " + 300 + ","+ 1+ " --> " + p + ',' + h);
|
||||
T = CoolProp.Props("T", 'P', p, 'H', h, "Propane");
|
||||
D = CoolProp.Props("D", 'P', p, 'H', h, "Propane");
|
||||
System.out.println("P,H -> T,D " + p + ',' + h + " --> " + T + ',' + D);
|
||||
CoolProp.disable_TTSE_LUT("Propane");
|
||||
|
||||
try
|
||||
{
|
||||
System.out.println(" ");
|
||||
System.out.println("************ USING REFPROP ***************");
|
||||
System.out.println(" ");
|
||||
System.out.println("TWO PHASE INPUTS (Pressure)");
|
||||
System.out.println("Density of saturated liquid Propane at 101.325 kPa: " + CoolProp.Props("D", 'P', 101.325, 'Q', 0, "Propane") + " kg/m^3");
|
||||
System.out.println("Density of saturated vapor R290 at 101.325 kPa: " + CoolProp.Props("D", 'P', 101.325, 'Q', 1, "R290") + " kg/m^3");
|
||||
System.out.println("TWO PHASE INPUTS (Temperature)");
|
||||
System.out.println("Density of saturated liquid Propane at 300 K: " + CoolProp.Props("D", 'T', 300, 'Q', 0, "Propane") + " kg/m^3");
|
||||
System.out.println("Density of saturated vapor R290 at 300 K: " + CoolProp.Props("D", 'T', 300, 'Q', 1, "R290") + " kg/m^3");
|
||||
System.out.println("SINGLE PHASE CYCLE (propane)");
|
||||
p = CoolProp.Props("P",'T',300,'D',1,"Propane");
|
||||
h = CoolProp.Props("H",'T',300,'D',1,"Propane");
|
||||
System.out.println("T,D -> P,H " + 300 + "," + 1 + " --> " + p + ',' + h);
|
||||
T = CoolProp.Props("T",'P',p,'H',h,"Propane");
|
||||
D = CoolProp.Props("D",'P',p,'H',h,"Propane");
|
||||
System.out.println("P,H -> T,D " + p + ',' + h + " --> " + T + ',' + D);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
System.out.println(" ");
|
||||
System.out.println("************ CANT USE REFPROP ************");
|
||||
System.out.println(" ");
|
||||
}
|
||||
|
||||
System.out.println(" ");
|
||||
System.out.println("************ CHANGE UNIT SYSTEM (default is kSI) *************");
|
||||
System.out.println(" ");
|
||||
CoolProp.set_standard_unit_system(unit_systems.UNIT_SYSTEM_SI.swigValue());
|
||||
System.out.println("Vapor pressure of water at 373.15 K in SI units (Pa): " + CoolProp.Props("P", 'T', 373.15, 'Q', 0, "Water"));
|
||||
CoolProp.set_standard_unit_system(unit_systems.UNIT_SYSTEM_KSI.swigValue());
|
||||
System.out.println("Vapor pressure of water at 373.15 K in kSI units (kPa): " + CoolProp.Props("P", 'T', 373.15, 'Q', 0, "Water"));
|
||||
|
||||
System.out.println(" ");
|
||||
System.out.println("************ BRINES AND SECONDARY WORKING FLUIDS *************");
|
||||
System.out.println(" ");
|
||||
System.out.println("Density of 50% (mass) ethylene glycol/water at 300 K, 101.325 kPa: " + CoolProp.Props("D", 'T', 300, 'P', 101.325, "EG-50%") + "kg/m^3");
|
||||
System.out.println("Viscosity of Therminol D12 at 350 K, 101.325 kPa: " + CoolProp.Props("V", 'T', 350, 'P', 101.325, "TD12") + "Pa-s");
|
||||
|
||||
System.out.println(" ");
|
||||
System.out.println("************ HUMID AIR PROPERTIES *************");
|
||||
System.out.println(" ");
|
||||
System.out.println("Humidity ratio of 50% rel. hum. air at 300 K, 101.325 kPa: " + CoolProp.HAProps("W", "T", 300, "P", 101.325, "R", 0.5) + " kg_w/kg_da");
|
||||
System.out.println("Relative humidity from last calculation: " + CoolProp.HAProps("R", "T", 300, "P", 101.325, "W", CoolProp.HAProps("W", "T", 300, "P", 101.325, "R", 0.5)) + "(fractional)");
|
||||
}
|
||||
}
|
||||
57
Web/examples/Java/Output.txt
Normal file
57
Web/examples/Java/Output.txt
Normal file
@@ -0,0 +1,57 @@
|
||||
CoolProp version: 4.1.2
|
||||
CoolProp gitrevision: 016d3219602f0ea2e5eac89f21b3ab0e54cdc941
|
||||
CoolProp fluids: Water,R134a,Helium,Oxygen,Hydrogen,ParaHydrogen,OrthoHydrogen,Argon,CarbonDioxide,Nitrogen,n-Propane,Ammonia,R1234yf,R1234ze(E),R32,R22,SES36,Ethylene,SulfurHexafluoride,Ethanol,DimethylEther,DimethylCarbonate,R143a,R23,n-Dodecane,Propylene,Cyclopentane,R236FA,R236EA,R227EA,R365MFC,R161,HFE143m,Benzene,n-Undecane,R125,CycloPropane,Neon,R124,Propyne,Fluorine,Methanol,RC318,R21,R114,R13,R14,R12,R113,R1234ze(Z),R1233zd(E),AceticAcid,R245fa,R41,CarbonMonoxide,CarbonylSulfide,n-Decane,HydrogenSulfide,Isopentane,Neopentane,Isohexane,Krypton,n-Nonane,Toluene,Xenon,R116,Acetone,NitrousOxide,SulfurDioxide,R141b,R142b,R218,Methane,Ethane,n-Butane,IsoButane,n-Pentane,n-Hexane,n-Heptane,n-Octane,CycloHexane,R152A,R123,R11,MDM,MD2M,MD3M,D6,MM,MD4M,D4,D5,1-Butene,IsoButene,cis-2-Butene,trans-2-Butene,MethylPalmitate,MethylStearate,MethylOleate,MethylLinoleate,MethylLinolenate,o-Xylene,m-Xylene,p-Xylene,EthylBenzene,Deuterium,ParaDeuterium,OrthoDeuterium,Air,R404A,R410A,R407C,R507A,R407F
|
||||
|
||||
************ USING EOS *************
|
||||
|
||||
FLUID STATE INDEPENDENT INPUTS
|
||||
Critical Density Propane: 220.4781kg/m^3
|
||||
TWO PHASE INPUTS (Pressure)
|
||||
Density of saturated liquid Propane at 101.325 kPa: 580.8829519548196 kg/m^3
|
||||
Density of saturated vapor R290 at 101.325 kPa: 2.4161360087881647 kg/m^3
|
||||
TWO PHASE INPUTS (Temperature)
|
||||
Density of saturated liquid Propane at 300 K: 489.4473752519588 kg/m^3
|
||||
Density of saturated vapor R290 at 300 K: 21.629532018462186 kg/m^3
|
||||
SINGLE PHASE CYCLE (propane)
|
||||
T,D -> P,H 300,1 --> 56.07276274829289,634.7336259284773
|
||||
P,H -> T,D 56.07276274829289,634.7336259284773 --> 300.00000000000017,0.9999999999999992
|
||||
|
||||
************ USING TTSE ***************
|
||||
|
||||
TWO PHASE INPUTS (Pressure)
|
||||
0.171 to build both two phase tables
|
||||
Density of saturated liquid Propane at 101.325 kPa: 580.882952265689 kg/m^3
|
||||
Density of saturated vapor R290 at 101.325 kPa: 2.416136006551446 kg/m^3
|
||||
TWO PHASE INPUTS (Temperature)
|
||||
Density of saturated liquid Propane at 300 K: 489.44737744117043 kg/m^3
|
||||
Density of saturated vapor R290 at 300 K: 21.62953187730398 kg/m^3
|
||||
SINGLE PHASE CYCLE (propane)
|
||||
T,D -> P,H 300,1 --> 56.07276440582185,634.733625854333
|
||||
P,H -> T,D 56.07276440582185,634.733625854333 --> 299.99999990675275,0.9999999797332718
|
||||
|
||||
************ USING REFPROP ***************
|
||||
|
||||
TWO PHASE INPUTS (Pressure)
|
||||
Density of saturated liquid Propane at 101.325 kPa: 580.8829519548196 kg/m^3
|
||||
Density of saturated vapor R290 at 101.325 kPa: 2.4161360087881647 kg/m^3
|
||||
TWO PHASE INPUTS (Temperature)
|
||||
Density of saturated liquid Propane at 300 K: 489.4473752519588 kg/m^3
|
||||
Density of saturated vapor R290 at 300 K: 21.629532018462186 kg/m^3
|
||||
SINGLE PHASE CYCLE (propane)
|
||||
T,D -> P,H 300,1 --> 56.07276274829289,634.7336259284773
|
||||
P,H -> T,D 56.07276274829289,634.7336259284773 --> 300.00000000000017,0.9999999999999992
|
||||
|
||||
************ CHANGE UNIT SYSTEM (default is kSI) *************
|
||||
|
||||
Vapor pressure of water at 373.15 K in SI units (Pa): 101417.9966599521
|
||||
Vapor pressure of water at 373.15 K in kSI units (kPa): 101.4179966599521
|
||||
|
||||
************ BRINES AND SECONDARY WORKING FLUIDS *************
|
||||
|
||||
Density of 50% (mass) ethylene glycol/water at 300 K, 101.325 kPa: 1061.1793077204613kg/m^3
|
||||
Viscosity of Therminol D12 at 350 K, 101.325 kPa: 5.228849410507948E-4Pa-s
|
||||
|
||||
************ HUMID AIR PROPERTIES *************
|
||||
|
||||
Humidity ratio of 50% rel. hum. air at 300 K, 101.325 kPa: 0.011096223750095191 kg_w/kg_da
|
||||
Relative humidity from last calculation: 0.49999999999999994(fractional)
|
||||
11
Web/examples/Java/example.rst
Normal file
11
Web/examples/Java/example.rst
Normal file
@@ -0,0 +1,11 @@
|
||||
Example Code for Java
|
||||
=====================
|
||||
|
||||
Code
|
||||
----
|
||||
.. literalinclude:: Example.java
|
||||
:language: java
|
||||
|
||||
Output
|
||||
------
|
||||
.. literalinclude:: Output.txt
|
||||
31
Web/examples/Java/run_example.bat
Normal file
31
Web/examples/Java/run_example.bat
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
@echo on
|
||||
copy ..\..\..\wrappers\Java\Example.java Example.java
|
||||
|
||||
REM ******** set the variables ************
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
|
||||
call "C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
|
||||
|
||||
REM ******* compile all the sources ***************
|
||||
swig -java -c++ -outcurrentdir ../../../CoolProp/CoolProp.i
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
cl /c /I../../../CoolProp /I"C:\Program Files\Java\jdk1.7.0_40\include" /I"C:\Program Files\Java\jdk1.7.0_40\include\win32" /EHsc *.cxx
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
cl /c /I../../../CoolProp /I"C:\Program Files\Java\jdk1.7.0_40\include" /I"C:\Program Files\Java\jdk1.7.0_40\include\win32" /EHsc ../../../CoolProp/*.cpp
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
link /DLL *.obj /OUT:CoolProp.dll
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
erase *.obj
|
||||
erase *.exp
|
||||
erase *.lib
|
||||
|
||||
javac *.java
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
java Example > Output.txt
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
|
||||
erase *.java
|
||||
erase *.class
|
||||
erase CoolProp.dll
|
||||
erase CoolProp_wrap.cxx
|
||||
copy ..\..\..\wrappers\Java\Example.java Example.java
|
||||
Reference in New Issue
Block a user