Commit Graph

1714 Commits

Author SHA1 Message Date
Ian Bell
94242e224b Add a pybind11 wrapper interface file for low-level interface 2016-10-21 18:46:59 -06:00
Ian Bell
4626602237 Fix plus symbols 2016-10-18 20:47:11 -06:00
JonWel
ba0829b9f3 Remove possible division by 0, closes #1270 (#1271)
* Remove possible division by 0, closes #1270
2016-10-18 20:41:51 -06:00
Ian Bell
0dbd096a56 Fix logic for Helmholtz evaluation 2016-10-17 21:45:04 -06:00
JonWel
1fd55c9eef Solves a bug in VTPR (#1272)
The value of lnGammag was not cleared, this was creating a sort of caching issue.
(@ibell this solves the issue I was had in Paper1, I finally got it)
2016-10-17 20:07:11 -06:00
Ian Bell
156b3e5cb9 Export spinodal curves in DLL; closes #1273 2016-10-17 20:06:08 -06:00
Ian Bell
91704a450b Export critical points in DLL; closes #1274 2016-10-17 19:55:25 -06:00
Ian Bell
797f500307 Use powInt instead of pow(double,int) - seems to save about 30% in speed 2016-10-16 13:13:22 -06:00
JonWel
d8225753fe SatL and SatV of type VTPR too (#1269)
The copy was previously creating PengRobinson instances for SatV and SatL, thus calls like "QT_INPUTS" were giving identical results as PR for mixtures.
2016-10-15 18:45:50 -06:00
Ian Bell
521cfc6d78 One more try with the alpha function copying 2016-10-14 23:08:08 -06:00
Ian Bell
afb04bc5fa Set alpha (properly) in SatL and SatV in cubics; closes #1267 2016-10-14 22:51:18 -06:00
Ian Bell
94d2a7a4b7 Calculate molar mass with the VTPR backend too 2016-10-14 20:36:48 -06:00
Ian Bell
d5641856cc Grabbing some bits from #1266
Sorry @JonWel, can't do the fix you propose, so I just took 2/3 of your PR
2016-10-14 20:25:27 -06:00
Ian Bell
06bd66a23c Implement fluid_names for cubic backend; closes #1268 2016-10-14 20:19:24 -06:00
Ian Bell
ec141962f9 Set alpha in SatL and SatV in cubics; closes #1267 2016-10-14 20:09:15 -06:00
Ian Bell
9149341821 Make psi_plus public; closes #1240 2016-10-13 21:15:30 -06:00
Ian Bell
7893a7f7d9 Make spinodal accessible to python
See plot:

```
import CoolProp, numpy as np, matplotlib.pyplot as plt
CP = CoolProp.CoolProp
AS = CP.AbstractState('HEOS','Methane&Ethane')
AS.set_mole_fractions([0.5,0.5])

# The spinodal
AS.build_spinodal()
sp = AS.get_spinodal_data()
plt.plot(sp.tau, sp.delta, label='spinodal')

# The phase envelope
AS.build_phase_envelope("none")
pe = AS.get_phase_envelope_data()
plt.plot(AS.T_reducing()/np.array(pe.T), np.array(pe.rhomolar_vap)/AS.rhomolar_reducing(), label='phase envelope')

plt.show()
```
2016-10-13 20:48:10 -06:00
Ian Bell
a4a8eaa5ae Rename SpinodalValues to SpinodalData to mirror phase envelope 2016-10-13 20:30:25 -06:00
Ian Bell
b948f44dd8 Implement in C++ the calculation of the spinodal 2016-10-13 20:18:28 -06:00
Ian Bell
18b4316d6c Update initialization for VTPR; closes #1264 2016-10-13 19:38:21 -06:00
Ian Bell
c929e92b3d Build/retrieve phase envelope through high-level DLL; closes #1158 2016-10-13 19:35:36 -06:00
Ian Bell
92f4c58525 Set alpha function in JSON (#1262)
* First cut at adding the ability to set alpha function from external code

Quite a bit of refactoring...

* First cut at adding the ability to set alpha function from external code

Quite a bit of refactoring...

* Fix setting of alpha function for VTPR
2016-10-12 22:44:37 -06:00
JonWel
1fb9925baa Solves a bug with cubic and mixtures (#1258)
The transient_pure_state has no mole fractions when created, this was triggering a CoolProp: `Mole fractions must be set` error.

I guess it's because that transient state is supposed to be pure, but this fix allows to get the answer.
Is there something more elegant to do?
2016-10-11 12:59:19 -06:00
Ian Bell
7071bf5923 Set all parameters in one shot ( a bit faster ) 2016-10-05 21:36:35 -06:00
Ian Bell
a4d54687fe Implement coefficient derivatives of dYr_dxi in reducing function; closes #1250 2016-10-04 23:16:32 -06:00
Ian Bell
22f79e471b main.cxx is ignored now, as should be 2016-09-30 00:54:28 -06:00
Ian Bell
5b9e66c2c1 lots of small updates to get VxWorks to build properly 2016-09-30 00:41:24 -06:00
Ian Bell
317e37504c Disable cppformat for VxWorks 2016-09-29 22:03:45 -06:00
Ian Bell
e97a7f931f Add ability to skip flash for DT inputs for REFPROP; closes #801 2016-09-18 19:44:43 -06:00
JonWel
30d44be01e Shortcut VTPR when pure fluids, solves #1232 (#1239)
* Shortcut VTPR when pure fluids, closes #1232

Also get use of the molar fraction as available as an argument in gE_R_RT
2016-09-18 19:02:04 -06:00
Ian Bell
ac8e6df11d Add ability to use Peng-Robinson in REFPROP; closes #1233 2016-09-15 21:01:36 -06:00
Ian Bell
08245ff00b Update stability debug output text 2016-09-09 13:44:38 -07:00
Ian Bell
7e6c0637d3 A bit more conservative search for the stationary point density on liquid side
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2016-09-09 13:21:36 -07:00
Ian Bell
54cf1fdc96 Decrease max tau to 4; see #1226 (max tau was 4.9... in issue) 2016-09-08 20:51:58 -06:00
Ian Bell
26a2520b5a Make all functions in DepartureFunction overrridable; closes #1227 2016-09-08 20:27:45 -06:00
Ian Bell
9a0aa614a8 Fix upper bound for density in TPD calc; closes #1222 2016-09-04 18:28:13 -06:00
Ian Bell
d2ba7df29b Take more steps in stability evaluator; closes #1221 2016-09-04 15:21:19 -06:00
Ian Bell
a74ae15a86 Update convergence criteria for ND Newton-Raphson; closes #985 2016-09-01 19:36:27 -06:00
Ian Bell
9b129ce950 First cut at adding ODE integrators; closes #1220 2016-09-01 13:24:14 -06:00
Ian Bell
ae7184c297 Add some logic to avoid negative densities for cubics; closes #1217 2016-08-30 18:20:11 -06:00
Ian Bell
2281351de4 One more update to docs 2016-08-30 18:08:18 -06:00
Ian Bell
6d4e1835a9 Fix docs for saturation_Wilson; see #1218 2016-08-30 18:06:26 -06:00
Ian Bell
1d1d9be4f7 Remove double post_update in update_TP_guessrho; closes #1219 2016-08-30 18:06:26 -06:00
Ian Bell
371eecae60 Turn off caching in UNIFAQ and move non-temperature dependent code into set_mole_fractions (thanks @JonWel); closes #1215 2016-08-29 20:33:37 -06:00
Ian Bell
79fb9a6933 Fix debug print formatting 2016-08-28 21:58:57 -06:00
Ian Bell
5f2bf21141 Add QT_flash_with_guesses
``` python
import matplotlib.pyplot as plt, numpy as np, CoolProp.CoolProp as CP, CoolProp

fluids = ['CO2','Ethane']

AS = CoolProp.AbstractState('HEOS','&'.join(fluids))
xx,yy = [],[]
for z in np.linspace(0, 1, 20):
	try:
		AS.set_mole_fractions([z, 1-z])
		pt = AS.all_critical_points()[0]
		xx.append(z)
		yy.append(pt.p)
	except: pass
plt.plot(xx, yy, label='critical line')

CP.set_debug_level(0)
AS = CoolProp.AbstractState('HEOS','&'.join(fluids))
for T, c in zip([288,293,298],['b','r','g']):
	for Q in 0,1:
		guesses = None
		for x in np.linspace(0.00001, 1, 200):
			try:
				if guesses is None:
					AS.set_mole_fractions([x,1-x])
					AS.update(CP.QT_INPUTS,Q,T)
					guesses = CP.PyGuessesStructure()
					plt.plot(x, AS.p(), 'o',color=c)
				else:
					guesses = CP.PyGuessesStructure()
					guesses.rhomolar_liq = AS.saturated_liquid_keyed_output(CP.iDmolar)
					guesses.rhomolar_vap = AS.saturated_vapor_keyed_output(CP.iDmolar)
					guesses.p = AS.p()
					guesses.x = AS.mole_fractions_liquid()
					guesses.y = AS.mole_fractions_vapor()
					if Q == 0:
						guesses.x = [x,1-x];
					else:
						guesses.y = [x,1-x];
					AS.set_mole_fractions([x,1-x])
					AS.update_with_guesses(CP.QT_INPUTS, Q, T, guesses)
					plt.plot(x, AS.p(), 'o',color=c)
			except BaseException as BE:
				print(x, BE)
plt.legend(loc='best')
plt.show()
```
2016-08-28 21:52:07 -06:00
Ian Bell
d9c3c91dab Some efforts to resolve issues with the stationary point failures 2016-08-28 18:07:15 -06:00
Ian Bell
ef2dc92cf5 Another fix for TP flash to fix logo script 2016-08-28 00:25:54 -06:00
Ian Bell
d88752a82c Avoid UNIFAQ calls if set_mole_fractions gets the same input again 2016-08-27 22:44:05 -06:00
Ian Bell
0dcc97210b Avoid crazy number of calls to set_temperature if possible. 2016-08-27 22:39:05 -06:00