<?xml version="1.0" encoding="UTF-8"?>
<simulation xmds-version="2">
  <testing>
    <xsil_file name="fibre_with_correlation_function.xsil" expected="fibre_with_correlation_function_expected.xsil" absolute_tolerance="5e-5" relative_tolerance="1e-3" />
  </testing>
  <name>fibre_with_correlation_function</name>
  <author>Unknown author</author>
  <description>
    Example fibre noise simulation
  </description>
  
  <geometry>
    <propagation_dimension> t </propagation_dimension>
    <transverse_dimensions>
      <dimension name="x" lattice="64"  domain="(-5, 5)" aliases="xp" />
    </transverse_dimensions>
  </geometry>
  
  <features>
    <auto_vectorise />
    <benchmark />
    <bing />
    <stochastic>
      <noise kind="gaussian-solirte" prefix="n" num="2" seed="293485"/>
      <!-- If there is no seed attribute then seeds will be chosen randomly at run-time -->
    </stochastic>
    <globals>
      <![CDATA[
      const real ggamma = 1.0;
      const real beta = sqrt(2.0*M_PI*ggamma/10.0);
      ]]>
    </globals>
  </features>
  
  <vector name="main" initial_basis="x" type="complex">
    <components>phi</components>
    <initialisation no_noises="true">
      <![CDATA[
        phi = 0.0;
      ]]>
    </initialisation>
  </vector>
  
  <sequence>
    <integrate algorithm="SI" interval="2.5" steps="200000" tolerance="1e-6">
      <samples>50 1 1</samples>
      <operators>
        <operator kind="ex" constant="yes">
          <operator_names>L</operator_names>
          <![CDATA[
            L = -i*kx*kx;
          ]]>
        </operator>
        <integration_vectors>main</integration_vectors>
        <![CDATA[
          dphi_dt = L[phi] - ggamma*phi + beta*complex(n_1, n_2);
        ]]>
      </operators>
    </integrate>
  </sequence>
  
  <output format="binary">
      <sampling_group basis="kx" initial_sample="yes">
        <moments>pow_dens</moments>
        <dependencies>main</dependencies>
        <![CDATA[
          pow_dens = mod2(phi);
        ]]>
      </sampling_group>
      <sampling_group basis="x xp" initial_sample="no">
        <moments>g1 g2</moments>
        <dependencies>main</dependencies>
        <![CDATA[
          g1 = abs(conj(phi) * phi(x => xp));
          g2 = mod2(phi) * mod2(phi(x => xp));
        ]]>
      </sampling_group>
      <sampling_group basis="kx kxp" initial_sample="no">
        <moments>g1 g2 g2minus</moments>
        <dependencies>main</dependencies>
        <![CDATA[
          g1 = abs(conj(phi) * phi(kx => kxp));
          g2 = mod2(phi) * mod2(phi(kx => kxp));
          g2minus = mod2(phi) * mod2(phi(kx => -kxp));
        ]]>
      </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">2</Param>
  <Array Name="variables" Type="Text">
    <Dim>3</Dim>
    <Stream><Metalink Format="Text" Delimiter=" \n"/>
t kx pow_dens 
    </Stream>
  </Array>
  <Array Name="data" Type="double">
    <Dim>51</Dim>
    <Dim>64</Dim>
    <Dim>3</Dim>
    <Stream><Metalink Format="Binary" UnsignedLong="uint32" precision="double" Type="Remote" Encoding="LittleEndian"/>
fibre_with_correlation_function_expected_mg0.dat
    </Stream>
  </Array>
</XSIL>

<XSIL Name="moment_group_2">
  <Param Name="n_independent">2</Param>
  <Array Name="variables" Type="Text">
    <Dim>4</Dim>
    <Stream><Metalink Format="Text" Delimiter=" \n"/>
x xp g1 g2 
    </Stream>
  </Array>
  <Array Name="data" Type="double">
    <Dim>64</Dim>
    <Dim>64</Dim>
    <Dim>4</Dim>
    <Stream><Metalink Format="Binary" UnsignedLong="uint32" precision="double" Type="Remote" Encoding="LittleEndian"/>
fibre_with_correlation_function_expected_mg1.dat
    </Stream>
  </Array>
</XSIL>

<XSIL Name="moment_group_3">
  <Param Name="n_independent">2</Param>
  <Array Name="variables" Type="Text">
    <Dim>5</Dim>
    <Stream><Metalink Format="Text" Delimiter=" \n"/>
kx kxp g1 g2 g2minus 
    </Stream>
  </Array>
  <Array Name="data" Type="double">
    <Dim>64</Dim>
    <Dim>64</Dim>
    <Dim>5</Dim>
    <Stream><Metalink Format="Binary" UnsignedLong="uint32" precision="double" Type="Remote" Encoding="LittleEndian"/>
fibre_with_correlation_function_expected_mg2.dat
    </Stream>
  </Array>
</XSIL>
</simulation>
