Prerequisites
Make sure you have a version of git and python 2.7 installed and have a github account
Download
First obtain a copy of the current Einstein Toolkit website and tool to transfer trac tickets to github:
git clone git@bitbucket.org:einsteintoolkit/www.git einsteinwebsitegit clone
mpute the array of energies and store the results in energy[index]
. Add code to WaveMoL_Energy
that
Exercise
Open the file arrangements/CactusExamples/WaveMoL/src/WaveMoL.c
which contains the C code used to compute phi and a quantity called energy. Find the function WaveMoL_Energy
which is located at the end of the file. The function is called once per timestep and computes a quantity energy
which is always positive (or zero). The loops
for (k=0; k<cctk_lsh[2]; k++) { for (j=0; j<cctk_lsh[1]; j++) { for (i=0; i<cctk_lsh[0]; i++) { index = CCTK_GFINDEX3D(cctkGH,i,j,k); energy[index] = phit[index]*phit[index] + phix[index]*phix[index] + phiy[index]*phiy[index] + phiz[index]*phiz[index]; } } }
compute the array of energies and store the results in energy[index]
. Add code to WaveMoL_Energy
that
- computes the maximum value of
energy[index]
- writes this value as a function of time to a file
energy_maximum.xg
using the same format asphi_maximum.xg
. Time is accessible as the variablecctk_time
.
Please compile the code once more, run it and send me the modified source file as well as energy_maximum.xg
to me before the interview.
./simfactory/bin/sim build --mdbkey make 'make -j2' exe/cactus_sim arrangements/CactusExamples/WaveMoL/par/gaussian.par
Hint
You can access the value of phi
as phi[index]
and check that your code produces the same results as found in phi_maximum.xg
.
If you prefer to use C++ instead of plain C you can rename the file WaveMoL.c
to WaveMoL.cc
, update the file arrangements/CactusExamples/WaveMoL/src/make.code.defn
to list WaveMoL.cc
and recompile.
This fragment outputs time:
printf("Current time: %g\n", cctk_time);
Solution
If you get stumped with the exercise, here's a worked out solution. Obviously you cannot send me this one before the interview .