diff --git a/src/scripts/model_maker.py b/src/scripts/model_maker.py index 10b10d0fbd4c78c0fdb4c81f298b09e2dab7f2ca..cfb0e28e6ae3258d6e90324a06311bb8154c31f9 100755 --- a/src/scripts/model_maker.py +++ b/src/scripts/model_maker.py @@ -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,20 +313,30 @@ 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']) != gconf['nsph']): - print("ERROR: Y coordinates do not match the number of spheres!") + 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']['z_coords']) != gconf['nsph']): - print("ERROR: Z 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) - for si in range(gconf['nsph']): - gconf['vec_sph_x'][si] = float(model['geometry_settings']['x_coords'][si]) - gconf['vec_sph_y'][si] = float(model['geometry_settings']['y_coords'][si]) - gconf['vec_sph_z'][si] = float(model['geometry_settings']['z_coords'][si]) + # 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]) + gconf['vec_sph_y'][si] = float(model['geometry_settings']['y_coords'][si]) + gconf['vec_sph_z'][si] = float(model['geometry_settings']['z_coords'][si]) else: # model is None print("ERROR: could not parse " + model_file + "!") return (sconf, gconf)