Hi-PACE / hipace

Highly efficient Plasma Accelerator Emulation, quasistatic particle-in-cell code
https://hipace.readthedocs.io
Other
51 stars 14 forks source link

Read laser profile from parser #1122

Closed huixingjian closed 2 months ago

huixingjian commented 3 months ago

With this PR, the laser profile can be initialised through parser, with lasers.laser_real(x,y,z)=" "for real part and lasers.laser_imag(x,y,z)=" "for imaginary part separately.

huixingjian commented 3 months ago

use

lasers.laser_real(x,y,z)="2*exp(-(x^2+y^2)/W0^2-z^2/(2*clight^2*tau^2))*cos(-(6.28*z/800e-9))*
                          if(abs(z)<5e-7 and y >0,
                               if(y<(2.25*sqrt(abs(-(abs(z*1e6)-0.5)*(abs(z*1e6)+0.5))/(-(abs(z*1e6)-0.5)*(abs(z*1e6)+0.5))))/1e6,0,1),1)*
                          if(abs(z)>5e-7 and abs(z)<7.5e-7 and y >0,
                               if(y<(3*abs(z*1e6)+0.75*sqrt(abs(-(abs(z*1e6)-0.5)*(abs(z*1e6)-0.75))/(-(abs(1e6*z)-0.5)*(abs(z*1e6)-0.75))))/1e6,0,1),1)*
                          if(abs(z)>7.5e-7 and abs(z)< 1e-6 and y >0,
                               if(y<(9*sqrt(abs(-(abs(z*1e6)-1)*(abs(z*1e6)-0.75))/(-(abs(1e6*z)-1)*(abs(z*1e6)-0.75)))-8*abs(z*1e6))/1e6,0,1),1)*
                          if(abs(z)>1e-6 and abs(z)< 3e-6 and y >0,
                               if(y<(6*sqrt(10)/7+(1.5-0.5*abs(z*1e6))*sqrt(abs(abs(z*1e6)-1)/(abs(z*1e6)-1))-6*sqrt(10)*sqrt(4-(abs(1e6*z)-1)**2)/14)/1e6,0,1),1)*
                          if(abs(z)>3e-6 and abs(z) < 7e-6 and y>0,
                               if(y <(3*sqrt(1-(z*1e6/7)**2)*sqrt(abs(abs(z*1e6)-3)/(abs(z*1e6)-3)))/1e6,0,1),1)*
                          if(abs(z)>4e-6 and abs(z)<7e-6 and y<0,
                               if(y >(-3*sqrt(1-(z*1e6/7)**2)*sqrt(abs(abs(z*1e6)-4)/(abs(z*1e6)-4)))/1e6,0,1),1)*
                          if(abs(z)< 4e-6 and y <0,
                                if(y > (abs(z*1e6/2)-(3*sqrt(33)-7)*(z*1e6)**2/122-3.1+sqrt(1-(abs(abs(z*1e6)-2)-1)**2))/1e6,0,1),1)"
lasers.laser_imag(x,y,z)="2*exp(-(x^2+y^2)/W0^2-z^2/(2*clight^2*tau^2))*sin(-(6.28*z/800e-9))*
                          if(abs(z)<5e-7 and y >0,
                               if(y<(2.25*sqrt(abs(-(abs(z*1e6)-0.5)*(abs(z*1e6)+0.5))/(-(abs(z*1e6)-0.5)*(abs(z*1e6)+0.5))))/1e6,0,1),1)*
                          if(abs(z)>5e-7 and abs(z)<7.5e-7 and y >0,
                               if(y<(3*abs(z*1e6)+0.75*sqrt(abs(-(abs(z*1e6)-0.5)*(abs(z*1e6)-0.75))/(-(abs(1e6*z)-0.5)*(abs(z*1e6)-0.75))))/1e6,0,1),1)*
                          if(abs(z)>7.5e-7 and abs(z)< 1e-6 and y >0,
                               if(y<(9*sqrt(abs(-(abs(z*1e6)-1)*(abs(z*1e6)-0.75))/(-(abs(1e6*z)-1)*(abs(z*1e6)-0.75)))-8*abs(z*1e6))/1e6,0,1),1)*
                          if(abs(z)>1e-6 and abs(z)< 3e-6 and y >0,
                               if(y<(6*sqrt(10)/7+(1.5-0.5*abs(z*1e6))*sqrt(abs(abs(z*1e6)-1)/(abs(z*1e6)-1))-6*sqrt(10)*sqrt(4-(abs(1e6*z)-1)**2)/14)/1e6,0,1),1)*
                          if(abs(z)>3e-6 and abs(z) < 7e-6 and y>0,
                               if(y <(3*sqrt(1-(z*1e6/7)**2)*sqrt(abs(abs(z*1e6)-3)/(abs(z*1e6)-3)))/1e6,0,1),1)*
                          if(abs(z)>4e-6 and abs(z)<7e-6 and y<0,
                               if(y >(-3*sqrt(1-(z*1e6/7)**2)*sqrt(abs(abs(z*1e6)-4)/(abs(z*1e6)-4)))/1e6,0,1),1)*
                          if(abs(z)< 4e-6 and y <0,
                                if(y > (abs(z*1e6/2)-(3*sqrt(33)-7)*(z*1e6)**2/122-3.1+sqrt(1-(abs(abs(z*1e6)-2)-1)**2))/1e6,0,1),1)"

a batman pulse could be generated.

Screenshot 2024-06-08 at 02 29 01