-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_data.py
More file actions
109 lines (87 loc) · 3.04 KB
/
read_data.py
File metadata and controls
109 lines (87 loc) · 3.04 KB
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
import numpy as np
import csv
elementAtomicNumbers = {
"La": 57,
"Ce": 58,
"Pr": 59,
"Nd": 60,
"Pm": 61,
"Sm": 62,
"Eu": 63,
"Gd": 64,
"Tb": 65,
"Dy": 66,
"Ho": 67,
"Er": 68,
"Tm": 69,
"Yb": 70,
"Lu": 71
}
mixtureRatios = [0.75, 0.625, 0.5, 0.375, 0.25]
def readData(filepath):
res = []
with open(filepath) as file:
# skip first row
file.__next__()
for row in file:
rowSplit = row.split()
element1, element2 = elementAtomicNumbers[rowSplit[0]], elementAtomicNumbers[rowSplit[1]]
for i in range(len(mixtureRatios)):
x = mixtureRatios[i]
HE = float(rowSplit[2 + i])
res.append([element1, element2, x, HE])
return np.array(res)
def readCSVData(filepath, separator=";", material="monazite", bulkshear=False, Volume=False):
res = []
with open(filepath) as file:
# skip first row
file.__next__()
csv_reader = csv.reader(file, delimiter=separator)
for row in csv_reader:
# element = elementAtomicNumbers[row[0]]
Z = int(row[1])
atomicMass = float(row[2])
if material == "xenotime":
#print("read data for xenozite")
R = float(row[3])
else:
R = float(row[4])
IP2 = float(row[5])
IP3 = float(row[6])
electronegativity = float(row[7])
E = float(row[8])
nuclearCharge = float(row[9])
density = float(row[10])
bulkmodulus = float(row[11])
shearmodulus = float(row[12])
Vol = float(row[13])
if bulkshear:
if Volume:
res.append([Z, atomicMass, IP2, E, nuclearCharge, bulkmodulus, shearmodulus, electronegativity, IP3, Vol, R])
else:
res.append([Z, atomicMass, IP2, E, nuclearCharge, bulkmodulus, shearmodulus, electronegativity, IP3, R])
else:
if Volume:
res.append([Z, atomicMass, IP2, E, nuclearCharge, electronegativity, IP3, Vol, R])
else:
res.append([Z, atomicMass, IP2, E, nuclearCharge, electronegativity, IP3, R])
return np.array(res)
def readCSVData_simplified(filepath, separator=";", material="monazite", R=False):
res = []
with open(filepath) as file:
# skip first row
file.__next__()
csv_reader = csv.reader(file, delimiter=separator)
for row in csv_reader:
if R:
if material == "xenotime":
R = float(row[3])
else:
R = float(row[4])
E = float(row[8])
res.append([E, R])
else:
E = float(row[8])
Vol = float(row[13])
res.append([E, Vol])
return np.array(res)