def test(self): "wrap IQE_monitor" from mcstas2 import componentfactory category = 'monitors' componentname = 'IQE_monitor' factory = componentfactory(category, componentname) Qmin = 0 Qmax = 13. nQ = 130 Emin = -50 Emax = 50. nE = 100 component = factory( 'component', Ei=Ei, Qmin=Qmin, Qmax=Qmax, nQ=nQ, Emin=Emin, Emax=Emax, nE=nE, max_angle_out_of_plane=30, min_angle_out_of_plane=-30, max_angle_in_plane=120, min_angle_in_plane=-30, ) scatterer = makeScatterer() import mcni N = 10000 neutrons = mcni.neutron_buffer(N) for i in range(N): neutron = mcni.neutron(r=(0, 0, 0), v=(0, 0, vi), time=0, prob=1) scatterer.scatter(neutron) neutrons[i] = neutron #print neutrons[i] continue component.process(neutrons) hist = get_histogram(component) import os f = os.path.basename(__file__) filename = 'IQE-%s.h5' % f if os.path.exists(filename): os.remove(filename) import histogram.hdf as hh hh.dump(hist, filename, '/', 'c') if self.interactive: from histogram.plotter import defaultPlotter defaultPlotter.plot(hist) return
def test(self): "wrap IQE_monitor" from mcstas2 import componentfactory factory = componentfactory(category, componentname) Qmin = 0 Qmax = 13. nQ = 130 Emin = -50 Emax = 50. nE = 100 component = factory( 'component', Ei=Ei, Qmin=Qmin, Qmax=Qmax, nQ=nQ, Emin=Emin, Emax=Emax, nE=nE, max_angle_out_of_plane=30, min_angle_out_of_plane=-30, max_angle_in_plane=120, min_angle_in_plane=-30, ) kernel = makeKernel() import mcni N = 10000 neutrons = mcni.neutron_buffer(N) for i in range(N): neutron = mcni.neutron(r=(0, 0, 0), v=(0, 0, vi), time=0, prob=1) kernel.scatter(neutron) neutrons[i] = neutron #print neutrons[i] continue component.process(neutrons) from mcstas2.pyre_support._component_interfaces.monitors.IQE_monitor import get_histogram hist = get_histogram(component) if interactive: from histogram.plotter import defaultPlotter defaultPlotter.plot(hist) return
def test(self): "wrap IQE_monitor" from mcstas2 import componentfactory category = 'monitors' componentname = 'IQE_monitor' factory = componentfactory( category, componentname ) Qmin=0; Qmax=13.; nQ=130 Emin=-50; Emax=50.; nE=100 component = factory( 'component', Ei=Ei, Qmin=Qmin, Qmax=Qmax, nQ=nQ, Emin=Emin, Emax=Emax, nE=nE, max_angle_out_of_plane=30, min_angle_out_of_plane=-30, max_angle_in_plane=120, min_angle_in_plane=-30, ) scatterer = makeScatterer() import mcni N = 10000 neutrons = mcni.neutron_buffer( N ) for i in range(N): neutron = mcni.neutron(r=(0,0,0), v=(0,0,vi), time=0, prob=1) scatterer.scatter(neutron) neutrons[i] = neutron #print neutrons[i] continue component.process( neutrons ) hist = get_histogram(component) import os f = os.path.basename(__file__) filename = 'IQE-%s.h5' % f if os.path.exists(filename): os.remove(filename) import histogram.hdf as hh hh.dump(hist, filename, '/', 'c') if self.interactive: from histogram.plotter import defaultPlotter defaultPlotter.plot(hist) return
def test(self): "wrap IQE_monitor" from mcstas2 import componentfactory factory = componentfactory( category, componentname ) Ei = 70 Qmin=0; Qmax=13.; nQ=130 Emin=-50; Emax=50.; nE=100 component = factory( 'component', Ei=Ei, Qmin=Qmin, Qmax=Qmax, nQ=nQ, Emin=Emin, Emax=Emax, nE=nE, max_angle_out_of_plane=30, min_angle_out_of_plane=-30, max_angle_in_plane=120, min_angle_in_plane=-30, ) import mcni from mcni.utils import conversion as C neutrons = mcni.neutron_buffer( nQ*nE ) import numpy as N count = 0 for Q in N.arange(Qmin, Qmax, (Qmax-Qmin)/nQ): for E in N.arange(Emin,Emax,(Emax-Emin)/nE): Ef = Ei-E cosphi = (Ei+Ef-C.k2e(Q))/(2*N.sqrt(Ei)*N.sqrt(Ef)) vf = C.e2v(Ef) vfz = vf*cosphi sinphi = N.sqrt(1-cosphi*cosphi) vfx = vf*sinphi neutrons[count] = mcni.neutron(r=(0,0,0), v=(vfx,0,vfz), time = 0, prob = 1) count += 1 continue component.process( neutrons ) from mcstas2.pyre_support._component_interfaces.monitors.IQE_monitor import get_histogram hist = get_histogram(component) if interactive: from histogram.plotter import defaultPlotter defaultPlotter.plot(hist) return
def test(self): "fccNi kernel constructed by hand" from mcstas2 import componentfactory category = 'monitors' componentname = 'IQE_monitor' factory = componentfactory( category, componentname ) Qmin=0; Qmax=13.; nQ=130 Emin=-50; Emax=50.; nE=100 component = factory( 'component', Ei=Ei, Qmin=Qmin, Qmax=Qmax, nQ=nQ, Emin=Emin, Emax=Emax, nE=nE, max_angle_out_of_plane=30, min_angle_out_of_plane=-30, max_angle_in_plane=120, min_angle_in_plane=-30, ) kernel = makeKernel() import mcni # N = 500000 # needs about 20 minutes on a Intel Core2 Duo 2.53GHz virtual machine, ubuntu 10.04LTS on a 2.53GHz Intel Core 2 Duo Macbook N = 10000 neutrons = mcni.neutron_buffer( N ) for i in range(N): neutron = mcni.neutron(r=(0,0,0), v=(0,0,vi), time=0, prob=1) kernel.scatter(neutron) neutrons[i] = neutron #print neutrons[i] continue component.process( neutrons ) hist = get_histogram(component) if self.interactive: from histogram.plotter import defaultPlotter defaultPlotter.plot(hist) return
def test(self): "wrap IQE_monitor" from mcstas2 import componentfactory factory = componentfactory( category, componentname ) Qmin=0; Qmax=13.; nQ=130 Emin=-50; Emax=50.; nE=100 component = factory( 'component', Ei=Ei, Qmin=Qmin, Qmax=Qmax, nQ=nQ, Emin=Emin, Emax=Emax, nE=nE, max_angle_out_of_plane=30, min_angle_out_of_plane=-30, max_angle_in_plane=120, min_angle_in_plane=-30, ) kernel = makeKernel() import mcni N = 10000 neutrons = mcni.neutron_buffer( N ) for i in range(N): neutron = mcni.neutron(r=(0,0,0), v=(0,0,vi), time=0, prob=1) kernel.scatter(neutron) neutrons[i] = neutron #print neutrons[i] continue component.process( neutrons ) from mcstas2.pyre_support._component_interfaces.monitors.IQE_monitor import get_histogram hist = get_histogram(component) if interactive: from histogram.plotter import defaultPlotter defaultPlotter.plot(hist) return