-
Notifications
You must be signed in to change notification settings - Fork 29
/
testit.py
86 lines (70 loc) · 2.61 KB
/
testit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import os
import timeit
import json
import numpy as np
import cCOSMO
here = os.path.abspath(os.path.dirname(__file__))
dbVT = cCOSMO.VirginiaTechProfileDatabase(
here+"/profiles/VT2005/Sigma_Profile_Database_Index_v2.txt",
here+"/profiles/VT2005/Sigma_Profiles_v2/")
db = cCOSMO.DelawareProfileDatabase(
here+"/profiles/UD/complist.txt",
here+"/profiles/UD/sigma3/")
names = [ "METHANE", "ETHANE" ]
for iden in names:
db.add_profile(db.normalize_identifier(iden))
dbVT.add_profile(dbVT.normalize_identifier(iden))
# Use the Delaware database to create a dictionary mapping from
# name of each fluid name to the CAS #
#
# Something analogous could be done with the VT database, though the keys differ slightly
CAS_lookup = {meta['name']: meta['CAS'] for primary_key, meta in json.loads(db.to_JSON()).items()}
# Make a list of CAS # for the fluids
CASes = [CAS_lookup[fluid] for fluid in names]
# Switch over to using the CAS# as the identifier rather than the name
names = CASes[:]
for COSMO in [cCOSMO.COSMO1(names, dbVT), cCOSMO.COSMO3(names, db)]:
T = 400.15;
z = np.array([0, 1])
# print(COSMO.get_lngamma(T, z))
# Print the constants in use (debugging use, not generally necessary)
# print(COSMO.get_mutable_combinatorial_constants())
# print(COSMO.get_mutable_COSMO_constants())
psigma_mix = 0
xA = 0
for _z, name in zip(z,names):
prof = db.get_profile(db.normalize_identifier(name))
psigma_mix += _z*prof.profiles.nhb.psigmaA
xA += prof.A_COSMO_A2
psigma_mix /= xA
# Change a constant
comb_consts = COSMO.get_mutable_combinatorial_constants()
comb_consts.z_coordination = 10.0
cConsts = COSMO.get_mutable_COSMO_constants()
cConsts.fast_Gamma = False
Nreps = 1000
for fast_Gamma in [False,True]:
cConsts.fast_Gamma = fast_Gamma
print('fast_Gamma:', fast_Gamma)
tic = timeit.default_timer()
for i in range(100):
lngamma = COSMO.get_lngamma(T, z)
toc = timeit.default_timer()
print(lngamma)
print((toc-tic)*1e6/Nreps,'us/call')
# tic = timeit.default_timer()
# Gamma_mix = COSMO.get_Gamma(T, psigma_mix)
# toc = timeit.default_timer()
# print('t(get_Gamma):',toc-tic)
# print('Gamma_mix:', Gamma_mix)
print('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
# Plot the profiles
import matplotlib.pyplot as plt
for i in names:
prof = db.get_profile(db.normalize_identifier(i))
print(prof.name)
nhb = prof.profiles.nhb
plt.plot(nhb.sigma, nhb.psigmaA/np.sum(nhb.psigmaA))
plt.xlabel(r'$\sigma$ / e/$\AA^2$')
plt.ylabel(r'$p(\sigma)$ ')
plt.show()