-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from mabarnes/parameter-scan-update
Update automated parameter scan functionality
- Loading branch information
Showing
18 changed files
with
359 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Parameter scans | ||
=============== | ||
|
||
Running a scan | ||
-------------- | ||
|
||
Parameter scans can be run using the `run_parameter_scan.jl` script. To run from the REPL | ||
```julia | ||
$ julia -p 8 --project -O3 | ||
julia> include("run_parameter_scan.jl") | ||
julia> run_parameter_scan("path/to/an/input/file.toml") | ||
``` | ||
or to run a single scan from the command line | ||
```shell | ||
$ julia -p 8 --project -O3 run_parameter_scan.jl path/to/an/input/file.toml | ||
``` | ||
The `-p 8` argument passed to julia in these examples is optional. It indicates | ||
that julia should use 8 processes for parallelism. In this case we are not | ||
using MPI - each run in the scan is run in serial, but up to 8 (in this | ||
example) runs from the scan can be performed simultaneously (using the | ||
`@distributed` macro). | ||
|
||
The runs can use MPI - in this case call julia using `mpirun`, etc. as usual | ||
but do not pass the `-p` argument. Mixing MPI and `@distributed` would cause | ||
oversubscription and slow everything down. The runs will run one after the | ||
other, and each run will be MPI parallelised. | ||
|
||
The inputs (see [`moment_kinetics.parameter_scans.get_scan_inputs`](@ref)) can | ||
be passed to the function in a Dict, or read from a TOML file. | ||
|
||
`run_parameter_scan` can also be passed a directory (either as an argument to | ||
the function or from the command line), in which case it will perform a run for | ||
every input file contained in that directory. | ||
|
||
Post processing a scan | ||
---------------------- | ||
|
||
[`moment_kinetics.makie_post_processing.makie_post_process`](@ref) can be | ||
called for each run in a scan. For example to post process the scan in | ||
`runs/scan_example` from the REPL | ||
```julia | ||
$ julia -p 8 --project -O3 | ||
julia> include("post_process_parameter_scan.jl") | ||
julia> post_process_parameter_scan("runs/scan_example/") | ||
``` | ||
or to from the command line | ||
```shell | ||
$ julia -p 8 --project -O3 post_process_parameter_scan.jl runs/scan_example/ | ||
``` | ||
Again the `-p 8` argument passed to julia in these examples is optional. It | ||
indicates that julia should use 8 processes for parallelism. Each run in the | ||
scan is post-processed in serial, but up to 8 (in this example) runs from the | ||
scan can be post-processed simultaneously (using the `@distributed` macro). | ||
|
||
API | ||
--- | ||
|
||
```@autodocs | ||
Modules = [moment_kinetics.parameter_scans] | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Pkg | ||
Pkg.activate(".") | ||
|
||
using Distributed | ||
|
||
@everywhere using moment_kinetics.makie_post_processing: makie_post_process | ||
|
||
# get the run_names from the command-line | ||
function post_process_parameter_scan(scan_dir) | ||
run_directories = Tuple(d for d ∈ readdir(scan_dir, join=true) if isdir(d)) | ||
@sync @distributed for d ∈ run_directories | ||
println("post-processing ", d) | ||
try | ||
makie_post_process(d) | ||
catch e | ||
println(d, " failed with ", e) | ||
end | ||
end | ||
end | ||
|
||
if abspath(PROGRAM_FILE) == @__FILE__ | ||
post_process_parameter_scan(ARGS[1]) | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Pkg | ||
Pkg.activate(".") | ||
|
||
using Distributed | ||
|
||
@everywhere using moment_kinetics | ||
using moment_kinetics.parameter_scans: get_scan_inputs | ||
|
||
""" | ||
run_parameter_scan(args...) | ||
Run a parameter scan, getting the inputs for each run from | ||
[`moment_kinetics.parameter_scans.get_scan_inputs`](@ref). | ||
If MPI is not used (i.e. each run should be run in serial), then `@distributed` | ||
parallelism can be used to launch several runs at the same time. To do this, start julia | ||
using the `-p` option to set the number of distributed processes, for example | ||
```shell | ||
\$ julia --project -p 8 run_parameter_scan.jl examples/something/scan_foobar.toml | ||
``` | ||
When MPI is used, do not pass the `-p` flag to julia. Each run will run in parallel using | ||
MPI, and the different runs in the scan will be started one after the other. | ||
""" | ||
function run_parameter_scan(args...) | ||
scan_inputs = get_scan_inputs(args...) | ||
|
||
@sync @distributed for s ∈ scan_inputs | ||
println("running ", s["run_name"]) | ||
run_moment_kinetics(s) | ||
end | ||
|
||
return nothing | ||
end | ||
|
||
if abspath(PROGRAM_FILE) == @__FILE__ | ||
run_parameter_scan() | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.