<?xml version="1.0" encoding="UTF-8"?>
<simulation xmds-version="2">
  <testing>
    <command_line>mpirun -n 2 ./mpi_highdimcrossprop</command_line>
    <xsil_file name="mpi_highdimcrossprop.xsil" expected="../operators/highdimcrossprop_expected.xsil" absolute_tolerance="1e-5" relative_tolerance="1e-4" />
  </testing>
  <name>mpi_highdimcrossprop</name>
  
  <features>
    <benchmark />
   
    <bing />
      <globals>
<![CDATA[
const real pi=3.14159265358979;
const real g =2*pi*11.4005; // Sqrt(density)/Hz
const real sample_length = 0.2; //m
const real time_input =2.5e-6; // sec (5)
const real sigma=1e-6; // sec (2)
const real inp_hgt=1e3; //photonnum
const real gama=2*pi*5.6e6; //Hz
const real eta =2*pi*10e6/sample_length; //Hz/m (was 2*pi*10e6)
const real omc=2*pi*20e6; //Hz (was 2*pi*20e6)

const real gama0=0; //2*pi*2e3; //Hz
const real gamac=0; //2*pi*1e3; //Hz
const real c=3e8; // m/s
const real timeswitchz=10e-6; // sec (10)

const real N=1e18; // density 
const real gNonc = g*N/c; 
const real delta=2*pi*3e9; //Hz

const real width = 0.001; //m
const real k0 = 6.28 / (795e-9);

const real alpha=0.00; //m^2/s

]]> 
  </globals>
    
  </features>
  <driver name="distributed-mpi" />
  
  <geometry>
    <propagation_dimension> t </propagation_dimension>
    <transverse_dimensions>
	   <dimension name="x" lattice="16" domain="(-0.004,0.004)"  /> 
	   <dimension name="y" lattice="16" domain="(-0.003,0.003)"  /> 
	   <dimension name="z" lattice="512"  domain="(0,0.2)" />
    </transverse_dimensions>
  </geometry>
  
  <vector name="main" initial_basis="z x y" type="complex">
    <components>
    alpha12
    </components>
    <initialisation>
      <![CDATA[
      alpha12 =  0.0;
    
      ]]>
    </initialisation>
  </vector>

    <vector name="crossinitial" initial_basis="x y" type="complex">
    <components>
    beamprofile
    </components>
    <initialisation>
      <![CDATA[
      beamprofile=inp_hgt * (2*sqrt(2)*x/width) * exp(-x*x/(width*width)) * exp(-y*y/(width*width))* exp(-i*k0*(x*x+y*y)/0.5);
      ]]>
    </initialisation>
  </vector>

<vector name="cross1" initial_basis="x y z" type="complex">
    <components>
     E
    </components>
  </vector>
  
  
  <sequence>
    <integrate algorithm="RK4" interval="20e-8" steps="20" tolerance="1.0e-6">
          <samples>2 1 2 2 1 1 1 1 1 1</samples>
      
       <operators>
        <operator kind="cross_propagation" algorithm="RK4"  propagation_dimension="z">
            <operator kind="ip" constant="yes">
              <operator_names>Btt</operator_names>
              <![CDATA[
                Btt = 0; //i*(kx*kx + ky*ky)/(2*k0);
              ]]>
            </operator>

          <integration_vectors>cross1</integration_vectors>
          <!-- You can have a dependencies tag in here -->
          <dependencies>main</dependencies>
          <boundary_condition kind="left">
            <!-- You can also have a dependencies tag in here -->
            <!-- like the one shown below, but none are needed -->
            <!-- in this example -->
			<dependencies>crossinitial</dependencies> 
      <![CDATA[
	  
	  //E=inp_hgt*exp(-(t-time_input)*(t-time_input)/(sigma*sigma)) * exp(-x*x/(width*width))*exp(-y*y/(width*width));
	  E = exp(-(t-time_input)*(t-time_input)/(sigma*sigma)) * beamprofile;
			
			]]>
          </boundary_condition>
          <![CDATA[
      complex aalpha13 = (alpha12*omc+g*E)/delta;
	  
	  dE_dz =  i*gNonc*(aalpha13) + Btt[E]; 
	   
          ]]>
        </operator>
           <operator kind="ip" constant="yes">
              <operator_names>Ltt</operator_names>
              <![CDATA[
                Ltt = -alpha*(kz*kz+kx*kx+ky*ky);
              ]]>
            </operator>
        
        <integration_vectors>main</integration_vectors>
        <![CDATA[

complex sw  = -1.0; //( t<timeswitchz ? -1.0:1.0);

complex aalpha13 = (alpha12*omc+g*E)/(delta-i*(gamac/2+gama+gama0/2));
dalpha12_dt  = ((-gama0 - gamac-i*(sw*eta*(z-sample_length/2) +(omc*omc)/delta))*alpha12+i*aalpha13*(omc)) + Ltt[alpha12];


        ]]>
      </operators>
      
    </integrate>
  </sequence>
  
  <output format="hdf5" filename="mpi_highdimcrossprop.xsil">
    <group>
      <sampling basis="z(128) x(16) y(16)" initial_sample="yes">
        <moments>bprobereal bprobeimag</moments>
        <dependencies>cross1</dependencies>
        <![CDATA[
bprobereal = E.Re();
bprobeimag = E.Im();
        ]]>
      </sampling>
     </group> 
     <sampling_group basis="kx(16) ky(16) kz(128)" initial_sample="yes">
        <moments>bproberealK bprobeimagK bintensityK</moments>
        <dependencies>cross1</dependencies>
        <![CDATA[
          bproberealK = E.Re();
          bprobeimagK = E.Im();
          bintensityK = mod2(E);
        ]]>
      </sampling_group>
      <sampling_group basis="x(16) y(16) z(256)" initial_sample="yes">
        <moments>balpreal12 balpimag12</moments>
        <dependencies>main</dependencies>
        <![CDATA[
balpreal12 = (alpha12).Re();
balpimag12 = (alpha12).Im();
        ]]>
      </sampling_group>
      <sampling_group basis="kx(2) ky(2) kz(256)" initial_sample="yes">
        <moments>balpreal12K balpimag12K</moments>
        <dependencies>main</dependencies>
        <![CDATA[
          balpreal12K = (alpha12).Re();
          balpimag12K = (alpha12).Im();
        ]]>
      </sampling_group>
      <sampling_group basis="x(0) y(0) z(512)" initial_sample="yes">
        <moments>bprobereal bprobeimag</moments>
        <dependencies>cross1</dependencies>
        <![CDATA[
bprobereal = E.Re();
bprobeimag = E.Im();
        ]]>
      </sampling_group>
      <sampling_group basis="x(0) y(16) z(0)" initial_sample="yes">
        <moments>bprobereal bprobeimag</moments>
        <dependencies>cross1</dependencies>
        <![CDATA[
bprobereal = E.Re();
bprobeimag = E.Im();
        ]]>
      </sampling_group>
      <sampling_group basis="x(16) y(0) z(0)" initial_sample="yes">
        <moments>bprobereal bprobeimag</moments>
        <dependencies>cross1</dependencies>
        <![CDATA[
bprobereal = E.Re();
bprobeimag = E.Im();
        ]]>
      </sampling_group>
       <sampling_group basis="x(0) y(0) z(512)" initial_sample="no">
        <moments>balpreal12 balpimag12</moments>
        <dependencies>main</dependencies>
        <![CDATA[
          balpreal12 = Re(alpha12);
          balpimag12 = Im(alpha12);
        ]]>
      </sampling_group>
      <sampling_group basis="x(16) y(0) z(0)" initial_sample="no">
        <moments>balpreal12 balpimag12</moments>
        <dependencies>main</dependencies>
        <![CDATA[
          balpreal12 = Re(alpha12);
          balpimag12 = Im(alpha12);
        ]]>
      </sampling_group>
      <sampling_group basis="x(0) y(16) z(0)" initial_sample="no">
        <moments>balpreal12 balpimag12</moments>
        <dependencies>main</dependencies>
        <![CDATA[
          balpreal12 = Re(alpha12);
          balpimag12 = Im(alpha12);
        ]]>
      </sampling_group>
  </output>
</simulation>
