<?xml version="1.0" encoding="UTF-8"?>
<simulation xmds-version="2">
  <testing>
    <arguments>--time_factor 2.0 --size 25.0</arguments>
    <xsil_file name="arguments.xsil" expected="arguments_expected.xsil" absolute_tolerance="1e-7" relative_tolerance="1e-5" />
  </testing>
  
  <name>arguments</name>
  <author>Andy Ferris</author>
  <description>
    Simple one-dimensional diffusion with a pointless second dimension thrown in for fun.
    Uses arguments and argument preprocessing. Essentially the simulation "looks" the
    same for any given "size", as the interval/etc is scaled to fit the interesting region.
    The user may use width_scale, time_scale and ratio to zoom out and in...
  </description>
  
  <features>
    <benchmark />
    <fftw plan="exhaustive" />
    <validation kind="run-time"/>
    <globals>
      <![CDATA[
      double minx;
      double maxx;
      double miny;
      double maxy;
      double width;
      double time_interval;
      ]]>
    </globals>
    <arguments>
      <argument name="size" type="double" default_value="20.0"/>
      <argument name="ratio" type="double" default_value="0.1"/>
      <argument name="width_factor" type="double" default_value="1.0"/>
      <argument name="time_factor" type="double" default_value="1.0"/>
      <![CDATA[
      minx = -0.5*size;
      maxx = 0.5*size;
      miny = -0.5*size*ratio;
      maxy = 0.5*size*ratio;
      width = 0.5*sqrt(0.5)*size*ratio*width_factor; // half the simulation size
      // The time intersting stuff happens scales as width^2
      time_interval = 20.0 * width*width * time_factor;
      ]]>
    </arguments>
  </features>
  
  <geometry>
    <propagation_dimension> t </propagation_dimension>
    <transverse_dimensions>
      <dimension name="x" lattice="32"  domain="(minx, maxx)" />
      <dimension name="y" lattice="128" domain="(miny, maxy)" />
    </transverse_dimensions>
  </geometry>
  
  <vector name="main" initial_basis="x y" type="complex">
    <components>
      phi
    </components>
    <initialisation>
      <![CDATA[
        phi = exp(-y*y/(2*width*width));
      ]]>
    </initialisation>
  </vector>
  
  <sequence>
    <!-- This is an interesting simulation because using IP operators means there is NO error due to the algorithm (though there may be numerical error) -->
    <integrate algorithm="RK4" interval="time_interval" steps="24">
      <samples>24</samples>
      <operators>
        <operator kind="ip" constant="yes" fourier_space="x ky">
          <operator_names>L</operator_names>
          <![CDATA[
            L = -0.02*ky*ky;
          ]]>
        </operator>
        <integration_vectors>main</integration_vectors>
        <![CDATA[
          dphi_dt = L[phi];
        ]]>
      </operators>
    </integrate>
  </sequence>
  <output format="binary">
      <sampling_group initial_sample="yes">
        <!-- Any dimension not mentioned is assumed to be in real space and its middle element will be sampled -->
        <!-- Note that dimensions can be in any order. Not that I can think of a reason why you would want to do that -->
        <dimension name="x" lattice="0" fourier_space="x" />
        <dimension name="y" lattice="128" fourier_space="y" />
        <moments>dens</moments>
        <dependencies>main</dependencies>
        <![CDATA[
          dens = mod2(phi);
        ]]>
      </sampling_group>
  </output>

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

Variables that can be specified on the command line:
  Command line argument size = 2.500000e+01
  Command line argument ratio = 1.000000e-01
  Command line argument width_factor = 1.000000e+00
  Command line argument time_factor = 2.000000e+00
</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 y dens 
    </Stream>
  </Array>
  <Array Name="data" Type="double">
    <Dim>25</Dim>
    <Dim>128</Dim>
    <Dim>3</Dim>
    <Stream><Metalink Format="Binary" UnsignedLong="uint32" precision="double" Type="Remote" Encoding="LittleEndian"/>
arguments_expected_mg0.dat
    </Stream>
  </Array>
</XSIL>
</simulation>
