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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giacomo Mulas
NP_TMcode
Commits
923255b1
Commit
923255b1
authored
2 months ago
by
Giovanni La Mura
Browse files
Options
Downloads
Patches
Plain Diff
Prepare model_maker to accept random generators
parent
27676c69
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
+22
-12
22 additions, 12 deletions
src/scripts/model_maker.py
with
22 additions
and
12 deletions
src/scripts/model_maker.py
+
22
−
12
View file @
923255b1
...
@@ -247,7 +247,7 @@ def load_model(model_file):
...
@@ -247,7 +247,7 @@ def load_model(model_file):
print
(
"
ERROR: %s is not a supported scaling mode!
"
%
(
model
[
'
radiation_settings
'
][
'
scale_name
'
]))
print
(
"
ERROR: %s is not a supported scaling mode!
"
%
(
model
[
'
radiation_settings
'
][
'
scale_name
'
]))
return
(
None
,
None
)
return
(
None
,
None
)
sph_types
=
model
[
'
particle_settings
'
][
'
sph_types
'
]
sph_types
=
model
[
'
particle_settings
'
][
'
sph_types
'
]
if
(
len
(
sph_types
)
!=
sconf
[
'
nsph
'
]):
if
(
len
(
sph_types
)
!=
sconf
[
'
nsph
'
]
and
len
(
sph_types
)
!=
0
):
print
(
"
ERROR: vector of sphere types does not match the declared number of spheres!
"
)
print
(
"
ERROR: vector of sphere types does not match the declared number of spheres!
"
)
return
(
None
,
None
)
return
(
None
,
None
)
else
:
else
:
...
@@ -313,15 +313,25 @@ def load_model(model_file):
...
@@ -313,15 +313,25 @@ def load_model(model_file):
gconf
[
'
vec_sph_y
'
]
=
[
0.0
for
i
in
range
(
gconf
[
'
nsph
'
])]
gconf
[
'
vec_sph_y
'
]
=
[
0.0
for
i
in
range
(
gconf
[
'
nsph
'
])]
gconf
[
'
vec_sph_z
'
]
=
[
0.0
for
i
in
range
(
gconf
[
'
nsph
'
])]
gconf
[
'
vec_sph_z
'
]
=
[
0.0
for
i
in
range
(
gconf
[
'
nsph
'
])]
if
(
gconf
[
'
application
'
]
!=
"
SPHERE
"
or
gconf
[
'
nsph
'
]
!=
1
):
if
(
gconf
[
'
application
'
]
!=
"
SPHERE
"
or
gconf
[
'
nsph
'
]
!=
1
):
# TODO: put here a test to allow for empty vectors in case of random generation
if
(
len
(
model
[
'
geometry_settings
'
][
'
x_coords
'
])
!=
len
(
model
[
'
geometry_settings
'
][
'
y_coords
'
])):
if
(
len
(
model
[
'
geometry_settings
'
][
'
x_coords
'
])
!=
gconf
[
'
nsph
'
]):
print
(
"
ERROR: X and Y coordinate vectors have different lengths!
"
)
print
(
"
ERROR: X coordinates do not match the number of spheres!
"
)
return
(
None
,
None
)
if
(
len
(
model
[
'
geometry_settings
'
][
'
x_coords
'
])
!=
len
(
model
[
'
geometry_settings
'
][
'
z_coords
'
])):
print
(
"
ERROR: X and Z coordinate vectors have different lengths!
"
)
return
(
None
,
None
)
if
(
len
(
model
[
'
geometry_settings
'
][
'
y_coords
'
])
!=
len
(
model
[
'
geometry_settings
'
][
'
z_coords
'
])):
print
(
"
ERROR: Y and Z coordinate vectors have different lengths!
"
)
return
(
None
,
None
)
return
(
None
,
None
)
if
(
len
(
model
[
'
geometry_settings
'
][
'
y
_coords
'
])
!=
gconf
[
'
nsph
'
]
):
if
(
len
(
model
[
'
particle_settings
'
][
'
sph_types
'
])
==
0
and
len
(
model
[
'
geometry_settings
'
][
'
x
_coords
'
])
!=
0
):
print
(
"
ERROR:
Y coordinates do not match the number of spher
es!
"
)
print
(
"
ERROR:
random type assignment is not allowed with assigned coordinat
es!
"
)
return
(
None
,
None
)
return
(
None
,
None
)
if
(
len
(
model
[
'
geometry_settings
'
][
'
z_coords
'
])
!=
gconf
[
'
nsph
'
]):
# TODO: put here a test to allow for empty vectors in case of random generation
print
(
"
ERROR: Z coordinates do not match the number of spheres!
"
)
if
(
len
(
model
[
'
geometry_settings
'
][
'
x_coords
'
])
==
0
):
# Generate random cluster
print
(
"
DEBUG: would generate random cluster.
"
)
else
:
if
(
len
(
model
[
'
geometry_settings
'
][
'
x_coords
'
])
!=
gconf
[
'
nsph
'
]):
print
(
"
ERROR: coordinate vectors do not match the number of spheres!
"
)
return
(
None
,
None
)
return
(
None
,
None
)
for
si
in
range
(
gconf
[
'
nsph
'
]):
for
si
in
range
(
gconf
[
'
nsph
'
]):
gconf
[
'
vec_sph_x
'
][
si
]
=
float
(
model
[
'
geometry_settings
'
][
'
x_coords
'
][
si
])
gconf
[
'
vec_sph_x
'
][
si
]
=
float
(
model
[
'
geometry_settings
'
][
'
x_coords
'
][
si
])
...
...
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