Warwick-Plasma / epoch

Particle-in-cell code for plasma physics simulations
https://epochpic.github.io
GNU General Public License v3.0
184 stars 58 forks source link

skew temporal profile #695

Closed koesterf closed 2 months ago

koesterf commented 3 months ago

Dear Epoch developers,

Is there any utility with which a skew temporal profile of a laser pulse can be directly implemented in the code ?

Thanks. Frank

Status-Mirror commented 3 months ago

Hi Frank,

By skew, do you mean having a laser wavelength which changes with time? EPOCH should be able to support this. Check out our laser pulse demo for an example deck with a laser.

If you wanted the laser wavelength to linearly vary from 1 micron to 2 microns over the simulation run-time, you could modify the wavelength key to read:

lambda = 1.0e-6 * (1 + time / t_end)

where we have used the maths parser variables time and t_end. As the code is run, time will be replaced by the current simulation time for each time-step.

Hope this helps, Stuart

koesterf commented 3 months ago

Hi @Status-Mirror, thanks for replying.

Sorry for the misunderstanding. By Skew I mean a non-symmetrical longitudinal or temporal profile. Ideally, the temporal profile is Gaussian (or normal ) symmetric, but I would like to have non-symmetric normal distribution, i.e., fast rising and slow decaying pulses. like here : either 𝛼=4 or 𝛼=-4

Status-Mirror commented 2 months ago

Hey @koesterf,

My apologies, I think I confused "skew" with "chirp". A Gaussian skew like the one you describe requires evaluation of the error function, $\text{erf}(x)$, which can't be evaluated by the standard EPOCH maths parser.

The easiest solution would be to write some code which gives you a set of $[t, f(t)]$ pairs, giving you the temporal envelope $f$ at various times $t$. You can then feed this distribution into EPOCH using the interpolate function of the maths parser.

For example, I could approximate the function sin(t) using:

interpolate(time, 0, 0, pi/6, 0.5, 2*pi/6, 0.5*sqrt(3), pi/2, 1, 4)

where I have fed 4 evaluation points:

time    f(t)
0       0
pi/6    0.5
2*pi/6  0.5*sqrt(3)
pi/2    1

Hope this helps, Stuart

koesterf commented 2 months ago

Hi @Status-Mirror, thanks for replying. I appreciate your help. I have generated data of about 1000 points as ( t, f(t) ). I assume it as longitudinal or temporal profile of the laser pulse.

Now, the questions are:

(1) first, I have to read this file ( t, f(t) ) in the input script, (2) second, interpolate it and then pass the interpolated values to the code.

Please, could you give me some suggestion what steps I should follow to do this.

Thank you, Frank

koesterf commented 2 months ago

Hi @Status-Mirror,

any possibility to include the temporal profile using a [ t, f(t) ] 1-D data file ?

Status-Mirror commented 2 months ago

Sorry for the delay @koesterf. EPOCH isn't set up to read in data-files like that. The easiest way to achieve this is to reformat your data into an interpolate function. If you have two columns of t, f(t) values, the conversion won't be too difficult. You could write:

t_profile = interpolate(time, \ 
          0,   0, \
    1.0e-15,   0.1, \
    2.0e-15,   0.2, \
    3.0e-15,   0.3, \
    4.0e-15,   0.4, \
    5.0e-15,   0.5, \
    6.0e-15,   0.6, \
    7.0e-15,   0.7, \
    8) 

Where I have taken a two-column data-set, applied linebreaks \ to each line, and added the number of datapoints as the final argument. Are you able to implement this?

Cheers, Stuart

koesterf commented 2 months ago

Hi @Status-Mirror, thanks for replying and sorry for my late response. I will check this way and will let you know if I run under any issue.

Thanks a lot.

Best, Frank