Matlab-to-SPINS grid ordering: Difference between revisions

From Fluids Wiki
Jump to navigation Jump to search
Line 21: Line 21:


== Running the code on Graham ==
== Running the code on Graham ==
It's a good idea to test the case you want to run on a local machine first. When you are ready to run the code on Graham, use the following script to submit a job. You will need to replace <code><USER></code> with your user ID, <code><DRIVER_SCRIPT></code> with <code>driver_unidomain.m</code> or <code>driver_multidomain.m</code>, and <code><YOUR_CASE_NAME></code> with the case name identical to <code>casename</code> you specified in <code>driver_unidomain.m</code> or <code>driver_multidomain.m</code>. Also, make sure you have a copy of <code>wave_reader.x</code> for Graham available in the <code>matlab2spins</code> directory, and a "dummy" (or whatever name you want to call it) directory available for log/error files.
Before running the code on Graham, test the case you want to run on a local machine first. When you are ready to run the code on Graham, use the following script to submit a job. You will need to replace <code><USER></code> with your user ID, <code><DRIVER_SCRIPT></code> with <code>driver_unidomain.m</code> or <code>driver_multidomain.m</code>, and <code><YOUR_CASE_NAME></code> with the case name identical to <code>casename</code> you specified in <code>driver_unidomain.m</code> or <code>driver_multidomain.m</code>. Also, make sure you have a copy of <code>wave_reader.x</code> for Graham available in the <code>matlab2spins</code> directory, and a "dummy" (or whatever name you want to call it) directory available for log/error files.


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">

Revision as of 18:02, 9 July 2018

Matlab to SPINS grid ordering, for a 2D domain with periodic (or free-slip) conditions in the x-direction and free-slip conditions in the z-direction and a flat bottom boundary. It solves the DJL equation for solitary waves or the Taylor-Goldstein equation for traveling/standing linear waves, interpolates the u, w and rho fields onto a regular (non-Cheb) grid, and then saves the data as SPINS input files (for wave_reader_x).

Getting the code

The code is hosted in a git repository on the UW git server. To extract the code from the git repository, go to (or create) the directory in which you want to run simulations using SPINS. In that directory, type git clone https://git.uwaterloo.ca/c2xu/matlab2spins.git. This will create a directory called matlab2spins where the code is stored.

Components

  • driver_unidomain.m Input parameters and main driver file for matlab2spins2d.m.
  • driver_multidomain.m Input parameters and main driver file for matlab2spins2d.m with different waves in multiple domains combined together.
  • tg.m Taylor-Goldstein equation solver for traveling/standing linear waves.
  • get_eta.m Main iteration loop of the DJL solver.
  • md_diff.m Differentiation matrix for the DJL solver.
  • iswpost.m Post processing for the DJL solver.
  • iswpic.m Making plots for the DJL solver.
  • find_contour.m Find the contour of Ri=0.25 in the DJL solution.
  • contour_data.m Function called by find_contour.m.
  • spins_interp2d.m Interpolation of flow fields from DJL/TG solver onto SPINS grid.
  • resize_x.m Spectral interpolation in x-direction.
  • resize_z.m Spectral interpolation in z-direction.
  • matlab2spins2d.m Writing data to disk.

Running the code on Graham

Before running the code on Graham, test the case you want to run on a local machine first. When you are ready to run the code on Graham, use the following script to submit a job. You will need to replace <USER> with your user ID, <DRIVER_SCRIPT> with driver_unidomain.m or driver_multidomain.m, and <YOUR_CASE_NAME> with the case name identical to casename you specified in driver_unidomain.m or driver_multidomain.m. Also, make sure you have a copy of wave_reader.x for Graham available in the matlab2spins directory, and a "dummy" (or whatever name you want to call it) directory available for log/error files.

#!/bin/bash
# bash script for submitting a Matlab job to the sharcnet Graham queue

#SBATCH --mem-per-cpu=2G                    # memory per processor (default in Mb)
#SBATCH --time=01-00:00                     # time (DD-HH:MM)
#SBATCH --job-name="<YOUR_CASE_NAME>"       # job name
#SBATCH --input=<DRIVER_SCRIPT>             # Matlab script
##SBATCH —dependency=afterok:<jobid>        # Wait for job to complete

##SBATCH --ntasks=1                         # number of processors
#SBATCH --nodes=1                           # number of nodes
#SBATCH --ntasks-per-node=32                # processors per node
#SBATCH --output=../dummy/sim-%j.log        # log file
#SBATCH --error=../dummy/sim-%j.err         # error file
#SBATCH --mail-user=<USER>@uwaterloo.ca     # who to email
#SBATCH --mail-type=FAIL                    # when to email
#SBATCH --account=ctb-mmstastn              # UW Fluids designated resource allocation

casename='<YOUR_CASE_NAME>'

module load matlab/2018a
matlab -nodisplay -nosplash -singleCompThread

cp wave_reader.x ../$casename
cd ../$casename
srun ./wave_reader.x