Commit d2966b74 authored by Islam, Fahima's avatar Islam, Fahima
Browse files

Upload New File

parent 503b4e58
Loading
Loading
Loading
Loading
+58 −0
Original line number Diff line number Diff line
from mcvine import run_script
import numpy as np
import base.sampleassembly_program as sampleProg
from base.scatterer_xml import grid_sq_kernel
from base.geometry_program import sample_cylinder
from base.xyz_file import generate_xyz_file_H

def run_nomad_cylinder(beam_path, sample_path, cylinder_height, cylinder_radius, sq_path, q_range_start,
                       q_range_end, sampleName, simdir, MS= False, max_scatterering=1,
                       max_interactM_scattering=1,
                       min_neutron_probability=0.03, number_of_neutrons= 1E8,
                       number_of_nodes=10,
                       SE=False, SE_type='cryostat'):
    """
        Run the NOMAD simulation for a cylindrical sample.

        Parameters:
        beam_path (str): Path to the beam file.
        sample_path (str): name of the path where the sample assembly will be created.
        cylinder_height (float): Height of the cylindrical sample.
        cylinder_radius (float): Radius of the cylindrical sample.
        sq_path (str): Path to the S(Q) file.
        q_range_start (float): Starting value of the Q range.
        q_range_end (float): Ending value of the Q range.
        sampleName (str): Name of the sample.
        simdir (str): Directory where the simulation results will be saved.
        max_scatterering (int): Maximum number of scattering loops among scatterers.
        max_interactM_scattering (int): Maximum number of scattering loops for interactM path.
        min_neutron_probability (float): Minimum neutron probability.
        number_of_neutrons (float): Number of neutrons to simulate.
        number_of_nodes (int): Number of nodes to use for the simulation
        SE (bool): Flag to indicate if SE (Sample Environment) is used. Default is False.
        SE_type (str): Type of Sample Environment. Default is 'cryostat'.
        """
    geometry_file_name = f'{sampleName}-geo'
    sample_cylinder(cylinder_radius, cylinder_height, sample_path, geometry_file_name)
    grid_sq_kernel(sq_path, q_range_start, q_range_end, sample_path, sampleName)
    generate_xyz_file_H(sample_path)
    if SE == False:
        scatterers = {
        (f'{sampleName}', f'{sampleName}shape', geometry_file_name, 'H', 'H.xyz', 'xyz'),
        # (name, shape_name, geometry file name, formula, structure file, structurefile type)

    }
    else:
        scatterers = []
        for sampleName in sample_names:
            geometry_file_name = f'{sampleName}-geo'
            scatterers.append((f'{sampleName}', f'{sampleName}shape', geometry_file_name, 'H', 'H.xyz', 'xyz'))


    sampleProg.makeSAXML(sampleName, sample_path, max_scatterering=max_scatterering,
                         max_interactM_scattering=max_interactM_scattering,
                         min_neutron_probability=min_neutron_probability, scatterers=scatterers)
    run_script.run1_mpi(base/Nomad.py, simdir, beam = beam_path, sample_path= sample_path,mutiple_scattering=MS,
                        ncouts =number_of_neutrons, overwrite_datafiles = True, nodes= number_of_nodes)