Skip to content
Snippets Groups Projects
Commit 923255b1 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Prepare model_maker to accept random generators

parent 27676c69
No related branches found
No related tags found
No related merge requests found
......@@ -247,7 +247,7 @@ def load_model(model_file):
print("ERROR: %s is not a supported scaling mode!"%(model['radiation_settings']['scale_name']))
return (None, None)
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!")
return (None, None)
else:
......@@ -313,15 +313,25 @@ def load_model(model_file):
gconf['vec_sph_y'] = [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):
# TODO: put here a test to allow for empty vectors in case of random generation
if (len(model['geometry_settings']['x_coords']) != gconf['nsph']):
print("ERROR: X coordinates do not match the number of spheres!")
if (len(model['geometry_settings']['x_coords']) != len(model['geometry_settings']['y_coords'])):
print("ERROR: X and Y coordinate vectors have different lengths!")
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)
if (len(model['geometry_settings']['y_coords']) != gconf['nsph']):
print("ERROR: Y coordinates do not match the number of spheres!")
if (len(model['particle_settings']['sph_types']) == 0 and len(model['geometry_settings']['x_coords']) != 0):
print("ERROR: random type assignment is not allowed with assigned coordinates!")
return (None, None)
if (len(model['geometry_settings']['z_coords']) != gconf['nsph']):
print("ERROR: Z coordinates do not match the number of spheres!")
# TODO: put here a test to allow for empty vectors in case of random generation
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)
for si in range(gconf['nsph']):
gconf['vec_sph_x'][si] = float(model['geometry_settings']['x_coords'][si])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment