<?xml version="1.0" ?><simulation xmds-version="2">
  <testing>
    <command_line>mpirun -n 4 ./cpc_example4</command_line>
    <xsil_file absolute_tolerance="1e-5" expected="cpc_example4_expected.xsil" name="cpc_example4.xsil" relative_tolerance="1e-5"/>
  </testing>

  <name> cpc_example4 </name>
  
  <features>
    <benchmark/>
    <auto_vectorise/>
    <globals>
      <![CDATA[
        real N = 10.0; // number of atoms
        real g = 1.0;  // nonlinear coupling
      ]]>
    </globals>
  </features>
  
  <geometry>
    <propagation_dimension> t </propagation_dimension>
    <transverse_dimensions>
      <dimension domain="(-7, 7)" lattice="256" name="x"/>
          <dimension domain="(-7, 7)" lattice="256" name="y"/>    
          <dimension domain="(-1, 1)" lattice="3" name="j" type="integer"/>    
    </transverse_dimensions>
  </geometry>

  <driver name="distributed-mpi"/>

  <vector name="potential" type="real">
    <components> V </components>
    <initialisation>
      <![CDATA[
        V = 0.5*(x*x + y*y);
      ]]>
    </initialisation>
  </vector>
  
  <vector name="wavefunction" type="complex">
    <components> psi </components>
    <initialisation>
      <![CDATA[
        psi = sqrt(N) * pow(M_PI, -0.25) * exp(-(x*x + y*y)/2);
      ]]>
    </initialisation>
  </vector>

  <sequence>
    <integrate algorithm="ARK45" interval="0.628" tolerance="1e-5">
      <samples> 5 </samples>
      <operators>

        <operator constant="yes" dimensions="x" kind="ip">
          <operator_names> Tx </operator_names>
          <![CDATA[
            Tx = -i * 0.5 * (kx * kx);
          ]]>
        </operator>

        <operator constant="yes" dimensions="y" kind="ip">
          <operator_names> Ty </operator_names>
          <![CDATA[
            Ty = -i * 0.5 * (ky * ky);
          ]]>
        </operator>
        <operator constant="yes" dimensions="" kind="ip">
          <operator_names> T </operator_names>
          <![CDATA[
            T = -0.2;
          ]]>
        </operator>

        <operator constant="yes" dimensions="j" kind="ip">
          <operator_names> Tj </operator_names>
          <![CDATA[
            Tj = -0.2*j;
          ]]>
        </operator>

        <integration_vectors>
          wavefunction
        </integration_vectors> 
        <dependencies> potential </dependencies>
        <![CDATA[
          dpsi_dt = Tx[psi] + Ty[psi] + T[psi] + Tj[psi] - i * (V + g * mod2(psi)) * psi;
        ]]>
      </operators>
    </integrate>
  </sequence>

  <output format="hdf5">
    <sampling_group basis="x(16) y(16) j" initial_sample="yes">
      <dependencies> wavefunction </dependencies>
      <moments> psireal psiimag </moments>
      <![CDATA[
        psireal = Re(psi);
        psiimag = Im(psi);
      ]]>
    </sampling_group>
  </output>

<info>
Script compiled with XMDS2 version VERSION_PLACEHOLDER (SUBVERSION_REVISION_PLACEHOLDER)
See http://www.xmds.org for more information.
</info>

<XSIL Name="moment_group_1">
  <Param Name="n_independent">4</Param>
  <Array Name="variables" Type="Text">
    <Dim>6</Dim>
    <Stream><Metalink Format="Text" Delimiter=" \n"/>
t x y j psireal psiimag 
    </Stream>
  </Array>
  <Array Name="data" Type="double">
    <Dim>6</Dim>
    <Dim>16</Dim>
    <Dim>16</Dim>
    <Dim>3</Dim>
    <Dim>6</Dim>
    <Stream><Metalink Format="HDF5" Type="Remote" Group="/1"/>
cpc_example4_expected.h5
    </Stream>
  </Array>
</XSIL>
</simulation>
