Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NP_TMcode
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giacomo Mulas
NP_TMcode
Commits
47ee8b28
Commit
47ee8b28
authored
3 months ago
by
Giovanni La Mura
Browse files
Options
Downloads
Patches
Plain Diff
Fix optical constant sorting in inclusion model maker
parent
81e351ee
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scripts/model_maker.py
+32
-25
32 additions, 25 deletions
src/scripts/model_maker.py
with
32 additions
and
25 deletions
src/scripts/model_maker.py
+
32
−
25
View file @
47ee8b28
...
...
@@ -164,9 +164,10 @@ def load_model(model_file):
sconf
[
'
nshl
'
]
=
[
0
for
i
in
range
(
sconf
[
'
configurations
'
])]
for
i
in
range
(
sconf
[
'
configurations
'
]):
sconf
[
'
nshl
'
][
i
]
=
int
(
model
[
'
particle_settings
'
][
'
n_layers
'
][
i
])
if
(
sconf
[
'
application
'
]
==
"
INCLUSION
"
):
sconf
[
'
nshl
'
][
0
]
+=
1
max_layers
=
max
(
sconf
[
'
nshl
'
])
if
(
sconf
[
'
application
'
]
==
"
INCLUSION
"
):
if
(
max_layers
<
sconf
[
'
nshl
'
][
0
]
+
1
):
max_layers
=
sconf
[
'
nshl
'
][
0
]
+
1
if
(
num_dielec
!=
sconf
[
'
configurations
'
]):
print
(
"
ERROR: declared array of optical constants does not match configurations!
"
)
return
(
None
,
None
)
...
...
@@ -176,8 +177,11 @@ def load_model(model_file):
[
0
for
j
in
range
(
max_layers
)]
for
i
in
range
(
sconf
[
'
configurations
'
])
]
for
i
in
range
(
sconf
[
'
configurations
'
]):
if
(
len
(
model
[
'
particle_settings
'
][
'
dielec_id
'
][
i
])
!=
1
+
int
(
sconf
[
'
nshl
'
][
i
]
/
2
)):
print
(
"
ERROR: Declared materials in type %d do not match number of layers!
"
%
(
i
+
1
))
expected_layer_num
=
1
+
int
(
sconf
[
'
nshl
'
][
i
]
/
2
)
if
(
sconf
[
'
application
'
]
==
"
INCLUSION
"
and
i
==
0
):
expected_layer_num
+=
1
if
(
len
(
model
[
'
particle_settings
'
][
'
dielec_id
'
][
i
])
!=
expected_layer_num
):
print
(
"
ERROR: Declared materials in type %d do not match the number of layers!
"
%
(
i
+
1
))
return
(
None
,
None
)
else
:
for
j
in
range
(
1
+
int
(
sconf
[
'
nshl
'
][
i
]
/
2
)):
...
...
@@ -268,11 +272,17 @@ def load_model(model_file):
[
0.0
for
j
in
range
(
max_layers
)]
for
i
in
range
(
sconf
[
'
configurations
'
])
]
for
i
in
range
(
sconf
[
'
configurations
'
]):
if
(
len
(
model
[
'
particle_settings
'
][
'
rad_frac
'
][
i
])
!=
sconf
[
'
nshl
'
][
i
]):
print
(
"
ERROR: Declared transition radii in type %d do not match number of layers!
"
%
i
)
expected_radii
=
sconf
[
'
nshl
'
][
i
]
if
(
sconf
[
'
application
'
]
==
"
INCLUSION
"
and
i
==
0
):
expected_radii
+=
1
if
(
len
(
model
[
'
particle_settings
'
][
'
rad_frac
'
][
i
])
!=
expected_radii
):
print
(
"
ERROR: Declared transition radii in type %d do not match the number of layers!
"
%
(
i
+
1
))
return
(
None
,
None
)
else
:
for
j
in
range
(
sconf
[
'
nshl
'
][
i
]):
expected_radii
=
sconf
[
'
nshl
'
][
i
]
if
(
sconf
[
'
application
'
]
==
"
INCLUSION
"
and
i
==
0
):
expected_radii
+=
1
for
j
in
range
(
expected_radii
):
sconf
[
'
rcf
'
][
i
][
j
]
=
float
(
model
[
'
particle_settings
'
][
'
rad_frac
'
][
i
][
j
])
# Create the gconf dict
str_polar
=
model
[
'
radiation_settings
'
][
'
polarization
'
]
...
...
@@ -356,7 +366,10 @@ def match_grid(sconf):
nxi
=
0
sconf
[
'
vec_xi
'
]
=
[]
for
i
in
range
(
sconf
[
'
configurations
'
]):
for
j
in
range
(
sconf
[
'
nshl
'
][
i
]):
layers
=
sconf
[
'
nshl
'
][
i
]
if
(
sconf
[
'
application
'
]
==
"
INCLUSION
"
and
i
==
0
):
layers
+=
1
for
j
in
range
(
layers
):
file_idx
=
sconf
[
'
dielec_id
'
][
i
][
j
]
dielec_path
=
PurePath
(
sconf
[
'
dielec_path
'
],
sconf
[
'
dielec_file
'
][
int
(
file_idx
)
-
1
])
file_name
=
str
(
dielec_path
)
...
...
@@ -377,6 +390,8 @@ def match_grid(sconf):
if
(
max_layers
==
0
):
# This is executed only once
max_layers
=
max
(
sconf
[
'
nshl
'
])
if
(
sconf
[
'
application
'
]
==
"
INCLUSION
"
and
max_layers
<
sconf
[
'
nshl
'
][
0
]
+
1
):
max_layers
=
sconf
[
'
nshl
'
][
0
]
+
1
w_start
=
sconf
[
'
xi_start
'
]
w_end
=
sconf
[
'
xi_end
'
]
for
wi
in
range
(
len
(
wavelengths
)):
...
...
@@ -553,11 +568,11 @@ def write_legacy_sconf(conf):
output
.
write
(
"
\n
"
)
for
ci
in
range
(
conf
[
'
configurations
'
]):
layers
=
conf
[
'
nshl
'
][
ci
]
if
(
conf
[
'
application
'
]
==
"
INCLUSION
"
and
ci
==
0
):
layers
-=
1
str_line
=
"
{0:3d} {1:15.7E}
\n
"
.
format
(
layers
,
conf
[
'
ros
'
][
ci
])
output
.
write
(
str_line
)
for
cj
in
range
(
conf
[
'
nshl
'
][
ci
]):
if
(
conf
[
'
application
'
]
==
"
INCLUSION
"
and
ci
==
0
):
layers
+=
1
for
cj
in
range
(
layers
):
str_line
=
"
{0:.7E}
\n
"
.
format
(
conf
[
'
rcf
'
][
ci
][
cj
])
output
.
write
(
str_line
)
if
(
conf
[
'
application
'
]
!=
"
INCLUSION
"
):
...
...
@@ -585,35 +600,27 @@ def write_legacy_sconf(conf):
# Write all layers in each configuration for every wavelength
for
xk
in
range
(
conf
[
'
nxi
'
]):
for
xi
in
range
(
conf
[
'
configurations
'
]):
layers
=
1
+
int
(
conf
[
'
nshl
'
][
xi
])
-
1
layers
=
int
(
conf
[
'
nshl
'
][
xi
])
if
(
xi
==
0
):
layers
+=
1
for
xj
in
range
(
layers
):
rdc0
=
conf
[
'
rdc0
'
][
xj
][
xi
][
xk
]
idc0
=
conf
[
'
idc0
'
][
xj
][
xi
][
xk
]
if
(
rdc0
!=
0.0
or
idc0
!=
0.0
):
str_line
=
"
({0:11.5E},{1:11.5E})
\n
"
.
format
(
rdc0
,
idc0
)
output
.
write
(
str_line
)
if
(
xi
==
conf
[
'
configurations
'
]
-
1
):
rdc0
=
conf
[
'
rdc0
'
][
layers
][
0
][
xk
]
idc0
=
conf
[
'
idc0
'
][
layers
][
0
][
xk
]
if
(
rdc0
!=
0.0
or
idc0
!=
0.0
):
str_line
=
"
({0:11.5E},{1:11.5E})
\n
"
.
format
(
rdc0
,
idc0
)
output
.
write
(
str_line
)
elif
(
conf
[
'
idfc
'
]
==
-
1
):
# Write reference scale constants for each layer in each configuration
for
xi
in
range
(
conf
[
'
configurations
'
]):
layers
=
1
+
int
(
conf
[
'
nshl
'
][
xi
])
-
1
layers
=
int
(
conf
[
'
nshl
'
][
xi
])
if
(
xi
==
0
):
layers
+=
1
for
xj
in
range
(
layers
):
rdc0
=
conf
[
'
rdc0
'
][
xj
][
xi
][
0
]
idc0
=
conf
[
'
idc0
'
][
xj
][
xi
][
0
]
if
(
rdc0
!=
0.0
or
idc0
!=
0.0
):
str_line
=
"
({0:11.5E},{1:11.5E})
\n
"
.
format
(
rdc0
,
idc0
)
output
.
write
(
str_line
)
if
(
xi
==
conf
[
'
configurations
'
]
-
1
):
rdc0
=
conf
[
'
rdc0
'
][
layers
][
0
][
0
]
idc0
=
conf
[
'
idc0
'
][
layers
][
0
][
0
]
if
(
rdc0
!=
0.0
or
idc0
!=
0.0
):
str_line
=
"
({0:11.5E},{1:11.5E})
\n
"
.
format
(
rdc0
,
idc0
)
output
.
write
(
str_line
)
output
.
write
(
"
0
\n
"
)
output
.
close
()
return
result
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment