forked from ImpactsWiki/pyko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eos_table.py
2161 lines (2106 loc) · 97.4 KB
/
eos_table.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
Classes and functions for accessing and manipulating tabulated EOS data.
"""
##############################################################
# IMPORT PYTHON MODULES
import numpy as np
#
# GLOBAL VARIABLE
__version__ = 'v1.1.5' # 7/1/2023 added temperatures to MGR and TIL-iSALE EOS;
# fixed logic for iSALE Tillotson; problems with SESAME interpolation near zero pressure and tension
#__version__ = 'v1.1.4' # 6/24/2023 added load STD NOTENSION table
#__version__ = 'v1.1.3' # 2/15/2023 added write SESAME EXT table function
#__version__ = 'v1.1.1' # 2/11/2023 minor print statement removals
#__version__ = 'v1.1' # 2/6/2023 STS adding ideal gas compatibility
#__version__ = 'v1.0.1' # 2/27/2022 STS Added to classes for plotting data against the ANEOS model
#__version__ = 'v1.0' # 09/2019 STS original module created for ANEOS-Forsterite-2019
#
##############################################################
#
# calculate the structure for one planet
# make a class to hold the PREM data
class isentrope_class:
"""Class to isentrope data extracted from EOS table.""" # this is a documentation string for this class
def __init__(self): # self is the default name of the object for internal referencing of the variables in the class
"""A function to initialize the class object.""" # this is a documentation string for this function
self.ND = 0 # number of radius points
self.density = []
self.pressure = []
self.temperature = []
self.soundspeed = []
self.energy = []
self.partvel = []
self.region = [] # Tillotson region flag
# not going to use all the variables in the file
self.units = '' # I like to keep a text note in a structure about the units
self.label = ''
#
# make a class to hold a curve (e.g., isentrope) through EOS surface
class EOScurve:
"""Class EOS curve.""" # this is a documentation string for this class
def __init__(self): # self is the default name of the object for internal referencing of the variables in the class
"""A function to initialize the class object.""" # this is a documentation string for this function
self.rho = []
self.P = []
self.P_err = []
self.T = []
self.cs = []
self.gamma = []
self.U = []
self.U_err = []
self.up = []
self.us = []
# not going to use all the variables in the file
self.units = '' # I like to keep a text note in a structure about the units
self.label = ''
#
class EOShugoniot:
"""Class for Hugoniot array from extEOStable."""
def __init__(self):
self.NH = 0
self.rho0 = 0.
self.rho0_err = 0.
self.T0 = 0.
self.rho = np.zeros(self.NH)
self.rho_err = np.zeros(self.NH)
self.T = np.zeros(self.NH)
self.T_err = np.zeros(self.NH)
self.P = np.zeros(self.NH)
self.P_err = np.zeros(self.NH)
self.U = np.zeros(self.NH)
self.S = np.zeros(self.NH)
self.S_err = np.zeros(self.NH)
self.up = np.zeros(self.NH)
self.up_err = np.zeros(self.NH)
self.us = np.zeros(self.NH)
self.us_err = np.zeros(self.NH)
self.cs = np.zeros(self.NH)
self.ref = np.zeros(self.NH) # reflectivity
self.ref_err = np.zeros(self.NH) # reflectivity
self.gamma = np.zeros(self.NH)
self.gamma_err = np.zeros(self.NH)
self.units = ''
self.label = ''
#
class EOSvaporcurve:
"""Class for vapor curve from ANEOS."""
def __init__(self):
self.NT = 0
self.NV = 0
self.T = np.zeros(self.NT)
self.rl = np.zeros(self.NT)
self.rv = np.zeros(self.NT)
self.Pl = np.zeros(self.NT)
self.Pv = np.zeros(self.NT)
self.Ul = np.zeros(self.NT)
self.Uv = np.zeros(self.NT)
self.Sl = np.zeros(self.NT)
self.Sv = np.zeros(self.NT)
self.Gl = np.zeros(self.NT)
self.Gv = np.zeros(self.NT)
self.units = ''
#
class EOSmeltcurve:
"""Class for melt curve from ANEOS."""
def __init__(self):
self.NT = 0
self.NV = 0
self.T = np.zeros(self.NT)
self.Tl = np.zeros(self.NT)
self.Ts = np.zeros(self.NT)
self.rl = np.zeros(self.NT)
self.rs = np.zeros(self.NT)
self.Pl = np.zeros(self.NT)
self.Ps = np.zeros(self.NT)
self.Ul = np.zeros(self.NT)
self.Us = np.zeros(self.NT)
self.Sl = np.zeros(self.NT)
self.Ss = np.zeros(self.NT)
self.units = ''
#
class EOS1barcurve:
"""Class for 1bar curve from the EOS."""
def __init__(self):
self.NT = 0
self.S = np.zeros(self.NT)
self.T = np.zeros(self.NT)
self.rho = np.zeros(self.NT)
self.Tvap = 0.
self.Tmelt = 0.
self.Sim = 0.
self.Scm = 0.
self.Siv = 0.
self.Scv = 0.
self.rhoiv = 0.
self.rhocv = 0.
self.rhocm = 0.
self.rhoim = 0.
self.units = ''
self.label = ''
#
class EOSpoint:
"""Class for a state on the EOS."""
def __init__(self):
self.P = 0
self.P_err = 0
self.S = 0
self.S_err = 0
self.T = 0
self.T_err = 0
self.rho = 0
self.rho_err = 0
self.U = 0
self.U_err = 0
self.units = ''
self.label = ''
def __str__(self):
""" Print the values in the EOS point """
return '\nClass EOSpoint: \n' + \
f' eos_table module version {__version__} \n' + \
f' P, rho, T: {self.P} {self.rho} {self.T} \n' + \
f' U, S: {self.U} {self.S} \n'
#
class EOScriticalpoint:
"""Class for critical point state from the EOS."""
def __init__(self):
self.P = 0
self.S = 0
self.T = 0
self.rho = 0
self.U = 0
self.units = ''
self.label = ''
#
class EOStriplepoint:
"""Class for triple point state from the EOS."""
def __init__(self):
self.P = 0
self.T = 0
self.Sim = 0.
self.Scm = 0.
self.Siv = 0.
self.Scv = 0.
self.rhol = 0.
self.units = ''
self.label = ''
#
class EOSaneoshugoniot:
"""Class for Hugoniot calculated in ANEOS."""
def __init__(self):
self.ND = 0
self.NV = 0
#self.all = np.zeros((self.ND,self.NV))
self.rho = 0
self.T = 0
self.P = 0
self.U = 0
self.S = 0
self.us = 0
self.up = 0
self.units = ''
#
class extEOStable:
"""Class for accessing EXTENDED SESAME-STYLE EOS tables output from ANEOS"""
# ANEOS KPA FLAG
# TABLE ANEOS
# KPAQQ=STATE INDICATOR =1, 1p =1, 1p (eos without melt)
# =2, 2p lv =2, 2p liquid/solid plus vapor
# =4, 1p solid (eos with melt)
# =5, 2p melt (eos with melt)
# =6, 1p liquid (eos with melt)
# =-1 bad value of temperature
# =-2 bad value of density
# =-3 bad value of material number
#
def __init__(self):
self.ND = 0 # integer; number of density points in grid
self.NT = 0 # integer; number of temperature points in grid
self.rho = np.zeros(self.ND) # g/cm3, density values
self.T = np.zeros(self.NT) # K, temperature values
self.P = np.zeros(self.ND*self.NT) # GPA, pressure(T,rho)
self.U = np.zeros(self.ND*self.NT) # MJ/kg, sp. internal energy(T,rho)
self.A = np.zeros(self.ND*self.NT) # MJ/kg, Helmholtz free energy(T,rho)
self.S = np.zeros(self.ND*self.NT) # MJ/K/kg, sp. entropy(T,rho)
self.cs = np.zeros(self.ND*self.NT) # cm/s, sound speed(T,rho)
self.cv = np.zeros(self.ND*self.NT) # MJ/K/kg, sp. heat capacity(T,rho)
self.KPA = np.zeros(self.ND*self.NT) # integer, ANEOS KPA flag(T,rho)
self.MDQ = np.zeros(self.ND*self.NT) # integer, Model Development Quality Flag(T,rho)
self.units = ''
self.hug = EOShugoniot()
self.hugo = EOShugoniot()
self.vc = EOSvaporcurve()
self.mc = EOSmeltcurve()
self.cp = EOScriticalpoint()
self.tp = EOStriplepoint()
self.onebar = EOS1barcurve()
self.anhug = EOSaneoshugoniot()
# these are variables needed for the sesame header
self.MATID = 0.
self.DATE = 0.
self.VERSION = 0.
self.FMN = 0.
self.FMW = 0.
self.R0REF = 0.
self.K0REF = 0.
self.T0REF = 0.
self.P0REF = 0.
self.CS0REF = 0.
# variables needed for the ANEOS gamma function
self.gamma0 = 0.
self.theta0 = 0.
self.C24 = 0.
self.C60 = 0.
self.C61 = 0.
self.beta = 0.
# model name/version string
self.MODELNAME = ''
def loadstdsesame(self, fname, unitstxt=None):
"""Function for loading STD SESAME-STYLE EOS table output from ANEOS"""
data = ([])
if unitstxt is None:
self.units = 'Units: rho g/cm3, T K, P GPa, U MJ/kg, A MJ/kg, S MJ/K/kg, cs cm/s, cv MJ/K/kg, KPA flag. 2D arrays are (NT,ND).'
else:
self.units = unitstxt
sesamefile = open(fname,"r")
sesamedata=sesamefile.readlines()
sesamefile.close()
nskip = 6 # skip standard header to get to the content of the 301 table
# num.density, num. temps
tmp = sesamedata[nskip][0:16]
dlen = float(tmp)
tmp = sesamedata[nskip][16:32]
tlen = float(tmp)
if (np.mod((dlen*tlen*3.0+dlen+tlen+2.0),5.0) == 0):
neos = int((dlen*tlen*3.0+dlen+tlen+2.0)/5.0)
else:
neos = int((dlen*tlen*3.0+dlen+tlen+2.0)/5.0) +1
#print(dlen,tlen,neos,len(sesamedata))
data = np.zeros((neos,5),dtype=float)
for j in range(nskip,neos+nskip):
tmp3 = sesamedata[j]
tmp4 = list(tmp3.split())
if len(tmp4) < 5:
lentmp4 = len(tmp4)
data[j-nskip,0:lentmp4] = np.asarray(tmp4[0:lentmp4])
else:
data[j-nskip,:] = np.asarray(tmp4)
#print(j,eosarr[j,:])
#print(data.shape)
data=np.resize(data,(neos*5))
#print(data.shape)
self.ND = data[0].astype(int) # now fill the extEOStable class
self.NT = data[1].astype(int)
self.rho = data[2:2+self.ND]
self.T = data[2+self.ND : 2+self.ND+self.NT]
self.P = data[2+self.ND+self.NT : 2+self.ND+self.NT+self.ND*self.NT
].reshape(self.NT,self.ND)
self.U = data[2+self.ND+self.NT+self.ND*self.NT
: 2+self.ND+self.NT+2*self.ND*self.NT
].reshape(self.NT,self.ND)
self.A = data[2+self.ND+self.NT+2*self.ND*self.NT
: 2+self.ND+self.NT+3*self.ND*self.NT
].reshape(self.NT,self.ND)
#self.S = data[2+self.ND+self.NT+3*self.ND*self.NT
# : 2+self.ND+self.NT+4*self.ND*self.NT
# ].reshape(self.NT,self.ND)
#self.cs = data[2+self.ND+self.NT+4*self.ND*self.NT
# : 2+self.ND+self.NT+5*self.ND*self.NT
# ].reshape(self.NT,self.ND)
#self.cv = data[2+self.ND+self.NT+5*self.ND*self.NT
# : 2+self.ND+self.NT+6*self.ND*self.NT
# ].reshape(self.NT,self.ND)
#self.KPA = data[2+self.ND+self.NT+6*self.ND*self.NT
# : 2+self.ND+self.NT+7*self.ND*self.NT
# ].reshape(self.NT,self.ND)
#
def loadextsesame(self, fname, unitstxt=None):
"""Function for loading EXTENDED SESAME-STYLE EOS table output from ANEOS"""
data = ([])
if unitstxt is None:
self.units = 'Units: rho g/cm3, T K, P GPa, U MJ/kg, A MJ/kg, S MJ/K/kg, cs cm/s, cv MJ/K/kg, KPA flag. 2D arrays are (NT,ND).'
else:
self.units = unitstxt
sesamefile = open(fname,"r")
sesamedata=sesamefile.readlines()
sesamefile.close()
nskip = 6 # skip standard header to get to the content of the 301 table
# num.density, num. temps
tmp = sesamedata[nskip][0:16]
dlen = float(tmp)
tmp = sesamedata[nskip][16:32]
tlen = float(tmp)
if (np.mod((dlen*tlen*4.0+dlen+tlen+2.0),5.0) == 0):
neos = int((dlen*tlen*4.0+dlen+tlen+2.0)/5.0)
else:
neos = int((dlen*tlen*4.0+dlen+tlen+2.0)/5.0) +1
#print(dlen,tlen,neos,len(sesamedata))
data = np.zeros((neos,5),dtype=float)
for j in range(nskip,neos+nskip):
tmp3 = sesamedata[j]
tmp4 = list(tmp3.split())
if len(tmp4) < 5:
lentmp4 = len(tmp4)
data[j-nskip,0:lentmp4] = np.asarray(tmp4[0:lentmp4])
else:
data[j-nskip,:] = np.asarray(tmp4)
#print(j,eosarr[j,:])
#print(data.shape)
data=np.resize(data,(neos*5))
#print(data.shape)
self.ND = data[0].astype(int) # now fill the extEOStable class
self.NT = data[1].astype(int)
self.rho = data[2:2+self.ND]
self.T = data[2+self.ND : 2+self.ND+self.NT]
#self.P = data[2+self.ND+self.NT : 2+self.ND+self.NT+self.ND*self.NT
# ].reshape(self.NT,self.ND)
#self.U = data[2+self.ND+self.NT+self.ND*self.NT
# : 2+self.ND+self.NT+2*self.ND*self.NT
# ].reshape(self.NT,self.ND)
#self.A = data[2+self.ND+self.NT+2*self.ND*self.NT
# : 2+self.ND+self.NT+3*self.ND*self.NT
# ].reshape(self.NT,self.ND)
self.S = data[2+self.ND+self.NT+0*self.ND*self.NT
: 2+self.ND+self.NT+1*self.ND*self.NT
].reshape(self.NT,self.ND)
self.cs = data[2+self.ND+self.NT+1*self.ND*self.NT
: 2+self.ND+self.NT+2*self.ND*self.NT
].reshape(self.NT,self.ND)
self.cv = data[2+self.ND+self.NT+2*self.ND*self.NT
: 2+self.ND+self.NT+3*self.ND*self.NT
].reshape(self.NT,self.ND)
self.KPA = data[2+self.ND+self.NT+3*self.ND*self.NT
: 2+self.ND+self.NT+4*self.ND*self.NT
].reshape(self.NT,self.ND)
#
def view(self, q='P', Tlow=None, Thigh=None, rholow=None, rhohigh=None):
"""Function for printing values from EXTENDED SESAME-STYLE EOS table."""
if Tlow is None:
Tlow = self.T.min()
if Thigh is None:
Thigh = self.T.max()
if rholow is None:
rholow = self.rho.min()
if rhohigh is None:
rhohigh = self.rho.max()
print(self.units)
if q == 'P':
print('T:', self.T[np.logical_and(self.T >= Tlow,self.T <= Thigh)])
print('rho:', self.rho[np.logical_and(self.rho >= rholow,
self.rho <= rhohigh)
])
print('P:', (self.P[np.logical_and(self.T >= Tlow,
self.T<=Thigh)
])[:, np.logical_and(self.rho >= rholow,
self.rho <= rhohigh)
])
if q == 'U':
print('T:', self.T[np.logical_and(self.T >= Tlow,self.T <= Thigh)])
print('rho:', self.rho[np.logical_and(self.rho >= rholow,
self.rho <= rhohigh)
])
print('U:', (self.U[np.logical_and(self.T >= Tlow,
self.T <= Thigh)
])[:, np.logical_and(self.rho >= rholow,
self.rho <= rhohigh)
])
if q == 'A':
print('T:', self.T[np.logical_and(self.T >= Tlow,self.T <= Thigh)])
print('rho:', self.rho[np.logical_and(self.rho >= rholow,
self.rho <= rhohigh)
])
print('A:', (self.A[np.logical_and(self.T >= Tlow,
self.T <= Thigh)
])[:, np.logical_and(self.rho >= rholow,
self.rho <= rhohigh)
])
if q == 'S':
print('T:', self.T[np.logical_and(self.T >= Tlow,self.T <= Thigh)])
print('rho:', self.rho[np.logical_and(self.rho
>= rholow,self.rho<=rhohigh)
])
print('S:', (self.S[np.logical_and(self.T >= Tlow,self.T <= Thigh)
])[:, np.logical_and(self.rho >= rholow,
self.rho <= rhohigh)
])
if q == 'cs':
print('T:', self.T[np.logical_and(self.T >= Tlow,self.T <= Thigh)])
print('rho:', self.rho[np.logical_and(self.rho >= rholow,
self.rho<=rhohigh)])
print('cs:', (self.cs[np.logical_and(self.T >= Tlow,
self.T <= Thigh)
])[:, np.logical_and(self.rho >= rholow,
self.rho <= rhohigh)
])
if q == 'cv':
print('T:', self.T[np.logical_and(self.T >= Tlow,self.T <= Thigh)])
print('rho:', self.rho[np.logical_and(self.rho >= rholow,
self.rho<=rhohigh)])
print('cv:', (self.cv[np.logical_and(self.T >= Tlow,
self.T <= Thigh)
])[:, np.logical_and(self.rho >= rholow,
self.rho <= rhohigh)
])
if q == 'KPA':
print('T:', self.T[np.logical_and(self.T >= Tlow,self.T <= Thigh)])
print('rho:', self.rho[np.logical_and(self.rho >= rholow,
self.rho<=rhohigh)])
print('KPA:', (self.KPA[np.logical_and(self.T >= Tlow,
self.T <= Thigh)
])[:, np.logical_and(self.rho >= rholow,
self.rho <= rhohigh)
])
def calchugoniot(self, r0=None, t0=None, pmax=None, writefilename=None):
"""Function for calculating a Hugoniot from EXTENDED SESAME-STYLE EOS table."""
if r0 is None:
return 'Must provide r0 and t0.'
if t0 is None:
return 'Must provide r0 and t0.'
if pmax is None:
pmax=1.E4 # GPa
self.hug.rho = []
self.hug.P = []
self.hug.T = []
self.hug.U = []
self.hug.S = []
self.hug.up = []
self.hug.us = []
self.hug.cs = []
it0 = int(np.round(np.interp(t0,self.T,np.arange(self.NT)))) # uses nearest value if t0 not in array
ir0 = int(np.round(np.interp(r0,self.rho,np.arange(self.ND)))) # uses nearest value if r0 not in the array
p0 = self.P[it0,ir0] # GPa
#print(self.P[it0,ir0])
e0 = self.U[it0,ir0]#np.interp(p0,self.P[it0,:],self.U[it0,:])
s0 = self.S[it0,ir0]#np.interp(p0,self.P[it0,:],self.S[it0,:])
up0 = 0. # no initial particle velocity
us0 = self.cs[it0,ir0]/1.e5 # cm/s->km/s use sound velocity for initial
cs0 = self.cs[it0,ir0]/1.e5 # cm/s->km/s use sound velocity for initial
#print(ir0,it0,r0,t0,p0,e0,up0,us0)
self.hug.rho = np.append(self.hug.rho, self.rho[ir0])
self.hug.P = np.append(self.hug.P, p0)
self.hug.T = np.append(self.hug.T, self.T[it0])
self.hug.U = np.append(self.hug.U, e0)
self.hug.S = np.append(self.hug.S, s0)
self.hug.up = np.append(self.hug.up, up0)
self.hug.us = np.append(self.hug.us, us0)
self.hug.cs = np.append(self.hug.cs, cs0)
#for iir in range(ir0+1,self.ND):
iir=ir0+1
pnew=p0
while pnew<pmax:
ediff =0.5*(self.P[it0::,iir]+p0)*(1./r0-1./self.rho[iir])+e0 -(self.U[it0::,iir]) # MJ/kg
# np.interp wants x values increasing
pnew = np.interp(0.,np.flip(ediff),np.flip(self.P[it0::,iir]))
tnew = np.interp(0.,np.flip(ediff),np.flip(self.T[it0::]))
enew = np.interp(0.,np.flip(ediff),np.flip(self.U[it0::,iir]))
snew = np.interp(0.,np.flip(ediff),np.flip(self.S[it0::,iir]))
upnew = np.sqrt((pnew-p0)*(1./r0-1./self.rho[iir]))
usnew = (1./r0)*np.sqrt((pnew-p0)/(1./r0-1./self.rho[iir]))
csnew = np.interp(0.,np.flip(ediff),np.flip(self.cs[it0::,iir]))/1.E5 # km/s
#print(self.rho[iir],tnew,pnew,enew,upnew,usnew)
self.hug.rho = np.append(self.hug.rho, self.rho[iir])
self.hug.P = np.append(self.hug.P, pnew)
self.hug.T = np.append(self.hug.T, tnew)
self.hug.U = np.append(self.hug.U, enew)
self.hug.S = np.append(self.hug.S, snew)
self.hug.up = np.append(self.hug.up, upnew)
self.hug.us = np.append(self.hug.us, usnew)
self.hug.cs = np.append(self.hug.cs, csnew) # km/s
iir += 1
self.hug.NH=len(self.hug.P)
self.hug.units='units: T K, rho g/cm3, P GPa, U MJ/kg, S MJ/K/kg, Up km/s, Us km/s, cs km/s'
if writefilename:
print('Writing Hugoniot to file: ',writefilename)
hugoniotfile = open(writefilename,"w")
hugoniotfile.writelines(' Hugoniot \n')
hugoniotfile.writelines(' Temperature, Density, Pressure, Int. Energy, Sp. Entropy, Part. Vel., Shock Vel. \n')
hugoniotfile.writelines(' K, g/cm3, GPa, MJ/kg, MJ/K/kg, km/s, km/s\n')
for iih in range(0,self.hug.NH):
hugoniotfile.write("%14.6e, %14.6e, %14.6e, %14.6e, %14.6e, %14.6e, %14.6e\n" % (
self.hug.T[iih],self.hug.rho[iih],self.hug.P[iih],self.hug.U[iih],self.hug.S[iih],self.hug.up[iih],self.hug.us[iih]))
hugoniotfile.close()
def calcOffEOSHugoniot(self, r0=None, t0=None, p0=None, e0=None, r1=None, pmax=None, writefilename=None):
"""Function for calculating a Hugoniot from EXTENDED SESAME-STYLE EOS table."""
if r0 is None:
return 'Must provide r0, t0, p0, e0.'
if t0 is None:
return 'Must provide r0, t0, p0, e0.'
if p0 is None:
return 'Must provide r0, t0, p0, e0.'
if e0 is None:
return 'Must provide r0, t0, p0, e0.'
if pmax is None:
pmax=1.E4 # GPa
self.hugo.rho = []
self.hugo.P = []
self.hugo.T = []
self.hugo.U = []
self.hugo.S = []
self.hugo.up = []
self.hugo.us = []
self.hugo.cs = []
print('r1=',r1)
it0 = int(np.round(np.interp(t0,self.T,np.arange(self.NT)))) # uses nearest value if t0 not in array
ir0 = int(np.round(np.interp(r1,self.rho,np.arange(self.ND)))) # start with full density
s0 = 0. # don't need it to get going
up0 = 0. # no initial particle velocity
us0 = self.cs[it0,ir0]/1.e5 # cm/s->km/s use sound velocity for initial
cs0 = self.cs[it0,ir0]/1.e5 # cm/s->km/s use sound velocity for initial
print(ir0,it0,r0,t0,p0,e0,up0,us0)
self.hugo.rho = np.append(self.hugo.rho, r0)
self.hugo.P = np.append(self.hugo.P, p0)
self.hugo.T = np.append(self.hugo.T, t0)
self.hugo.U = np.append(self.hugo.U, e0)
self.hugo.S = np.append(self.hugo.S, s0)
self.hugo.up = np.append(self.hugo.up, up0)
self.hugo.us = np.append(self.hugo.us, us0)
self.hugo.cs = np.append(self.hugo.cs, cs0)
#for iir in range(ir0+1,self.ND):
iir=ir0+1
pnew=p0
count=0
while pnew<pmax:
ediff =0.5*(self.P[it0::,iir]+p0)*(1./r0-1./self.rho[iir])+e0 -(self.U[it0::,iir]) # MJ/kg
# np.interp wants x values increasing
pnew = np.interp(0.,np.flip(ediff),np.flip(self.P[it0::,iir]))
tnew = np.interp(0.,np.flip(ediff),np.flip(self.T[it0::]))
enew = np.interp(0.,np.flip(ediff),np.flip(self.U[it0::,iir]))
snew = np.interp(0.,np.flip(ediff),np.flip(self.S[it0::,iir]))
upnew = np.sqrt((pnew-p0)*(1./r0-1./self.rho[iir]))
usnew = (1./r0)*np.sqrt((pnew-p0)/(1./r0-1./self.rho[iir]))
csnew = np.interp(0.,np.flip(ediff),np.flip(self.cs[it0::,iir]))/1.E5 # km/s
#print(self.rho[iir],tnew,pnew,enew,upnew,usnew)
self.hugo.rho = np.append(self.hugo.rho, self.rho[iir])
self.hugo.P = np.append(self.hugo.P, pnew)
self.hugo.T = np.append(self.hugo.T, tnew)
self.hugo.U = np.append(self.hugo.U, enew)
self.hugo.S = np.append(self.hugo.S, snew)
self.hugo.up = np.append(self.hugo.up, upnew)
self.hugo.us = np.append(self.hugo.us, usnew)
self.hugo.cs = np.append(self.hugo.cs, csnew) # km/s
count=count+1
iir += 1
self.hugo.NH=len(self.hug.P)
self.hugo.units='units: T K, rho g/cm3, P GPa, U MJ/kg, S MJ/K/kg, Up km/s, Us km/s, cs km/s'
if writefilename:
print('Writing Hugoniot to file: ',writefilename)
hugoniotfile = open(writefilename,"w")
hugoniotfile.writelines(' Hugoniot \n')
hugoniotfile.writelines(' Temperature, Density, Pressure, Int. Energy, Sp. Entropy, Part. Vel., Shock Vel. \n')
hugoniotfile.writelines(' K, g/cm3, GPa, MJ/kg, MJ/K/kg, km/s, km/s\n')
for iih in range(0,count):
hugoniotfile.write("%14.6e, %14.6e, %14.6e, %14.6e, %14.6e, %14.6e, %14.6e\n" % (
self.hugo.T[iih],self.hugo.rho[iih],self.hugo.P[iih],self.hugo.U[iih],self.hugo.S[iih],self.hugo.up[iih],self.hugo.us[iih]))
hugoniotfile.close()
###########################################################################################
# Functions added to be helpful for integration with the KO hydrocode
#
#
def querypt(self,rho,t):
"""Return EOS state for input (rho,t)"""
print('in query pt')
pt = EOSpoint()
# linearly interpolate the table for return the rho,t point values
rindex = np.where(self.rho >= rho)[0][0]
tindex = np.where(self.T >= t)[0][0]
P11 = self.P[tindex-1,rindex-1]
P21 = self.P[tindex,rindex-1]
P12 = self.P[tindex-1,rindex]
P22 = self.P[tindex,rindex]
U11 = self.U[tindex-1,rindex-1]
U21 = self.U[tindex,rindex-1]
U12 = self.U[tindex-1,rindex]
U22 = self.U[tindex,rindex]
r1 = np.log10(self.rho[rindex-1]) # try linearly interpreting on the log of the index
r2 = np.log10(self.rho[rindex])
t1 = np.log10(self.T[tindex-1])
t2 = np.log10(self.T[tindex])
logr = np.log10(rho)
logt = np.log10(t)
u1 = np.log10(U11) * (r2-logr)/(r2-r1) + np.log10(U12) * (logr-r1)/(r2-r1)
u2 = np.log10(U21) * (r2-logr)/(r2-r1) + np.log10(U22) * (logr-r1)/(r2-r1)
p1 = np.log10(P11) * (r2-logr)/(r2-r1) + np.log10(P12) * (logr-r1)/(r2-r1)
p2 = np.log10(P21) * (r2-logr)/(r2-r1) + np.log10(P22) * (logr-r1)/(r2-r1)
logp = p1 * (t2-logt)/(t2-t1) + p2 * (logt-t1)/(t2-t1)
pnew = np.power(10.,logp)
logu = u1 * (t2-logt)/(t2-t1) + u2 * (logt-t1)/(t2-t1)
unew = np.power(10.,logu)
pt.T = t
pt.rho = rho
pt.P = pnew
pt.U = unew
return pt
def queryptlin(self,rho,t):
"""Return EOS state for input (rho,t); linear EOS"""
print('in query pt')
pt = EOSpoint()
# linearly interpolate the table for return the rho,t point values
rindex = np.where(self.rho >= rho)[0][0]
tindex = np.where(self.T >= t)[0][0]
P11 = self.P[tindex-1,rindex-1]
P21 = self.P[tindex,rindex-1]
P12 = self.P[tindex-1,rindex]
P22 = self.P[tindex,rindex]
U11 = self.U[tindex-1,rindex-1]
U21 = self.U[tindex,rindex-1]
U12 = self.U[tindex-1,rindex]
U22 = self.U[tindex,rindex]
r1 = self.rho[rindex-1]
r2 = self.rho[rindex]
t1 = self.T[tindex-1]
t2 = self.T[tindex]
u1 = U11 * (r2-rho)/(r2-r1) + U12 * (rho-r1)/(r2-r1)
u2 = U21 * (r2-rho)/(r2-r1) + U22 * (rho-r1)/(r2-r1)
p1 = P11 * (r2-rho)/(r2-r1) + P12 * (rho-r1)/(r2-r1)
p2 = P21 * (r2-rho)/(r2-r1) + P22 * (rho-r1)/(r2-r1)
pnew = p1 * (t2-t)/(t2-t1) + p2 * (t-t1)/(t2-t1)
unew = u1 * (t2-t)/(t2-t1) + u2 * (t-t1)/(t2-t1)
pt.T = t
pt.rho = rho
pt.P = pnew
pt.U = unew
return pt
#
###########################################################################################
#
def writestdsesame(self, writestdsesfname=None):
"""Write standard Header-201-301 SESAME EOS TABULAR EOS FILE"""
# write a standard SESAME ascii file
# WRITE STANDARD Header-201-301 SESAME FILE
# WRITE SESAME 301 TABLE CONTAINS P, E, HFE
#sesfile = open("NEW-SESAME-STD-NOTENSION.EOSTXT","w")
if writestdsesfname is None:
print('Please provide a file name.')
exit(0)
sesfile = open(writestdsesfname,"w")
# WRITE SESAME HEADER INFORMATION: EOS matid number, number of words in section
# could input matid, date, version with the grid
# these parameters are set in the cell above that sets up the grid for ANEOS
# THEY SHOULD MATCH.......
# These variables are needed for the standard table output
NWDS=9
SESNTABLES=2.0
TABLE1 = 201.0
TABLE2 = 301.0
# 5 entries in 201 table
SESNWDS1=5.0
# Number of entries in STANDARD 301 table: 3 variables at each T,rho point
SESNWDS2=2.+self.ND+self.NT+self.ND*self.NT*3.
# HEADER SECTION
#sesfile.write("%14.6e, %14.6e, %14.6e, %14.6e, %14.6e, %14.6e, %14.6e\n" % (antarr[iit],rnew,pnew,enew,snew,upnew,usnew))
sesfile.write(" INDEX MATID ={:7d} NWDS = {:8d}\n".format(int(self.MATID), int(NWDS)))
sesfile.write("{:16.8e}{:16.8e}{:16.8e}{:16.8e}{:16.8e}\n".format(self.MATID, self.DATE, self.DATE, self.VERSION, SESNTABLES))
sesfile.write("{:16.8e}{:16.8e}{:16.8e}{:16.8e}\n".format(TABLE1, TABLE2, SESNWDS1, SESNWDS2))
# 201 SECTION
sesfile.write(" RECORD TYPE ={:5d} NWDS = {:8d}\n".format(int(TABLE1),int(SESNWDS1)))
sesfile.write("{:16.8e}{:16.8e}{:16.8e}{:16.8e}{:16.8e}\n".format(self.FMN, self.FMW, self.R0REF, self.K0REF, self.T0REF))
sesfile.write(" RECORD TYPE ={:5d} NWDS = {:8d}\n".format(int(TABLE2),int(SESNWDS2)))
sesfile.write("{:16.8e}{:16.8e}".format(self.ND, self.NT))
STYLE=2
# density array g/cm3
for k in range(0, int(self.ND)):
sesfile.write("{:16.8e}".format(self.rho[k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# temperature array K
for j in range(0, int(self.NT)):
sesfile.write("{:16.8e}".format(self.T[j]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# pressure array GPa P[tempindex,dindex]
for j in range(0,int(self.NT)):
for k in range(0,int(self.ND)):
sesfile.write("{:16.8e}".format(self.P[j,k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# specific internal energy array MJ/kg U[tempindex,dindex]
for j in range(0,int(self.NT)):
for k in range(0,int(self.ND)):
sesfile.write("{:16.8e}".format(self.U[j,k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# Helmholtz free energy array in MJ/kg A[tempindex,dindex]
for j in range(0,int(self.NT)):
for k in range(0,int(self.ND)):
sesfile.write("{:16.8e}".format(self.A[j,k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# close the SESAME TABLE FILE
sesfile.close()
print('Done writing the STD SESAME 301 table to local directory: ',writestdsesfname)
def writeextsesame(self, writeextsesfname=None):
"""Write standard Header-201-301 SESAME EOS TABULAR EOS FILE"""
# WRITE STANDARD Header-201-301 SESAME FILE
if writeextsesfname is None:
print('Please provide a file name.')
exit(0)
sesfile = open(writeextsesfname,"w")
# WRITE SESAME HEADER INFORMATION: EOS matid number, number of words in section
# could input matid, date, version with the grid
# these parameters are set in the cell above that sets up the grid for ANEOS
# THEY SHOULD MATCH.......
# These variables are needed for the standard table output
NWDS=9
SESNTABLES=2.0
TABLE1 = 201.0
TABLE2 = 301.0
# 5 entries in 201 table
SESNWDS1=5.0
# Number of entries in STANDARD 301 table: 3 variables at each T,rho point
SESNWDS2=2.+self.ND+self.NT+self.ND*self.NT*3.
# HEADER SECTION
#sesfile.write("%14.6e, %14.6e, %14.6e, %14.6e, %14.6e, %14.6e, %14.6e\n" % (antarr[iit],rnew,pnew,enew,snew,upnew,usnew))
sesfile.write(" INDEX MATID ={:7d} NWDS = {:8d}\n".format(int(self.MATID), int(NWDS)))
sesfile.write("{:16.8e}{:16.8e}{:16.8e}{:16.8e}{:16.8e}\n".format(self.MATID, self.DATE, self.DATE, self.VERSION, SESNTABLES))
sesfile.write("{:16.8e}{:16.8e}{:16.8e}{:16.8e}\n".format(TABLE1, TABLE2, SESNWDS1, SESNWDS2))
# 201 SECTION
sesfile.write(" RECORD TYPE ={:5d} NWDS = {:8d}\n".format(int(TABLE1),int(SESNWDS1)))
sesfile.write("{:16.8e}{:16.8e}{:16.8e}{:16.8e}{:16.8e}\n".format(self.FMN, self.FMW, self.R0REF, self.K0REF, self.T0REF))
sesfile.write(" RECORD TYPE ={:5d} NWDS = {:8d}\n".format(int(TABLE2),int(SESNWDS2)))
sesfile.write("{:16.8e}{:16.8e}".format(self.ND, self.NT))
STYLE=2
#NEW-SESAME-EXT.TXT: SESAME-style table with extra variables from ANEOS. Contains the standard 201 table and non-standard 301-extra-variables EOS table. The 301 table has: density grid values, temperature grid values, sp. entropy(T,rho), sound speed(T,rho), sp. heat capacity(T,rho), KPA flag(T,rho). 2-D arrays list all densities, looping over each temperature. 301 table units: g/cm$^3$, K, MJ/K/kg, cm/s, MJ/K/kg, integer flag, integer flag. The KPA flag is an ANEOS output with phase information. <br>
# density array g/cm3
for k in range(0, int(self.ND)):
sesfile.write("{:16.8e}".format(self.rho[k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# temperature array K
for j in range(0, int(self.NT)):
sesfile.write("{:16.8e}".format(self.T[j]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# specific entropy array MJ/K/kg S[tempindex,dindex]
for j in range(0,int(self.NT)):
for k in range(0,int(self.ND)):
sesfile.write("{:16.8e}".format(self.S[j,k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# sound speed array cm/s cs[tempindex,dindex]
for j in range(0,int(self.NT)):
for k in range(0,int(self.ND)):
sesfile.write("{:16.8e}".format(self.cs[j,k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# sp. heat capacity array in MJ/K/kg cv[tempindex,dindex]
for j in range(0,int(self.NT)):
for k in range(0,int(self.ND)):
sesfile.write("{:16.8e}".format(self.cv[j,k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# phase flag [integer] KPA[tempindex,dindex]
for j in range(0,int(self.NT)):
for k in range(0,int(self.ND)):
sesfile.write("{:16.8e}".format(self.KPA[j,k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# close the SESAME TABLE FILE
sesfile.close()
print('Done writing the EXT SESAME 301 table to local directory: ',writeextsesfname)
def writegadgetinitsesame(self, writegadgetinitsesfname=None):
"""Write standard Header-201-301 SESAME EOS TABULAR EOS FILE"""
# write a standard SESAME ascii file
# WRITE GADGET INIT Header-201-301 SESAME FILE
# WRITE SESAME 301 TABLE CONTAINS P, E, S
#sesfile = open("NEW-SESAME-GADGETINIT-NOTENSION.EOSTXT","w")
if writegadgetinitsesfname is None:
print('Please provide a file name.')
exit(0)
sesfile = open(writegadgetinitsesfname,"w")
# WRITE SESAME HEADER INFORMATION: EOS matid number, number of words in section
# could input matid, date, version with the grid
# these parameters are set in the cell above that sets up the grid for ANEOS
# THEY SHOULD MATCH.......
# These variables are needed for the standard table output
NWDS=9
SESNTABLES=2.0
TABLE1 = 201.0
TABLE2 = 301.0
# 5 entries in 201 table
SESNWDS1=5.0
# Number of entries in STANDARD 301 table: 3 variables at each T,rho point
SESNWDS2=2.+self.ND+self.NT+self.ND*self.NT*3.
# HEADER SECTION
#sesfile.write("%14.6e, %14.6e, %14.6e, %14.6e, %14.6e, %14.6e, %14.6e\n" % (antarr[iit],rnew,pnew,enew,snew,upnew,usnew))
sesfile.write(" INDEX MATID ={:7d} NWDS = {:8d}\n".format(int(self.MATID), int(NWDS)))
sesfile.write("{:16.8e}{:16.8e}{:16.8e}{:16.8e}{:16.8e}\n".format(self.MATID, self.DATE, self.DATE, self.VERSION, SESNTABLES))
sesfile.write("{:16.8e}{:16.8e}{:16.8e}{:16.8e}\n".format(TABLE1, TABLE2, SESNWDS1, SESNWDS2))
# 201 SECTION
sesfile.write(" RECORD TYPE ={:5d} NWDS = {:8d}\n".format(int(TABLE1),int(SESNWDS1)))
sesfile.write("{:16.8e}{:16.8e}{:16.8e}{:16.8e}{:16.8e}\n".format(self.FMN, self.FMW, self.R0REF, self.K0REF, self.T0REF))
sesfile.write(" RECORD TYPE ={:5d} NWDS = {:8d}\n".format(int(TABLE2),int(SESNWDS2)))
sesfile.write("{:16.8e}{:16.8e}".format(self.ND, self.NT))
STYLE=2
# density array g/cm3
for k in range(0, int(self.ND)):
sesfile.write("{:16.8e}".format(self.rho[k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# temperature array K
for j in range(0, int(self.NT)):
sesfile.write("{:16.8e}".format(self.T[j]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# pressure array GPa P[tempindex,dindex]
for j in range(0,int(self.NT)):
for k in range(0,int(self.ND)):
sesfile.write("{:16.8e}".format(self.P[j,k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# specific internal energy array MJ/kg U[tempindex,dindex]
for j in range(0,int(self.NT)):
for k in range(0,int(self.ND)):
sesfile.write("{:16.8e}".format(self.U[j,k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# specific entropy array in MJ/kg/K S[tempindex,dindex]
for j in range(0,int(self.NT)):
for k in range(0,int(self.ND)):
sesfile.write("{:16.8e}".format(self.S[j,k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# close the SESAME TABLE FILE
sesfile.close()
print('Done writing the GADGET INIT SESAME 301 notension table to local directory: ',writegadgetinitsesfname)
def writemdqsesame(self, writemdqsesfname=None):
"""Function to write a sesame 301-style ascii file with the MDQ variable"""
if writemdqsesfname is None:
print('Please provide a file name.')
exit(0)
sesfile = open(writemdqsesfname,"w")
sesfile.write("{:16.8e}{:16.8e}".format(self.ND, self.NT))
STYLE=2
# density array g/cm3
for k in range(0, int(self.ND)):
sesfile.write("{:16.8e}".format(self.rho[k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# temperature array K
for j in range(0, int(self.NT)):
sesfile.write("{:16.8e}".format(self.T[j]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# MDQ Flag[tempindex,dindex]
for j in range(0,int(self.NT)):
for k in range(0,int(self.ND)):
sesfile.write("{:16.8e}".format(self.MDQ[j,k]))
STYLE=STYLE+1
if (np.mod(STYLE,5) == 0):
sesfile.write("\n")
# close the SESAME TABLE FILE
sesfile.close()
print('Done writing the MDQ Flag as a 301-style table to local directory: ',writemdqsesfname)
def loadaneos(self, aneosinfname=None, aneosoutfname=None, silent=False):
"""Function for reading in ANEOS INPUT and OUTPUT FILE DATA into EOS structure."""
if aneosinfname is None:
return 'Must provide input file name.'
if aneosoutfname is None:
return 'Must provide output file name.'
# function to gather data from ANEOS input and output files
# SESAME FILE HEADER INFORMATION MUST BE LOADED INTO THE EOS STRUCTURE BEFORE CALLING THIS FUNCTION
#
# READ IN ANEOS INPUT FILE
aneosinputfile = open(aneosinfname,"r")
testin=aneosinputfile.readlines() # read in the whole ascii file at once because this is fatser
aneosinputfile.close()
# gather EOS information from the ANEOS.OUTPUT file
aneosoutputfile = open(aneosoutfname,"r")
testout=aneosoutputfile.readlines() # read everything in at once because this is faster
aneosoutputfile.close()
if silent == False:
print('Done loading ANEOS files.')
# THIS CODE PARSES THE ANEOS.OUTPUT FILE INTO ARRAYS FOR USE IN PLOTTING/USING THE EOS
if silent == False:
print('ANEOS WAS CALLED WITH THE FOLLOWING INPUT, LOADED FROM FILE ',aneosinfname)
# Gather parameters for the gamma function while printing the ANEOS INPUT FILE
aneoscount=1
for i in np.arange(len(testin)):
if testin[i].find('ANEOS') == 0:
if aneoscount<9:
if silent == False:
print(' '+testin[i-3],testin[i-2],testin[i-1],testin[i])
aneoscount=aneoscount+1
else:
if silent == False:
print(' '+testin[i])
if testin[i].find('ANEOS2') == 0:
tmp=testin[i]
nelem=int(tmp[10:20])
#print('nelem=',nelem)
rho0=float(tmp[30:40])
print('rho0=',rho0)
gamma0=float(tmp[70:80])
#print('gamma0=',gamma0)
theta0=float(tmp[80:90])
if testin[i].find('ANEOS3') == 0:
tmp=testin[i]
C24=float(tmp[20:30])/3.
#print('C24=',C24)
if testin[i].find('ANEOS5') == 0:
tmp=testin[i]
C60=float(tmp[60:70])
C61=float(tmp[70:80])
#print('C60=',C60)
if testin[i].find('ANEOS7') == 0:
tmp=testin[i]
betagamma=float(tmp[70:80])
# some checks
if rho0 != self.R0REF:
#print('WARNING: rho0 does not match. ')
#assert(False) # just a way to stop the notebook
print('WARNING: rho0 does not match. STOPPING THIS NOTEBOOK.')
assert(False) # just a way to stop the notebook
# GUESS A BIG ARRAY SIZE FOR THE PHASE BOUNDARIES AND HUGONIOT IN ANEOS.OUTPUT
# the melt curve, vapor curve and Hugoniot curves are not fixed length outputs
nleninit=300
meltcurve = 0
if silent == False:
print('READING DATA FROM ANEOS OUTPUT FILE ',aneosoutfname)
# Read in data from the ANEOS.OUTPUT FILE
imc = -1 # flag for no melt curve in the model
for i in np.arange(len(testout)):
if testout[i].find(' Data for ANEOS number') == 0:
tmp = testout[i+2][0:50]
eosname = tmp.strip()