-
Notifications
You must be signed in to change notification settings - Fork 17
Create test for the predictor corrector in RTheta geometry. #406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Changes from 27 commits
c710a3e
99c5a95
de830a2
aec4974
4e901fe
30c0886
130839f
6413737
2936963
1c82ca7
ef78a1f
75d73a5
445118f
8e3a65a
8f78251
fcf0e9a
207d8ad
97855e6
fdb4a25
c59a81d
2c2cc1b
1c9837c
9e2e493
561d734
7c2446f
1116ac0
db59cec
f7e2bad
1fb0d08
61376c7
da9a05a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||||||||||||||||||
| # SPDX-License-Identifier: MIT | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| find_package(Python3 REQUIRED COMPONENTS Interpreter) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| function (diocotron_test_executable PREDCORR_METHOD TIME_METHOD ) | ||||||||||||||||||||||
| set(test_name "TestSimulationDiocotron_${PREDCORR_METHOD}_${TIME_METHOD}") | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| add_test(NAME "${test_name}" | ||||||||||||||||||||||
| COMMAND bash "${CMAKE_CURRENT_SOURCE_DIR}/test_diocotron.sh" | ||||||||||||||||||||||
| "${PROJECT_SOURCE_DIR}" | ||||||||||||||||||||||
| "$<TARGET_FILE:diocotron_${PREDCORR_METHOD}_${TIME_METHOD}>" | ||||||||||||||||||||||
| "$<TARGET_FILE:Python3::Interpreter>") | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # The test should take less than 15 min. | ||||||||||||||||||||||
| set_property(TEST "${test_name}" PROPERTY TIMEOUT 900000) | ||||||||||||||||||||||
|
PaulineVidal marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||
| set_property(TEST "${test_name}" PROPERTY COST 100) | ||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would require
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe they could just be activated with an environment variable?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont know what is the best solution. The release only is better because indeed we dont need to test in debug. |
||||||||||||||||||||||
| endfunction() | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Select the parameters of the simulation: | ||||||||||||||||||||||
| diocotron_test_executable(PREDCORR EULER_METHOD) | ||||||||||||||||||||||
| diocotron_test_executable(EXPLICIT_PREDCORR EULER_METHOD) | ||||||||||||||||||||||
| diocotron_test_executable(IMPLICIT_PREDCORR EULER_METHOD) | ||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #!/usr/bin/python3 | ||
|
|
||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| """ | ||
| File which tests whether the growth rate of the perturbation of a diocotron instabilities test case | ||
| follows the predicted slope. | ||
| """ | ||
|
|
||
| from argparse import ArgumentParser | ||
| from pathlib import Path | ||
| import numpy as np | ||
|
|
||
| from gysdata import DiskStore | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| parser = ArgumentParser(description="Check growth rate.") | ||
| parser.add_argument('data_dir', | ||
| action='store', | ||
| nargs='?', | ||
| default=Path.cwd(), | ||
| type=Path, | ||
| help='Location of the results (output folder).') | ||
| args = parser.parse_args() | ||
|
|
||
| path_data_structure = Path('data_structure_RTheta.yaml') | ||
| ds = DiskStore(args.data_dir, data_structure=path_data_structure) | ||
|
|
||
| # Get initial data | ||
| rho_eq = np.array(ds['density_eq']) | ||
| phi_eq = np.array(ds['electrical_potential_eq']) | ||
|
|
||
| jacobian = np.array(ds["jacobian"]) | ||
|
|
||
| T = float(ds["final_T"]) | ||
| omega_Im = float(ds["slope"]) | ||
|
|
||
| # Get the data at each time step | ||
| Time = np.array(ds["density"].coords["time"]) | ||
| rho = np.array(ds['density']) | ||
| phi = np.array(ds['electrical_potential']) | ||
|
|
||
| # Compute norms | ||
| L2norms_rho = np.linalg.norm((rho - rho_eq[None,:,:])*abs(jacobian[None,:,:]), 2, axis=(1,2)) | ||
| L2norms_phi = np.linalg.norm((phi - phi_eq[None,:,:])*abs(jacobian[None,:,:]), 2, axis=(1,2)) | ||
|
|
||
| slope_rho = np.polyfit(Time, L2norms_rho, 1)[0] | ||
| slope_phi = np.polyfit(Time, L2norms_phi, 1)[0] | ||
|
|
||
| assert abs(slope_rho - omega_Im) / abs(omega_Im) < 1 | ||
| assert abs(slope_phi - omega_Im) / abs(omega_Im) < 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #!/bin/bash | ||
| set -xe | ||
|
|
||
| if [ $# -ne 3 ]; then | ||
| echo "Usage: $0 <GYSELALIBXX_SRCDIR> <GYSELALIBXX_EXEC> <PYTHON3_EXE>" | ||
| exit 1 | ||
| fi | ||
| GYSELALIBXX_SRCDIR="$1" | ||
| GYSELALIBXX_EXEC="$2" | ||
| PYTHON3_EXE="$3" | ||
|
|
||
| OUTDIR="${PWD}" | ||
|
|
||
| TMPDIR="$(mktemp -p "${PWD}" -d run-XXXXXXXXXX)" | ||
| function finish { | ||
| rm -rf "${TMPDIR}" | ||
| } | ||
| trap finish EXIT QUIT ABRT KILL SEGV TERM STOP | ||
|
|
||
| cd "${TMPDIR}" | ||
|
|
||
| # Create a parameter file with the default values. | ||
| "${GYSELALIBXX_EXEC}" "--dump-config" "${PWD}/diocotron_params.yaml" | ||
|
|
||
| # Modify the default parameter files for a faster test. | ||
| MODIFY_PARAMETERS=$(cat <<EOF | ||
| import yaml | ||
|
|
||
| with open('diocotron_params.yaml') as f: | ||
| data = yaml.safe_load(f) | ||
|
|
||
| data['SplineMesh']['r_ncells'] = 32 | ||
| data['SplineMesh']['theta_ncells'] = 64 | ||
| data['Time']['final_T'] = 40. | ||
| data['Output']['time_step_diag'] = 40 | ||
|
|
||
| with open('diocotron_params.yaml', 'w') as f: | ||
| yaml.dump(data, f) | ||
| EOF | ||
| ) | ||
|
|
||
| "${PYTHON3_EXE}" -c "$MODIFY_PARAMETERS" | ||
|
|
||
| # Launch the test with the modified parameter file. | ||
| "${GYSELALIBXX_EXEC}" "${PWD}/diocotron_params.yaml" | ||
|
|
||
| export PYTHONPATH="${GYSELALIBXX_SRCDIR}/post-process/PythonScripts:${PYTHONPATH}" | ||
| "${PYTHON3_EXE}" -B "${GYSELALIBXX_SRCDIR}/tests/geometryRTheta/time_solver/growth_rate_test.py" "${TMPDIR}/output" |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the CI the timings are:
Serial Debug GNU
Serial Debug Clang
Serial Release GNU
Serial Release Clang
OpenMP Release GNU
Coverage Flags GNU
Unacceptably slow
GPU
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can choose the parameters based on the CI. Run with 1 step for the coverage just to show there is a test 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is also probably sufficient to run in Release only if we can work out a clean way to do it