Parallel bash for loop to lattices tutorial.

Former-commit-id: 065638f79fbe8f37f681dd10f93b9914883c9577
This commit is contained in:
Marek Nečada 2019-06-12 14:53:50 +03:00
parent 8bd1ad1898
commit 4e199e822f
1 changed files with 11 additions and 2 deletions

View File

@ -80,7 +80,16 @@ This pre-calculates the translation operators for a simple (one particle per uni
621 nm × 571 nm rectangular lattice inside a medium with refractive index 1.52, 621 nm × 571 nm rectangular lattice inside a medium with refractive index 1.52,
up to the octupole (`lMax` = 3) order, yielding one file per frequency. up to the octupole (`lMax` = 3) order, yielding one file per frequency.
This can take some time and This can take some time and
it makes sense to run a parallelised `for`-loop instead. it makes sense to run a parallelised `for`-loop instead; this is a stupid but working
way to do it in bash:
```
N=4 # number of parallel processes
for omega in $(cat omegalist); do
((i=i%N)); ((i++==0)) && wait
ew_gen_kin $omega 621e-9 0 0 571e-9 3 w_$omega 1.52 1 0 0 < klist
echo $omega # optional, to follow progress
done
```
When this is done, we convert all the text output files into When this is done, we convert all the text output files into
numpy's binary format in order to speed up loading in the following steps. numpy's binary format in order to speed up loading in the following steps.
@ -94,7 +103,7 @@ is the destination path for the converted data (this will be
a directory), and the remaining arguments are paths to the a directory), and the remaining arguments are paths to the
files generated by `ew_gen_kin`. In the case above, one could use files generated by `ew_gen_kin`. In the case above, one could use
``` ```
processWfiles_sortnames.py 1 all s_* processWfiles_sortnames.py 1 all w_*
``` ```
which would create a directory named `all` containing several which would create a directory named `all` containing several
.npy files. .npy files.