-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathPyrough.py
More file actions
237 lines (219 loc) · 8.56 KB
/
Pyrough.py
File metadata and controls
237 lines (219 loc) · 8.56 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
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
# Title: Main code Pyrough
# Authors: Jonathan Amodeo, Hugo Iteney, Javier Gonzalez, Jennifer Izaguirre, Christophe Le Bourlot
# Date: June 01, 2022
#
# Pyrough generates 3D virtual samples with rough surfaces for atomistic and finite-element simulations.
# Several objects such as spheres, cubes, Wulff-shaped systems or wires can be generated.
# Additional options allowing to generate rough GBs or post-treat experimental images are also available.
# Various output formats are handled including .stl, .msh, .xyz, .lmp, etc.
# Example input .json files are provided in the examples/ folder, have a look !
# ---------------------------------------------------------------------------
import os
import subprocess
import sys
from src import Param_class, Sample_class, Func_pyrough as fp
print("##################################################################")
print("# /\\/\\/\\ #")
print("# | O _ | Pyrough #")
print("# <|-|--/ Version 1.2 #")
print("# \\---|-|> (C) 2023 Jonathan Amodeo and co. #")
print("# | _ O | https://github.com/jamodeo12/Pyrough #")
print("# \\/\\/\\/ #")
print("##################################################################")
# _____________________Main Code____________________
if sys.argv[1] == "-surface":
# -surface : Image characterization and digital twin generation
print("====== > Pyrough.py : surface analysis treatment running...")
current_dir = os.path.dirname(os.path.abspath(__file__))
subprocess.call(
[
"python",
current_dir + "/src/Surface_Analysis.py",
sys.argv[2],
sys.argv[3],
sys.argv[4],
sys.argv[5],
]
)
elif sys.argv[1] == "-test_pyrough_execution":
# -test_pyrough_execution : test if all examples/*.json files can be processed
print("====== > Pyrough.py : test_pyrough_execution running...")
print("====== > Pyrough.py : check/execute all .json files in examples folder")
current_dir = os.path.dirname(os.path.abspath(__file__))
fp.test_pyrough_execution(current_dir)
else:
# If no specific option, we generate a rough sample
# Parameter file definition
print("====== > Pyrough.py : parameter file definition running...")
Param_file = sys.argv[1]
out_pre = os.path.basename(Param_file)[:-5]
param = Param_class.Parameter(Param_file)
if param.type_S == "grain":
# If grain, we first create the mesh of a rough box
# the STL file will be used to make grain 1, while its negative will be used for grain 2
print("====== > Pyrough.py : grain option treatment running...")
print("====== > Pyrough.py : Sample_class.make_box running...")
vertices, FEM_stl, rot_FEM_stl = Sample_class.make_box(
param.type_S,
2 * (1 + param.eta),
param.C1,
param.RMS,
param.N,
param.M,
param.length,
param.height,
param.width,
param.ns,
param.alpha,
param.raw_stl,
param.angles,
out_pre,
param.ext_fem,
)
subprocess.call(["rm", rot_FEM_stl])
print("====== > Pyrough.py : Sample_class.make_atom_grain running...")
Sample_class.make_atom_grain(
FEM_stl,
param.lattice_structure1,
param.lattice_parameter1,
param.material1,
param.orien_x1,
param.orien_y1,
param.orien_z1,
param.lattice_structure2,
param.lattice_parameter2,
param.material2,
param.orien_x2,
param.orien_y2,
param.orien_z2,
vertices,
out_pre,
param.ext_ato,
)
# call make it md to create atomsk file
print("JOB DONE!" + " File name: " + out_pre + ".lmp")
elif param.type_S == "multi_layered" :
# If grain, we first create the mesh of a rough box
# the STL file will be used to make grain 1, while its negative will be used for grain 2
print("====== > Pyrough.py : multi_layered option treatment running...")
print("====== > Pyrough.py : Sample_class.make_atom_multi-layered running...")
Sample_class.make_atom_multilayered(
param.type_S,
param.height_layer,
param.pattern_layer,
2 * (1 + param.eta),
param.C1,
param.RMS,
param.N,
param.M,
param.length,
param.height,
param.width,
param.ns,
param.alpha,
param.raw_stl,
param.lattice_structure,
param.lattice_parameter,
param.material,
param.orien_x,
param.orien_y,
param.orien_z,
out_pre,
param.ext_fem,
param.ext_ato,
)
else:
print("====== > Pyrough.py : {} option treatment running...".format(param.type_S))
sample = Sample_class.Sample(param.type_S)
print("====== > Pyrough.py : sample.make_stl running...")
vertices, FEM_stl, rot_FEM_stl = sample.make_stl(
param.type_S,
param.eta,
param.C1,
param.RMS,
param.N,
param.M,
param.radius,
param.length,
param.height,
param.width,
param.ns,
param.alpha,
param.raw_stl,
param.nfaces,
param.surfaces,
param.energies,
param.n_at,
param.lattice_structure,
param.lattice_parameter,
param.material,
param.orien_x,
param.orien_z,
param.angles,
out_pre,
param.ext_fem,
)
print("====== > FEM JOB DONE !")
for ext in param.ext_fem:
print("====== > File name: " + out_pre + "." + str(ext))
if "stl" not in param.ext_fem:
print("====== > File name: " + out_pre + ".stl")
if param.output(Param_file) == "ATOM" and not hasattr(param, "spec"):
print("====== > Pyrough.py : sample.make_atom running...")
subprocess.call(["rm", rot_FEM_stl])
sample.make_atom(
FEM_stl,
param.lattice_structure,
param.lattice_parameter,
param.material,
param.orien_x,
param.orien_y,
param.orien_z,
vertices,
param.angles2,
out_pre,
param.ext_ato,
)
# call make it md to create atomsk file
print("====== > ATOM OBJECT JOB DONE !")
for ext in param.ext_ato:
print("====== > File name: " + out_pre + "." + str(ext))
if hasattr(param, "spec"):
if param.spec == "precinmatrix":
print("====== > Pyrough.py : precinmatric option treatment running...")
print("====== > sample.make_precipitate running")
# Generate the precipitate centered in the matrix-sized supercell : precipitate.lmp
sample.make_precipitate(
FEM_stl,
param.lattice_structure,
param.lattice_parameter,
param.material,
param.orien_x,
param.orien_y,
param.orien_z,
param.length_x2,
param.length_y2,
param.length_z2,
param.angles2,
param.precpos,
)
print("====== > sample.make_atom_matrix running")
sample.make_atom_matrix(
rot_FEM_stl,
param.length_x2,
param.length_y2,
param.length_z2,
param.lattice_structure2,
param.lattice_parameter2,
param.material2,
param.orien_x2,
param.orien_y2,
param.orien_z2,
param.precpos,
)
print("====== > sample.put_prec_in_matrix running...")
sample.put_prec_in_matrix(
out_pre,
param.ext_ato
)
print("====== > ATOM PRECIPITATE IN MATRIX JOB DONE !")