Esempio n. 1
0
def computeFlux(m2sout):
    f = os.path.join(m2sout, 'neutrons')
    from mcni.neutron_storage.idf_usenumpy import totalintensity, count
    I = totalintensity(f)
    if I == 0:
        raise RuntimeError("There is no neutrons at sample position. Please increase ncount")
    # one MC run corresponds to 34kJ/pulse
    # this is the flux if the power is at 34kJ/pulse
    # unit: 1/34kJ pulse
    # every neutron in the storage represents one 34kJ pulse. so 
    # we need to normalize by number of events in the storage
    nevts = count(f)
    flux = I/nevts
    return flux
def computeFlux(m2sout):
    f = os.path.join(m2sout, 'neutrons')
    from mcni.neutron_storage.idf_usenumpy import totalintensity, count
    I = totalintensity(f)
    if I == 0:
        raise RuntimeError, "There is no neutrons at sample position. Please increase ncount"
    # one MC run corresponds to 34kJ/pulse
    # this is the flux if the power is at 34kJ/pulse
    # unit: 1/34kJ pulse
    # every neutron in the storage represents one 34kJ pulse. so 
    # we need to normalize by number of events in the storage
    nevts = count(f)
    flux = I/nevts
    return flux
Esempio n. 3
0
    def collimator_inefficiency(self, params):

        dcs, I_d, error = self.diffraction_pattern_calculation(params)

        scattered = os.path.join(beam_path, 'clampcellSi_neutron')

        ncount = 1e9

        sample_peaks = self.peaks['sample']

        cell_peaks = self.peaks['cell']

        scattered_beam_intensity = totalintensity(scattered) * ncount / count(
            scattered)

        sample_peak_int = 0.0
        cell_peak_int = 0.0

        for sample_peak in sample_peaks:
            sample_peak_int += I_d[(dcs < sample_peak.dmax)
                                   & (dcs > sample_peak.dmin)].sum(
                                   )  #I_d[ (dcs<3.5) & (dcs>3)].sum()

        for cell_peak in cell_peaks:
            cell_peak_int += I_d[(dcs < cell_peak.dmax)
                                 & (dcs > cell_peak.dmin)].sum(
                                 )  #I_d[np.logical_and(dcs<2.2, dcs>2)].sum()

        # collimator_ineff=(cell_peak_int/sample_peak_int)+(1-sample_peak_int/scattered_beam_intensity)

        collimator_ineff = (cell_peak_int / sample_peak_int
                            )  # new objective function suggested by Garrett

        print('coll_len,:', params[0], 'focal_distance,:', params[1],
              'collimator_performance: ', (sample_peak_int / cell_peak_int))

        return (collimator_ineff)
Esempio n. 4
0
from collimator_geometry import create as create_collimator_geometry, Parameter_error
import reduction, conf

scattered = os.path.join(
    beam_path, 'clampcellSi_neutron'
)  # path to scattered neutrons from clamp cell and sample
sample = 'collimator'
ncount = 1e5
nodes = 20
sourceTosample = 0
detector_size = 0.5

instr = os.path.join(libpath, 'myinstrument.py')

scattered_beam_intensity = totalintensity(scattered) * ncount / count(
    scattered)

samplepath = os.path.join(thisdir, '../sample')
filename = 'coll_geometry.xml'
outputfile = os.path.join(samplepath, filename)


def objective_func(params):
    try:
        diffraction_pattern = diffraction_pattern_calculation(params)

        return (collimator_inefficiency(diffraction_pattern))

    except Parameter_error as e:
        return (1e10)