def parameters(self, val): """ Set (and check) the parameters. """ if val is None: self.__parameters = PhotonMatterInteractorParameters() if isinstance(val, dict): self.__parameters = PhotonMatterInteractorParameters(parameters_dictionary=val) if isinstance(val, PhotonMatterInteractorParameters): self.__parameters = val
def testBackengineMultipleProp(self): """ Check that the backengine method works correctly. """ # Prepare input. shutil.copytree(TestUtilities.generateTestFilePath('prop_out'), os.path.abspath('prop')) self.__dirs_to_remove.append('prop') self.__dirs_to_remove.append('pmi') parameters = PhotonMatterInteractorParameters(number_of_trajectories=1) test_interactor = XMDYNPhotonMatterInteractor( parameters=parameters, input_path='prop', output_path='pmi', sample_path=TestUtilities.generateTestFilePath('sample.h5')) # Call backengine status = test_interactor.backengine() # Check that the backengine returned zero. self.assertEqual(status, 0) # Check we have generated the expected output. self.assertIn('pmi_out_0000001.h5', os.listdir(test_interactor.output_path))
def testConstructionWithParameters(self): """ Testing the construction of the class with a parameter object. """ # Setup pmi parameters. pmi_parameters = PhotonMatterInteractorParameters( number_of_trajectories=1, ) interactor = XMDYNPhotonMatterInteractor(parameters=pmi_parameters, output_path='pmi_out', input_path=TestUtilities.generateTestFilePath('prop_out_0000001.h5'), sample_path=TestUtilities.generateTestFilePath('sample.h5'), ) self.assertIsInstance(interactor, XMDYNPhotonMatterInteractor)
def testConstructionWithParametersNoProp(self): """ Testing the construction of the class with a parameter dictionary without propagation input. """ beam = PhotonBeamParameters( photon_energy = 8.6e3*Units.electronvolt, pulse_energy=1.5e-3*Units.joule, photon_energy_relative_bandwidth=1e-4, divergence=1.0e-3*Units.radian, beam_diameter_fwhm=5.0e-3*Units.meter, ) # Setup pmi parameters. pmi_parameters = PhotonMatterInteractorParameters( number_of_trajectories=1, beam_parameters=beam, ) interactor = XMDYNPhotonMatterInteractor( parameters=pmi_parameters, output_path='pmi_out', sample_path=TestUtilities.generateTestFilePath('sample.h5'), ) self.assertIsInstance(interactor, XMDYNPhotonMatterInteractor)