def samplecomponent( name, sampleassembly_xml ): '''samplecomponent( name, xml ) --> sample simulation component name: name of the sample xml: xml file describing the sample assembly ''' import mccomposite.extensions.HollowCylinder import os filename = os.path.realpath( sampleassembly_xml ) dir, filename = os.path.split( os.path.abspath( filename ) ) save = os.path.abspath( os.curdir ) os.chdir( dir ) from sampleassembly.saxml import parse_file sa = parse_file( filename ) from sampleassembly_support import sampleassembly2compositescatterer, \ findkernelsfromxmls scatterercomposite = findkernelsfromxmls( sampleassembly2compositescatterer( sa ) ) os.chdir(save) import mccomponents.homogeneous_scatterer as hs engine = hs.scattererEngine( scatterercomposite ) engine.name = name return engine
def test3(self): """ parse weaved xml """ from sampleassembly.saxml import parse_file sampleassembly = parse_file('Ni.xml.weaved') return
def test3(self): """ parse weaved xml """ from sampleassembly.saxml import parse_file sampleassembly = parse_file( 'Ni.xml.weaved') return
def samplecomponent(name, sampleassembly_xml): '''samplecomponent( name, xml ) --> sample simulation component name: name of the sample xml: xml file describing the sample assembly ''' import mccomposite.extensions.HollowCylinder import os filename = os.path.realpath(sampleassembly_xml) dir, filename = os.path.split(os.path.abspath(filename)) save = os.path.abspath(os.curdir) os.chdir(dir) from sampleassembly.saxml import parse_file sa = parse_file(filename) from sampleassembly_support import sampleassembly2compositescatterer, \ findkernelsfromxmls scatterercomposite = findkernelsfromxmls( sampleassembly2compositescatterer(sa)) os.chdir(save) import mccomponents.homogeneous_scatterer as hs engine = hs.scattererEngine(scatterercomposite) engine.name = name return engine
def test2(self): """ sampleassembly.saxml.weave """ from sampleassembly.saxml import weave, parse_file sampleassembly = parse_file('Ni.xml') weave(sampleassembly, open('Ni.xml.weaved', 'w')) return
def test2(self): """ sampleassembly.saxml.weave """ from sampleassembly.saxml import weave, parse_file sampleassembly = parse_file( 'Ni.xml' ) weave(sampleassembly, open('Ni.xml.weaved', 'w') ) return
def test(self): """ sampleassembly.saxml.render """ from sampleassembly.saxml import render, parse_file sampleassembly = parse_file('Ni.xml') text = render(sampleassembly) print('\n'.join(text), file=open('Ni.xml.rendered', 'w')) return
def test(self): """ sampleassembly.saxml.render """ from sampleassembly.saxml import render, parse_file sampleassembly = parse_file( 'Ni.xml' ) text = render( sampleassembly ) print >> open('Ni.xml.rendered','w'), '\n'.join(text) return
def test1(self): """ sampleassembly.saxml.parser: with sample environment """ from sampleassembly.saxml import parse_file sampleassembly = parse_file( 'Ni-withenviron.xml' ) env = sampleassembly.getEnvironment() print env print env.attributes.temperature # print type(env.attributes.temperature) from pyre.units import temperature as T print env.attributes.temperature/T.K print env.temperature() return
def test0(self): """ sampleassembly.saxml.parser """ from sampleassembly.saxml import parse_file sampleassembly = parse_file( 'Ni.xml' ) geometer = sampleassembly.local_geometer Ni_powder = sampleassembly.elements()[0] shape = Ni_powder.shape() assert shape.__class__.__name__ == 'Union', len(shape.shapes)==3 phase = Ni_powder.phase self.assertEqual( phase.__class__.__name__, 'Crystal' ) self.assertEqual( phase.chemical_formula, 'Ni' ) crystal = phase unitcell = crystal.unitcell print unitcell return
def test0(self): from sampleassembly.saxml import parse_file sa = parse_file( sampleassembly_xml ) from mccomponents.sample.sampleassembly_support \ import sampleassembly2compositescatterer, \ findkernelsfromxmls scatterercomposite = findkernelsfromxmls( sampleassembly2compositescatterer( sa ) ) import mccomponents.homogeneous_scatterer as hs engine = hs.scattererEngine( scatterercomposite ) for i in range(10): ev = mcni.neutron( r = (0,0,-5), v = (0,0,3000) ) engine.scatter( ev ) print ev continue return