Commit 166a1a02 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Print a model summary after execution of model_maker

parent f9c263cd
Loading
Loading
Loading
Loading
+54 −1
Original line number Original line Diff line number Diff line
@@ -57,7 +57,10 @@ def main():
        sconf, gconf = load_model(config['yml_file_name'])
        sconf, gconf = load_model(config['yml_file_name'])
        if (sconf is not None) and (gconf is not None):
        if (sconf is not None) and (gconf is not None):
            result = write_legacy_sconf(sconf)
            result = write_legacy_sconf(sconf)
            if (result == 0): result += write_legacy_gconf(gconf)
            if (result == 0):
                result += write_legacy_gconf(gconf)
            if (result == 0):
                print_model_summary(sconf, gconf)
        else:
        else:
            print("ERROR: could not create configuration.")
            print("ERROR: could not create configuration.")
            result = 1
            result = 1
@@ -604,6 +607,56 @@ def print_help():
    print("--help                Print this help and exit.")
    print("--help                Print this help and exit.")
    print("                                               ")
    print("                                               ")


## \brief Print a summary of model properties.
#
#  This function provides a summary of useful information concerning the
#  radii of the particle monomers and of the equivalent mass sphere, to
#  assist in the selection of the proper starting orders.
#
#  \parameter scatterer: `dict` A dictionary for the scatterer configuration.
#  \parameter geometry: `dict` A dictionary for the geometry configuration.
def print_model_summary(scatterer, geometry):
    avgX = 0.0
    avgY = 0.0
    avgZ = 0.0
    Rmin = 0.0
    Rmax = 0.0
    Reqm = 0.0
    R3tot = 0.0
    Rcirc = 0.0
    square_farthest = 0.0
    for i in range(scatterer['nsph']):
        avgX += geometry['vec_sph_x'][i]
        avgY += geometry['vec_sph_y'][i]
        avgZ += geometry['vec_sph_z'][i]
        sph_type_index = scatterer['vec_types'][i] - 1
        ros = scatterer['ros'][sph_type_index]
        R3tot += math.pow(ros, 3.0)
        if (ros > Rmax):
            Rmax = ros
        if (Rmin == 0.0 or ros < Rmin):
            Rmin = ros
    Reqm = math.pow(R3tot, 1.0 / 3.0)
    avgX /= scatterer['nsph']
    avgY /= scatterer['nsph']
    avgZ /= scatterer['nsph']
    for i in range(scatterer['nsph']):
        sph_type_index = scatterer['vec_types'][i] - 1
        ros = scatterer['ros'][sph_type_index]
        dX = geometry['vec_sph_x'][i] - avgX
        dY = geometry['vec_sph_y'][i] - avgY
        dZ = geometry['vec_sph_z'][i] - avgZ
        square_range = dX * dX + dY * dY + dZ * dZ + ros * ros
        if (square_range > square_farthest):
            square_farthest = square_range
    Rcirc = math.sqrt(square_farthest)
    if (Rmax == Rmin):
        print("INFO: monomer radius is Rsph = %.5em"%Rmin)
    else:
        print("INFO: smallest monomer radius is Rmin = %.5em"%Rmin)
        print("INFO: largest monomer radius is Rmax = %.5em"%Rmax)
    print("INFO: equivalent mass radius is Reqm = %.5em"%Reqm)
    print("INFO: minimum encircling radius is Rcirc = %.5em"%Rcirc)


## \brief Generate a random cluster aggregate from YAML configuration options.
## \brief Generate a random cluster aggregate from YAML configuration options.
#
#