• The added line is THIS COLOR.
  • The deleted line is THIS COLOR.
* How to simulate [#f5c9dfdb]
#freeze
* How to simulate your own problems[#f5c9dfdb]

** To perform normal simulation [#le4c697d]
** To make "input.udf" for own purpose [#e1cb8b6d]

- Obtain an appropriate sample UDF file for your purpose from our examples.
- The simplest way is to use an appropriate sample UDF which can be found in "Examples" in the left menu.

- Start GOURMET and open the UDF file. Modify it for your own purpose and save it as "input.udf". GOURMET operation manual is here.
-- &ref(GourmetOperation_eng.pdf);.
-- &ref(GourmetOperation_jpn.pdf);.
- Start GOURMET and open an appropriate UDF. Modify it for your own purpose if necessarily and save it as "input.udf". GOURMET operation manual is here.
-- &ref(Docs/gourmetoperation_eng.pdf);.
-- &ref(Docs/GourmetOperation_jpn.pdf);.

- Run KAPSEL as follows.
- UDF is a text file. One can browse and edit it using a text editor, but it.can be more easily handled with GOURMET. See the manuals below for general information on UDF.
-- English: &ref(Docs/udf_spec_eng.pdf);
-- Japanese: &ref(Docs/UDF_Spec_jpn.pdf);

    > ../kapsel -Iinput.udf -Ooutput.udf -Ddefine.udf -Rrestart.udf
- In UDF of KAPSEL, one must first choose the type of problem you want to simulate by selecting "constitutive_eq" from list below.
-- Navier_Stokes: (sedimentation, diffusion, coagulation)
-- Shear_Navier_Stokes: (dynamics in shear flow, rheology)
-- Shear_Navier_Stokes_Lees_Edwards: (dynamics in shear flow, rheology)
-- Electrolyte: (electrophoresis)

-- "''-I''" option defines the name of UDF file which contains details of simulation (type of simulation, initial conditions, physical and simulation parameters, etc...).
-- "''-O''" option defines the name of UDF file which contains the results (time-dependent positions and velocities of all the particles, etc...) of the simulation.
-- "''-D''" option defines the name of UDF file which contains definitions of KAPSEL data format. This is common for any simulations, but the versions of input.udf and define.udf must be the same.
-- "''-R''" option defines the name of UDF file which contains values of all dynamical variables at the end of the simulation See "Re-start run" below.
-- Field data (fluid velocities, ionic densitied, etc...) is saved in a subdirectory specified in "input.udf" if "output.AVS" = "on". This requires huge disk space (GB order). No field data is saved if "output.AVS" = "off".
- Computation times of each run scale almost lineally with the size of CFD grid times the iteration steps (L^3 x Step). The largest part of the computation time is used by FFT calculations for solving fluid motion (and also for Poisson Eq. in case of electrolyte).  Additional costs for solving particles motions are quite small.
-- 10^5 iterations of 256^3 system takes roughly 5 days on a single core of Intel CPU.
-- Use of OpenMP much improves the computational performance on multi-core machines. The speed-up depends on the size of CFD grids (the speed-up is typically between 4 and 6 times using 8 cores).

- Start GOURMET and open "output.udf". 
-- Instantaneous  positions and velocities of all the particles can be seen as variables in "Particles[]". Use slide bar at the bottom of GOURMET viewer window to see variables at different time steps.
//-- Load "plot.py" to plot time evolutions of the variables. ([[See STEP4>InstallB]])
//-- Load "particleshow.py" to visualize motions of particles. ([[See STEP4>InstallB]])
- Older versions of UDF(v2.0,v2.1) must be converted to UDF(v3.0) before run. You can use &ref(convert.py); for this conversion. The script requires &ref(input_3.00.udf); and &ref(define_3.00.udf); additionally to old input_2.00.udf, which is to be converted, and define_2.00.udf called from it. In the following example, input_2.00.udf (v2.0) is converted to input_new.udf (v3.0).

** Visualize the simulation result [#de6c8fcf]
  > ls
  > convert.py define_2.00.udf define_3.00.udf input_2.00.udf input_3.00.udf
  > python convert.py input_2.00.udf input_new.udf

- The sample input.udf takes less than a minute to run.

- Animation on GOURMET
-- Save &ref(particleshow.py);.
-- Start GOURMET
-- "File" -> "Open" -> Open "output.udf".
-- Move down to "Python" panel, and click "Load"
-- Open "particleshow.py".
-- Click "Run"
-- A new window will open, and click the playback button ">" there.
//#ref(000.jpg,,80%)
** To perform normal simulation [#le4c697d]

- Gnuplot on GOURMET
-- Save &ref(plot.py);.
-- Start GOURMET
-- "File" -> "Open" -> Open "output.udf".
-- Move down to "Python" panel, and click "Load"
-- Open "plot.py", and click "Run"
-- Move up "View" box, and check "Table"
-- Move down-left and select "Graph Sheet[]".
-- Move down to "Plot" panel, and type plot "plot.dat" using 2:7 title 'vy0' with lines in the command box.
-- Click "Plot", and you will see the time evoluation of Vx.
//#ref(velocity_x.jpg,,40%)
- Run KAPSEL as follows.

- Animation on AVS/Express (optional)
-- One can enjoy much advanced data-visualization with AVS/Express. A sample visualization network &ref(avs_charge.v); is attached.
#youtube(Zuj8T6PunC8)
  > ../kapsel -Iinput.udf -Ooutput.udf -Ddefine.udf -Rrestart.udf

-- "''-I''" option defines the name of UDF file which contains details of simulation (type of simulation, initial conditions, physical and simulation parameters, etc...).
-- "''-O''" option defines the name of UDF file which contains the results (time-dependent positions and velocities of all the particles, etc...) of the simulation.
-- "''-D''" option defines the name of UDF file which contains definitions of KAPSEL data format. This is common for any simulations, but the versions of input.udf and define.udf must be the same.
-- "''-R''" option defines the name of UDF file which contains values of all dynamical variables at the end of the simulation See "Re-start run" below.
-- Field data (fluid velocities, ionic densitied, etc...) is saved in a subdirectory specified in "input.udf" if "output.AVS" = "on". This requires huge disk space (GB order). No field data is saved if "output.AVS" = "off".

** To re-start previous simulation  [#u7810c9a]
** To re-start from past runs [#u7810c9a]

- One can re-start simulations from the end of the previous run.
- One can re-start normally terminated simulations from the end of the previous run.

- Start GOURMET, and open "restart.udf"

- Set "resume.Calculation" = "CONTINUE"

- Increase "output.Num_step", and save it as "input2.udf"

- Run KAPSEL as follows. 

    > ../kapsel -Iinput2.udf -Ooutput2.udf -Ddefine.udf -Rrestart2.udf
  > ../kapsel -Iinput2.udf -Ooutput2.udf -Ddefine.udf -Rrestart2.udf

** To analyze simulation data [#hcc313c6]

- The history of simulation run (instantaneous positions and velocities of particles) is stored in "output.udf". One can access to this file by one of the following methods.

-- Python program. Read the manual below.
--- English: &ref(pythoninterface_eng.pdf); 
--- Japanese: &ref(PythonInterface_jpn.pdf);
--- &ref(sk.py); is a sample python script to calculate the static structure factor S(k) from the temporal particle positions stored in "output.udf". Read and edit the script for your purpose. 
 - For Windows
   "Start Menu" > "All Programs" > "OCTA2010" > "StartGourmetTerm"
   > python sk.py  (Sample only, can be abnormally terminated. The "numpy" package must be installed separately to handle array variables used in "sk.py".)

-- Fortran or C program with libplatform (library to access UDF). Read the manual below.
--- English: &ref(Install/libplatform_eng.pdf);
--- Japanese: &ref(Install/libplatform_jpn.pdf);

- KAPSEL outputs some important data to stderr. It usually appears in command line, but one can redirect stderr to a file on csh and tcsh
 > ../kapsel  -Iinput.udf -Ooutput.udf -Ddefine.udf -Rrestart.udf >& out1
or on sh, bash, and Windows command prompt
 # ../kapsel  -Iinput.udf -Ooutput.udf -Ddefine.udf -Rrestart.udf  2> out1