Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial propagation angle of laser enabled #1057

Merged
merged 28 commits into from
Feb 16, 2024

Conversation

huixingjian
Copy link
Contributor

@huixingjian huixingjian commented Jan 3, 2024

The laser is now allowed to be initialized with a transverse angle on yoz plane by setting laser.init_angle_yz.
The testing input script is

amr.n_cell = 1023 1023 1000
my_constants.L= 4e-4
my_constants.maxstep=200
my_constants.kp = wp/clight
my_constants.wp = sqrt( ne * q_e^2/(m_e *epsilon0) )
my_constants.ne = 1.58e23
my_constants.Plasma_len= 0.00200
my_constants.W0=40e-6

max_step = maxstep
hipace.verbose = 1
hipace.dt = (Plasma_len)/(clight*maxstep)
diagnostic.output_period = 10
hipace.deposit_rho = 1
hipace.numprocs_x = 1i
hipace.numprocs_y = 1
hipace.do_device_synchronize = 1
amr.max_level = 0
#hipace.comms_buffer_on_gpu=1
#hipace.comms_buffer_max_leading_slices=250
#hipace.comms_buffer_max_trailing_slices=250

geometry.is_periodic = false  false  false  # Is periodic?
geometry.prob_lo     = -0.0001   -10*W0  -0.0001
geometry.prob_hi     =  0.0001   -0.00000    0.0001

lasers.names = laser
lasers.lambda0 = 800e-9
lasers.solver_type = fft
laser.a0 =0.1
laser.position_mean = 0. -2.5*W0 0.
laser.w0 = W0
laser.L0 = 100e-15*clight
lasers.use_phase = 0
laser.init_angle_yz=-0.017
plasmas.names = plasma
plasma.density(x,y,z) = "ne"
plasma.ppc = 1 1
plasma.element = electron

diagnostic.diag_type = yz

And the result is tested by means of python script

N=0
laser_imag1, info_laser_image1 = ts.get_field( iteration=N,  field='laser_imag')
laser_real1, info_laser_real1 = ts.get_field( iteration=N,  field='laser_real')
laser_module1=np.array((laser_real1**2+laser_imag1**2)**0.5)
#laser_module1=laser_module1.T# caculate the modules for N
y_coord1=np.array(info_laser_real1.y)
z_coord1=np.array(info_laser_real1.z)
#cancel the noise in laser_module
laser_module1[laser_module1 < 0.000001] = 0
phi_envelop=np.array(np.arctan2(laser_imag1, laser_real1))
#unwrap phi_envelop
phi_envelop = np.unwrap(phi_envelop, axis=1)
    #filtering"  
window_size = 10
filtered_phi_envelop = np.zeros_like(phi_envelop)
filter_kernel = np.ones(window_size) / window_size
filtered_phi_envelop = np.apply_along_axis(lambda x: np.convolve(x, filter_kernel, mode='same'), axis=1, arr=phi_envelop)
phi_envelop=np.array(filtered_phi_envelop)
#calculate pphi_py
y_diff = np.diff(y_coord1)
pphi_py = (np.diff(phi_envelop, axis=1)) / y_diff
theta1=pphi_py/k0
sigma = np.sum(np.sum(theta1*laser_module1[:,1:len(y_coord1)]))
summ=np.sum(np.sum(laser_module1))
theta_num=(sigma/summ)

The output of theta_num shows that the laser is perfectly initialized with a transverse angle. And the error is small enough to be neglected. And then we let the pulse propagate for 2mm and trace the pulse orbit by the following script:

#plot the position
laser_y=[]
beam_y=[]
z_prop=[]
for N in range(0,210,10):
  laser_imag1, info_laser_image1 = ts.get_field( iteration=N,  field='laser_imag')
  laser_real1, info_laser_real1 = ts.get_field( iteration=N,  field='laser_real')
  laser_module1=np.array((laser_real1**2+laser_imag1**2)**0.5)
  y_coord1=np.array(info_laser_real1.y)
  z_coord1=np.array(info_laser_real1.z)
  ymean=0
  #zmean=0
  sum=0
  for i in range(len(y_coord1)):
    for j in range(len(z_coord1)):
        ymean=ymean+y_coord1[i]*laser_module1[j,i]
        #zmean=zmean+z_coord1[j]*laser_module1[j,i]
        sum=sum+laser_module1[j,i]
  #zmean=zmean/sum
  ymean=ymean/sum
  laser_y.append(ymean)
  z_prop.append(scc.c*N*dt)

Under this resolution, the slope of the orbit is -0.017036.

@AlexanderSinn AlexanderSinn added the component: laser envelope About the laser envelope solver label Jan 9, 2024
Copy link
Member

@MaxThevenet MaxThevenet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! See comments below. Could you add some documentation for the user? A NEW entry at the end of this section

Laser parameters
would be great.

@@ -22,6 +22,7 @@ public:
std::string m_name {""};
amrex::Real m_a0 {0.}; /**< Laser peak normalized amplitude */
amrex::Real m_w0 {0.}; /**< Laser waist */
amrex::Real m_init_angle_yz {0.}; /**< initial angle of laser pulse fron tilt on yoz */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name could be more explicit, and the description is not too accurate. Here is a suggestion. Note that renaming the variable here would require other changes below.

Suggested change
amrex::Real m_init_angle_yz {0.}; /**< initial angle of laser pulse fron tilt on yoz */
amrex::Real m_propagation_angle_yz {0.}; /**< Propagation angle of the pulse in the yz plane (0 is the along the z axis) */

Comment on lines 1020 to 1026
amrex::Real z = plo[2] + (islice+0.5_rt)*dx_arr[2] - z0;
amrex::Real x = (i+0.5_rt)*dx_arr[0]+plo[0]-x0;
amrex::Real y = (j+0.5_rt)*dx_arr[1]+plo[1]-y0;
const amrex::Real yp=std::cos(init_angle_yz)*y+std::sin(init_angle_yz)*z;
const amrex::Real zp=-std::sin(init_angle_yz)*y+std::cos(init_angle_yz)*z;
z=zp;
y=yp;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
amrex::Real z = plo[2] + (islice+0.5_rt)*dx_arr[2] - z0;
amrex::Real x = (i+0.5_rt)*dx_arr[0]+plo[0]-x0;
amrex::Real y = (j+0.5_rt)*dx_arr[1]+plo[1]-y0;
const amrex::Real yp=std::cos(init_angle_yz)*y+std::sin(init_angle_yz)*z;
const amrex::Real zp=-std::sin(init_angle_yz)*y+std::cos(init_angle_yz)*z;
z=zp;
y=yp;
amrex::Real x = (i+0.5_rt)*dx_arr[0]+plo[0]-x0;
# y and z location of the grid points
amrex::Real yg = (j+0.5_rt)*dx_arr[1]+plo[1]-y0;
amrex::Real zg = plo[2] + (islice+0.5_rt)*dx_arr[2] - z0;
# Rotation in the yz plane to set the laser's propagation direction
const amrex::Real y=std::cos(init_angle_yz)*yg+std::sin(init_angle_yz)*zg;
const amrex::Real z=-std::sin(init_angle_yz)*yg+std::cos(init_angle_yz)*zg;

// Compute envelope for time step 0
Complex diffract_factor = 1._rt + I * z * 2._rt/( k0 * w0 * w0 );
Complex diffract_factor = 1._rt + I * (z-zfoc*std::cos(init_angle_yz)) * 2._rt/( k0 * w0 * w0 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check if this correction is needed? e.g. by running with zero and non-zero (but small) angle, and checking where the laser is focused?

Copy link
Member

@AlexanderSinn AlexanderSinn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for this PR!

Copy link
Member

@MaxThevenet MaxThevenet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! See inlined comments. Also, could you remove file .DS_Store from the PR?

Copy link
Member

@MaxThevenet MaxThevenet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! See minor comments below.

Co-authored-by: Maxence Thévenet <maxence.thevenet@desy.de>
@MaxThevenet MaxThevenet merged commit 9e84a1e into Hi-PACE:development Feb 16, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: laser envelope About the laser envelope solver
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants