Commit 35734a7b authored by eric pellegrini's avatar eric pellegrini
Browse files

Updated mvi test

parent b6892c0b
......@@ -48,9 +48,9 @@ from MDANSE.Externals.magnitude import magnitude
from MDANSE.Framework.Jobs.IJob import IJob
from MDANSE.MolecularDynamics.Trajectory import sorted_atoms
MCSTAS_UNITS_LUT = {'THz': magnitude.mg(1,"THz","meV_eq").toval(),
MCSTAS_UNITS_LUT = {'THz': magnitude.mg(1,"THz","meV(freq)").toval(),
'nm**2' : magnitude.mg(1,"nm2","b").toval(),
'inv_nm' : magnitude.mg(1,"inv_nm","inv_ang").toval()
'inv_nm' : magnitude.mg(1,"1/nm","1/ang").toval()
}
class McStasError(Error):
......@@ -79,11 +79,11 @@ class McStasVirtualInstrument(IJob):
settings['frames'] = ('frames', {"dependencies":{'trajectory':'trajectory'}})
settings['sample_coh'] = ('netcdf_input_file', {"widget":'input_file',
"label":'MDANSE Coherent Structure Factor',
"variables":['q','omega','s(q,f)_total'],
"variables":['q','frequency','s(q,f)_total'],
'default' : os.path.join('..','..','..','Data','NetCDF','dcsf_prot.nc')})
settings['sample_inc'] = ('netcdf_input_file', {"widget":'input_file',
"label":'MDANSE Incoherent Structure Factor',
"variables" :['q','omega','s(q,f)_total'],
"variables" :['q','frequency','s(q,f)_total'],
'default':os.path.join('..','..','..','Data','NetCDF','disf_prot.nc')})
settings['temperature'] = ('float', {"default":298.0})
settings['display'] = ('boolean', {'label':'trace the 3D view of the simulation'})
......@@ -170,13 +170,13 @@ class McStasVirtualInstrument(IJob):
cmdLine.append(sqwInput)
cmdLine.append(trace)
cmdLine.extend(parameters)
s = subprocess.Popen(" ".join(cmdLine), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
out,_ = s.communicate()
for line in out.splitlines():
if "ERROR" in line:
raise McStasError("An error occured during McStas run: %s" % line)
raise McStasError("An error occured during McStas run: %s" % out)
with open(os.path.join(self.configuration["options"]["mcstas_output_directory"],"mcstas_mdanse.mvi"),"w") as f:
f.write(out)
......
......@@ -11,9 +11,9 @@ class TestMVI(UnitTest):
parameters['display'] = False
parameters['frames'] = (0, 10, 1)
parameters['instrument'] = '../../../Data/McStas/Instruments/Simple_ToF_Flat_Sample.out'
parameters['options'] = {'ncount': 10000, 'dir': '/tmp/mcstas_output/06.10.2015-17:23:53'}
parameters['options'] = {'ncount': 10000, 'dir': '/tmp/mcstas_output/27.01.2016-14:49:51'}
parameters['output_files'] = ('/tmp/output', ['netcdf'])
parameters['parameters'] = {'beam_wavelength_Angs': 2.0, 'container_thickness_m': 5e-05, 'environment_radius_m': 0.025, 'sample_detector_distance_m': 4.0, 'container': '/users/pellegrini/workspace/MDANSE/Data/McStas/Samples/Al.laz', 'environment_thickness_m': 0.002, 'detector_height_m': 3.0, 'beam_resolution_meV': 0.1, 'sample_height_m': 0.05, 'sample_thickness_m': 0.001, 'environment': '/users/pellegrini/workspace/MDANSE/Data/McStas/Samples/Al.laz', 'sample_width_m': 0.02, 'sample_rotation_deg': 45.0}
parameters['parameters'] = {'beam_wavelength_Angs': 2.0, 'container_thickness_m': 5e-05, 'environment_radius_m': 0.025, 'sample_detector_distance_m': 4.0, 'container': '/home/pellegrini/git/mdanse/Data/McStas/Samples/Al.laz', 'environment_thickness_m': 0.002, 'detector_height_m': 3.0, 'beam_resolution_meV': 0.1, 'sample_height_m': 0.05, 'sample_thickness_m': 0.001, 'environment': '/home/pellegrini/git/mdanse/Data/McStas/Samples/Al.laz', 'sample_width_m': 0.02, 'sample_rotation_deg': 45.0}
parameters['sample_coh'] = '../../../Data/NetCDF/dcsf_prot.nc'
parameters['sample_inc'] = '../../../Data/NetCDF/disf_prot.nc'
parameters['temperature'] = 298.0
......
#!/usr/bin/python
import unittest
from Tests.UnitTests.UnitTest import UnitTest
from MDANSE import REGISTRY
class TestTEST(UnitTest):
def test(self):
parameters = {}
parameters['frames'] = (0, 10, 1)
parameters['output_files'] = ('/tmp/output', ['netcdf'])
parameters['trajectory'] = '../../../Data/Trajectories/MMTK/waterbox_in_periodic_universe.nc'
job = REGISTRY['job']['test']()
self.assertNotRaises(job.run, parameters, status=False)
def suite():
loader = unittest.TestLoader()
s = unittest.TestSuite()
s.addTest(loader.loadTestsFromTestCase(TestTEST))
return s
if __name__ == '__main__':
unittest.main(verbosity=2)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment