PaNOSC-ViNYL / SimEx

Start-to-end photon experiment simulation platform
https://simex.readthedocs.io/
GNU General Public License v3.0
26 stars 25 forks source link

Gaussian source #180

Open CFGrote opened 4 years ago

CFGrote commented 4 years ago

Make a Calculator that generates a wavefront with Gaussian amplitude distribution in time and space.

CFGrote commented 4 years ago

Pushed to 6a65415 on gauss_source.

JunCEEE commented 4 years ago

When I try to run gaussianSource = GaussianPhotonSource(), I got this error:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-4-b3a32f0e7291> in <module>
----> 1 gaussianSource = GaussianPhotonSource()

/gpfs/exfel/data/user/juncheng/panoscProject/src/simex_platform/Sources/python/SimEx/Calculators/GaussianPhotonSource.py in __init__(self, parameters, input_path, output_path)
     50 
     51         # Initialize base class.
---> 52         super(GaussianPhotonSource, self).__init__(parameters, input_path, output_path)
     53 
     54         self.parameters = parameters

/gpfs/exfel/data/user/juncheng/panoscProject/src/simex_platform/Sources/python/SimEx/Calculators/AbstractPhotonSource.py in __init__(self, parameters, input_path, output_path)
     54 
     55         # Init base class.
---> 56         super(AbstractPhotonSource, self).__init__(parameters, input_path, output_path)
     57 
     58         # Setup provided data groups and sets.

/gpfs/exfel/data/user/juncheng/panoscProject/src/simex_platform/Sources/python/SimEx/Calculators/AbstractBaseCalculator.py in __init__(self, parameters, input_path, output_path)
     52         self.__parameters = checkAndSetParameters(parameters)
     53 
---> 54         self.__input_path, self.__output_path = checkAndSetIO((input_path, output_path))
     55 
     56 

/gpfs/exfel/data/user/juncheng/panoscProject/src/simex_platform/Sources/python/SimEx/Calculators/AbstractBaseCalculator.py in checkAndSetIO(io)
    214     i = checkAndSetInstance(str, io[0])
    215     if i is None:
--> 216         raise IOError("The parameter 'input_path' must be a valid filename.")
    217     i = os.path.abspath(i)
    218 #

OSError: The parameter 'input_path' must be a valid filename.
CFGrote commented 4 years ago

@ejcjason , is the above still an open issue? look at the tests for GaussianSource to see how it is supposed to work.

JunCEEE commented 4 years ago

develop branch Tested, still found several problems.

Cannot be imported by from SimEx import *

Got error NameError: name 'GaussWavefrontParameters' is not defined and NameError: name 'GaussWavefrontParameters' is not defined.

Possible solution: init.py might need to be modified.

unnecessay input_path requirement of GaussianPhotonSource

A dummy input_path has to be placed for GaussianPhotonSource, which should not be needed.

No attribute 'divergence' found while running backengine

When running gaussianSource.backengine(), got AttributeError: 'GaussWavefrontParameters' object has no attribute 'divergence'

My test script

import SimEx
from SimEx import *

gaussianParam = GaussWavefrontParameters(
    photon_energy = 4972.0 * electronvolt,  # photon energy in eV
    beam_diameter_fwhm=1.3e-7 * meter,      # focus diameter in m
    pulse_energy=0.45e-3 * joule,           # pulse energy in J
    photon_energy_relative_bandwidth=0.003, # relative bandwidth dE/E
    divergence=0.0*radian,                         # Beam divergence in rad
    number_of_transverse_grid_points = 100,
    number_of_time_slices = 30,
    )
gaussianSource = GaussianPhotonSource(
    parameters= gaussianParam,
    input_path='fd',
    output_path = 'FELsource_out.h5')

#import pdb; pdb.set_trace()
gaussianSource.backengine()
gaussianSource.saveH5()