From 1797e0c67d0c4fd3f145a434bd9c9d6aa8df9309 Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Thu, 21 Dec 2023 16:09:57 +0000 Subject: [PATCH 1/4] stop opt.dat being created and remove references to it in docs --- .gitignore | 7 - CMakeLists.txt | 1 - documentation/proc-pages/io/input-guide.md | 1 - documentation/proc-pages/io/utilities.md | 252 ++++++++++----------- source/fortran/init_module.f90 | 1 - source/fortran/optimiz_module.f90 | 49 ---- tests/integration/ref_dicts.json | 1 - 7 files changed, 126 insertions(+), 186 deletions(-) delete mode 100644 source/fortran/optimiz_module.f90 diff --git a/.gitignore b/.gitignore index d3529e3229..8dcb10e539 100644 --- a/.gitignore +++ b/.gitignore @@ -41,7 +41,6 @@ VFILE.DAT MFILE.DAT PLOT.DAT OUT.DAT -OPT.DAT SIG_TF.DAT SIG_TF.json tag.num @@ -70,12 +69,6 @@ lib/PLASMOD/*.DAT *.gz ford_site/ lib/ford -test_suite/test_files/*/new.OUT.DAT -test_suite/_divertor01.txt -test_suite/FZMIN_TEST.DAT -test_suite/REBCO_JC.DAT -test_suite/quench_data.DAT -test_suite/OPT.DAT *.egg-info fortran.py .coverage diff --git a/CMakeLists.txt b/CMakeLists.txt index b439786e81..22230dadf1 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,7 +95,6 @@ LIST(APPEND PROCESS_SRCS buildings_variables.f90 maths_library.f90 iteration_variables.f90 - optimiz_module.f90 evaluators.f90 water_usage_variables.f90 constraint_equations.f90 diff --git a/documentation/proc-pages/io/input-guide.md b/documentation/proc-pages/io/input-guide.md index 3b92a9d901..d45fefc557 100644 --- a/documentation/proc-pages/io/input-guide.md +++ b/documentation/proc-pages/io/input-guide.md @@ -22,7 +22,6 @@ Will produce output files named: - `my_file_name_OUT.DAT` - `my_file_name_MFILE.DAT` -- `my_file_name_OPT.DAT` If no input file name is given as the first argument to the code, it assumes an `IN.DAT` file is present in the current directory. diff --git a/documentation/proc-pages/io/utilities.md b/documentation/proc-pages/io/utilities.md index d0ee6cec2a..a00933c90f 100644 --- a/documentation/proc-pages/io/utilities.md +++ b/documentation/proc-pages/io/utilities.md @@ -29,13 +29,13 @@ Tool for comparing two MFILEs and outputting significant differences in numerica python process/io/mfile_comparison.py [-f path/to/first_MFILE.DAT path/to/second_MFILE.DAT] [-s] [--acc] [--verbose] ``` ### Options -| Argument | Description | -| ---- | --- | -| `-h, --help` | show help message and exit | -| `-f` | Files to compare | -| `-s` | Save output to file called comp.txt | -| `--acc` | Percentage difference threshold for reporting | -| `--verbose` | Additional output | +| Argument | Description | +| ------------ | --------------------------------------------- | +| `-h, --help` | show help message and exit | +| `-f` | Files to compare | +| `-s` | Save output to file called comp.txt | +| `--acc` | Percentage difference threshold for reporting | +| `--verbose` | Additional output | ### Output Outputs variables and their values which differ significantly between the two MFILEs. @@ -54,11 +54,11 @@ This script reads from a PROCESS MFILE and writes values into a CSV file. The va python process/io/mfile_to_csv.py [-h] [-f path/to/MFILE] [-v path/to/variable_list.json] ``` ### Options -| Argument | Description | -| - | - | -| `-h, --help` | show help message and exit | -| `-f, [filename]` | specify MFILE file path | -| `-v, VARFILE` | specify variable .json list file path | +| Argument | Description | +| ---------------- | ------------------------------------- | +| `-h, --help` | show help message and exit | +| `-f, [filename]` | specify MFILE file path | +| `-v, VARFILE` | specify variable .json list file path | ### Output A `.csv` file will be saved to the directory of the input file. @@ -80,11 +80,11 @@ python process/io/plot_proc.py [-h] [-f path/to/MFILE.DAT] [-s] If no `-f` argument is provided it assumes a file named `MFILE.DAT` is in the current directory. ### Options -| Argument | Description | -| - | - | -| `-h --help` | show help message and exit -| `-f path/to/MFILE.DAT` | specify input/output file prefix -| `-s, --show` | show plot +| Argument | Description | +| ---------------------- | -------------------------------- | +| `-h --help` | show help message and exit | +| `-f path/to/MFILE.DAT` | specify input/output file prefix | +| `-s, --show` | show plot | ### Output Produces a two-page PDF file in the same directory as the input MFILE. The PDF file name has the same prefix as the input MFILE but ending in `SUMMARY.pdf` @@ -111,65 +111,65 @@ used for startup and total available in $Wb$. Total burn time `tburn` in hrs. `Cost of electricity` - This is the cost of electricity in $/MWh$. Check the respective cost model for the reference year of the inflation used. -| Geometry | -| :-------- | -| major radius $R_0$ | -| minor radius $a$ | -| aspect ratio $A$ | -| elongation at the 95% flux surface $\kappa_{95}$ | +| Geometry | +| :--------------------------------------------------------- | +| major radius $R_0$ | +| minor radius $a$ | +| aspect ratio $A$ | +| elongation at the 95% flux surface $\kappa_{95}$ | | plasma triangularity at the 95% flux surface $\delta_{95}$ | -| plasma surface area | -| plasma volume | -| number of TF coils | -| inboard/outboard blanket thickness | -| inboard/outboard shield thickness | -| total fusion power | - -| Power flows | -| :---------- | -| average neutron wall load $W_{all}=\frac{P_{neutrons}}{S_{plasma,surface}f_{user}}$[^2] -| normalised radius of the 'core' region $\rho_{core}$ used in the radiation correction of the -confinement scaling[^3] [^4] | -| the electron density at the pedestal top $n_{e,ped}[m^{-3}]$ | -| the normalised radius $\rho=r/a$ at the pedestal top | -| the helium fraction relative to the electron density | -| the core radiation $P_{rad} (\rho<\rho_{core})$ subtracted from $P_{heat}$ in confinement scaling | -| $W_{th}$, the total radiation inside the separatrix | +| plasma surface area | +| plasma volume | +| number of TF coils | +| inboard/outboard blanket thickness | +| inboard/outboard shield thickness | +| total fusion power | + +| Power flows | +| :---------------------------------------------------------------------------------------------------------- | +| average neutron wall load $W_{all}=\frac{P_{neutrons}}{S_{plasma,surface}f_{user}}$[^2] | +| normalised radius of the 'core' region $\rho_{core}$ used in the radiation correction of the | +| confinement scaling[^3] [^4] | +| the electron density at the pedestal top $n_{e,ped}[m^{-3}]$ | +| the normalised radius $\rho=r/a$ at the pedestal top | +| the helium fraction relative to the electron density | +| the core radiation $P_{rad} (\rho<\rho_{core})$ subtracted from $P_{heat}$ in confinement scaling | +| $W_{th}$, the total radiation inside the separatrix | | nuclear heating power to blanket $P_{nuc,blkt}= P_{neutr} (1-e^{-\frac{\Delta x_{blkt}}{\lambda_{decay}}})$ | -| nuclear heating power to the shield $P_{nuc,shld}=P_{neutr}-P_{nuc,blkt}$ | -| power crossing the separatrix into the SoL/Divertor $P_{sep}$ | -| L-H threshold power $P_{LH}$ | -| divertor lifetime in years | -| high grade heat for electricity production $P_{therm}$ | -| gross cycle efficiency $P_{e,gross}/P_{therm}$ | -| net cycle efficiency $\frac{P_{e,gross}-P_{heat,pump}}{P_{therm}-P_{heat,pump}}$ | -| net electric power $P_{e,net}=P_{e,gross}-P_{recirc}$ | -| plant efficiency $P_{e,net}/P_{fus}$ | - -| Physics | -| :------ | -| plasma current $I_P[MA]$ | -| vaccuum magnetic field at in the plasma centre $B_T(R_0)$ | -| safety factor at the 95\% flux surface $q_{95}$ | -| definitions of $\beta$ as given in [^1] | -| volume averaged electron temperature $\langle T_e\rangle$ and density $\langle n_e\rangle$ | -| fraction of the line averaged electron density over the Greenwald density $\langle n_{e,line}\rangle / n_{GW}$ | +| nuclear heating power to the shield $P_{nuc,shld}=P_{neutr}-P_{nuc,blkt}$ | +| power crossing the separatrix into the SoL/Divertor $P_{sep}$ | +| L-H threshold power $P_{LH}$ | +| divertor lifetime in years | +| high grade heat for electricity production $P_{therm}$ | +| gross cycle efficiency $P_{e,gross}/P_{therm}$ | +| net cycle efficiency $\frac{P_{e,gross}-P_{heat,pump}}{P_{therm}-P_{heat,pump}}$ | +| net electric power $P_{e,net}=P_{e,gross}-P_{recirc}$ | +| plant efficiency $P_{e,net}/P_{fus}$ | + +| Physics | +| :-------------------------------------------------------------------------------------------------------------- | +| plasma current $I_P[MA]$ | +| vaccuum magnetic field at in the plasma centre $B_T(R_0)$ | +| safety factor at the 95\% flux surface $q_{95}$ | +| definitions of $\beta$ as given in [^1] | +| volume averaged electron temperature $\langle T_e\rangle$ and density $\langle n_e\rangle$ | +| fraction of the line averaged electron density over the Greenwald density $\langle n_{e,line}\rangle / n_{GW}$ | | peaking of the electron temperature $T_{e,0}/\langle T_e\rangle$ and density $n_{e,0}/\langle n_{e,vol}\rangle$ | -| core and SoL effective charge $Z_{eff}=\sum_i f_iZ_i^2$ | -| impurity fraction $f_Z=n_Z/\langle n_e\rangle$ | -| H-factor and confinement time are calculated using a radiation corrected confinement scaling[^3] [^4]. | +| core and SoL effective charge $Z_{eff}=\sum_i f_iZ_i^2$ | +| impurity fraction $f_Z=n_Z/\langle n_e\rangle$ | +| H-factor and confinement time are calculated using a radiation corrected confinement scaling[^3] [^4]. | -| Neutral Beam Current Drive | -| :------------------------- | +| Neutral Beam Current Drive | +| :------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | the steady state auxiliary power used for heating and current drive during the flat top phase (NOT to be confused with the start up or ramp down power requirements) | -| part of the auxiliary power that is used for heating only, but not current drive | -| current drive fractions for the inductive, auxiliary and bootstrap current | -| the neutral beam current drive efficiency $\gamma_{NB}$ | -| the neutral beam energy | -| the plasma heating used in the calculation of the confinement scaling/H-factor $P_{aux} + P_\alpha - P_{rad,core}$ | -| the divertor figure of merit $P_{sep}/R$, $P_{sep}/(\langle n_e\rangle R)$ | -| fraction of the power crossing the separatrix with respect to the LH-threshold power $P_{sep}/P_{LH}$ | -| non-radiation corrected H-factor (calculated for info only) | +| part of the auxiliary power that is used for heating only, but not current drive | +| current drive fractions for the inductive, auxiliary and bootstrap current | +| the neutral beam current drive efficiency $\gamma_{NB}$ | +| the neutral beam energy | +| the plasma heating used in the calculation of the confinement scaling/H-factor $P_{aux} + P_\alpha - P_{rad,core}$ | +| the divertor figure of merit $P_{sep}/R$, $P_{sep}/(\langle n_e\rangle R)$ | +| fraction of the power crossing the separatrix with respect to the LH-threshold power $P_{sep}/P_{LH}$ | +| non-radiation corrected H-factor (calculated for info only) | ## Sankey Diagram @@ -189,11 +189,11 @@ If no `-m` argument is provided it assumes a file named `MFILE.DAT` is in the cu ### Options -| Argument | Description | -| - | - | -| `-h --help` | show help message and exit | -| `-e --end` | file format, default = pdf | -| `-m --mfile` | mfile name, default = MFILE.DAT | +| Argument | Description | +| ------------ | ------------------------------- | +| `-h --help` | show help message and exit | +| `-e --end` | file format, default = pdf | +| `-m --mfile` | mfile name, default = MFILE.DAT | ### Output @@ -234,17 +234,17 @@ python utilities/plot_stress_tf.py [-h] [-f path/to/SIG_TF.json] [-p [PLOT_SELEC ### Option -| Argument | Description | -| - | - | -| `-h, --help` | show help message and exit | -| `-f, --input-file` | `SIG_TF.json` input file -| `-p, --plot_selec [PLOT_SELEC]` | Plot selection string : | -| - | - if the string contains `sig`, plot the stress distributions | -| - | - if the string contains `strain`, plot the strain distributions | -| - | - if the string contains `disp`, plot the radial displacement distribution | -| - | - if the string contains `all`, plot stress and displacement distributions | -| `-sf, --save_format [SAVE_FORMAT]` | output format (default='pdf') | -| `-as, --axis_font_size [AXIS_FONT_SIZE]` | Axis label font size selection (default=18) | +| Argument | Description | +| ---------------------------------------- | -------------------------------------------------------------------------- | +| `-h, --help` | show help message and exit | +| `-f, --input-file` | `SIG_TF.json` input file | +| `-p, --plot_selec [PLOT_SELEC]` | Plot selection string : | +| - | - if the string contains `sig`, plot the stress distributions | +| - | - if the string contains `strain`, plot the strain distributions | +| - | - if the string contains `disp`, plot the radial displacement distribution | +| - | - if the string contains `all`, plot stress and displacement distributions | +| `-sf, --save_format [SAVE_FORMAT]` | output format (default='pdf') | +| `-as, --axis_font_size [AXIS_FONT_SIZE]` | Axis label font size selection (default=18) | @@ -269,14 +269,14 @@ python utilities/write_new_in_dat.py [-h] [-f path/to/MFILE.DAT] [-i path/to/IN. ### Options -| Argument | Description | -| - | - | -| `-h, --help` | show help message and exit | -| `-f` | file to read as MFILE.DAT | -| `-i` | file to read as IN.DAT | -| `-o` | file to write as new IN.DAT | -| `-lfp` | use the last feasible point from a scan (default) | -| `-ffp` | use the first feasible point from a scan | +| Argument | Description | +| ------------ | ------------------------------------------------- | +| `-h, --help` | show help message and exit | +| `-f` | file to read as MFILE.DAT | +| `-i` | file to read as IN.DAT | +| `-o` | file to write as new IN.DAT | +| `-lfp` | use the last feasible point from a scan (default) | +| `-ffp` | use the first feasible point from a scan | @@ -299,16 +299,16 @@ python process/io/plot_scans.py [-h] [-f path/to/MFILE(s)] [-yv 'output vars'] [ ### Options -| Argument | Description | -| - | - | -| `-h, --help` | show help message and exit | -| `-f` | file(s) to read as MFILE.DAT | -| `-yv` | select the output variables | -| `-yv2` | select the 2nd axis output variable | -| `-o` | Output directory for plots, defaults to current working directory. | -| `-sf` | output format (default='pdf') | -| `-as` | Axis label font size selection (default=18) | -| `-ln` | Label names for plot legend. If multiple input files used then list the same number of label names eg: -nl 'leg1 leg2', (default = MFile file name) | +| Argument | Description | +| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- | +| `-h, --help` | show help message and exit | +| `-f` | file(s) to read as MFILE.DAT | +| `-yv` | select the output variables | +| `-yv2` | select the 2nd axis output variable | +| `-o` | Output directory for plots, defaults to current working directory. | +| `-sf` | output format (default='pdf') | +| `-as` | Axis label font size selection (default=18) | +| `-ln` | Label names for plot legend. If multiple input files used then list the same number of label names eg: -nl 'leg1 leg2', (default = MFile file name) | @@ -330,11 +330,11 @@ If no `-f` argument is provided it assumes a file named `MFILE.DAT` is in the cu ### Options -| Argument | Description | -| - | - | -| `-h, --help` | show help message and exit | -| `-f MFILE` | specify the MFILE | -| `-s, --save` | save figure | +| Argument | Description | +| ------------ | -------------------------- | +| `-h, --help` | show help message and exit | +| `-f MFILE` | specify the MFILE | +| `-s, --save` | save figure | ## Plot a bar chart of the cost breakdown @@ -354,12 +354,12 @@ python utilities/costs_bar.py [-h] [-f f [f ...]] [-s] [-inf INF] ### Options -| Argument | Description | -| - | - | -| `-h, --help` | show help message and exit | -| `-f MFILE` | specify the MFILE(s) to plot | -| `-s, --save` | save figure | -| `-inf INF` | Inflation Factor (multiplies costs) | +| Argument | Description | +| ------------ | ----------------------------------- | +| `-h, --help` | show help message and exit | +| `-f MFILE` | specify the MFILE(s) to plot | +| `-s, --save` | save figure | +| `-inf INF` | Inflation Factor (multiplies costs) | @@ -462,7 +462,7 @@ By convention, we have designated metadata about the PROCESS runs as having a pr - `uncertainties_data.h5`: This file contains the output variables of each successfully converged PROCESS run generated by the `evaluate_uncertainties.py` script. PROCESS output variables can be plotted using using the `hdf_to_scatter_plot.py` script. This file uses the [HDF format](https://www.hdfgroup.org/solutions/hdf5/) and requires [software](https://www.hdfgroup.org/downloads/hdfview/) to view its contents in a human legible format. -- `README.txt`, `process.log`, `MFILE.DAT`, `OUT.DAT`, `SIG_TF.DAT`, `SIG_TF.json`, `OPT.DAT`, `PLOT.DAT`: Typical PROCESS output generated by the last run. +- `README.txt`, `process.log`, `MFILE.DAT`, `OUT.DAT`, `SIG_TF.DAT`, `SIG_TF.json`, `PLOT.DAT`: Typical PROCESS output generated by the last run. ### Usage @@ -474,11 +474,11 @@ python process/uncertainties/evaluate_uncertainties.py -f path/to/config_evaluat ### Options -| Argument | Description | -| - | - | -| `-h, --help` | show help message and exit | -| `-f CONFIGFILE` | specify the path to the config file | -| `-m METHOD` | type of uncertainty analysis performed, default = monte_carlo, other options = sobol_method, morris_method | +| Argument | Description | +| --------------- | ---------------------------------------------------------------------------------------------------------- | +| `-h, --help` | show help message and exit | +| `-f CONFIGFILE` | specify the path to the config file | +| `-m METHOD` | type of uncertainty analysis performed, default = monte_carlo, other options = sobol_method, morris_method | The uncertainty analysis technique used can be specified using '`-m monte_carlo/sobol_method/morris_method`' but the default is Monte Carlo. Use `-h` or `--help` for help. @@ -500,10 +500,10 @@ If no `-f` argument is provided it assumes a file named `sobol.txt` is in the cu ### Options -| Argument | Description | -| - | - | -| `-h, --help` | show help message and exit | -| `-f DATAFILE` | path to datafile for plotting, default = sobol.txt | +| Argument | Description | +| --------------- | --------------------------------------------------------- | +| `-h, --help` | show help message and exit | +| `-f DATAFILE` | path to datafile for plotting, default = sobol.txt | | `-o OUTPUTFILE` | filename of outputed pdf file, default = sobol_output.pdf | ### Configuration File diff --git a/source/fortran/init_module.f90 b/source/fortran/init_module.f90 index bc5feb1e42..7b13c81f41 100644 --- a/source/fortran/init_module.f90 +++ b/source/fortran/init_module.f90 @@ -150,7 +150,6 @@ subroutine init open(unit=nout ,file=trim(output_prefix)//'OUT.DAT' ,status='unknown') open(unit=nplot ,file=trim(output_prefix)//'PLOT.DAT' ,status='unknown') open(unit=mfile ,file=trim(output_prefix)//'MFILE.DAT' ,status='unknown') - open(unit=opt_file ,file=trim(output_prefix)//'OPT.DAT' ,status='unknown') open(unit=sig_file ,file=trim(output_prefix)//'SIG_TF.DAT',status='unknown') ! Input any desired new initial values diff --git a/source/fortran/optimiz_module.f90 b/source/fortran/optimiz_module.f90 deleted file mode 100644 index 53b60373cb..0000000000 --- a/source/fortran/optimiz_module.f90 +++ /dev/null @@ -1,49 +0,0 @@ -module optimiz_module - implicit none - - contains - - subroutine write_out(n, m) - !! Write out optimiser information to the OPT.DAT file - ! #TODO Move to Python once file IO done in Python - use constants, only: opt_file - use numerics, only: icc, ixc - implicit none - - integer, intent(in) :: n - !! Number of variables - integer, intent(in) :: m - !! Number of constraints - - ! Array defined for optimizer data output only - integer, dimension(n) :: ixc_opt_out - integer, dimension(m) :: icc_opt_out - integer :: i - - ! Write the VMCON setup in OPT.DAT - do i = 1, m - icc_opt_out(i) = icc(i) - end do - do i = 1, n - ixc_opt_out(i) = ixc(i) - end do - - write(opt_file, *) ' number of constrains' - write(opt_file, '(I4)') m - write(opt_file, *) ' ' - write(opt_file, *) ' Constrains selection' - write(opt_file, '(I3,*(I4))') icc_opt_out - write(opt_file, *) ' ' - write(opt_file, *) ' number of variables' - write(opt_file, '(I4)') n - write(opt_file, *) ' ' - write(opt_file, *) ' Variables selection' - write(opt_file, '(I3,*(I4))') ixc_opt_out - write(opt_file, *) ' ' - write(opt_file, *) ' ' - write(opt_file, *) ' n VMCOM iter | Figure of merit | VMCON conv | constrains quad sum | residual, input values & - &and FoM input gradients' - write(opt_file, '(A,*(I18))') ' niter abs(objf) sum sqsumsq ', icc_opt_out, ixc_opt_out& - &, ixc_opt_out - end subroutine write_out -end module optimiz_module diff --git a/tests/integration/ref_dicts.json b/tests/integration/ref_dicts.json index f52d191297..22fd16bb49 100644 --- a/tests/integration/ref_dicts.json +++ b/tests/integration/ref_dicts.json @@ -19430,7 +19430,6 @@ "vlam" ], "ode_mod": [], - "optimiz_module": [], "param": [ "pi", "c" From 783709b0e1e4417a05669029b18f5e59cb2b9c03 Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Thu, 21 Dec 2023 16:24:45 +0000 Subject: [PATCH 2/4] remove references to plot.dat in documentation --- .gitignore | 1 - documentation/proc-pages/io/utilities.md | 2 +- process/io/process_config.py | 2 +- process/main.py | 1 - process/uncertainties/evaluate_uncertainties.py | 1 - tests/integration/test_solver.py | 1 - 6 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 8dcb10e539..0e794b0ab8 100644 --- a/.gitignore +++ b/.gitignore @@ -39,7 +39,6 @@ gui_dicts.py_prev rootdir.py VFILE.DAT MFILE.DAT -PLOT.DAT OUT.DAT SIG_TF.DAT SIG_TF.json diff --git a/documentation/proc-pages/io/utilities.md b/documentation/proc-pages/io/utilities.md index a00933c90f..369d5a86d5 100644 --- a/documentation/proc-pages/io/utilities.md +++ b/documentation/proc-pages/io/utilities.md @@ -462,7 +462,7 @@ By convention, we have designated metadata about the PROCESS runs as having a pr - `uncertainties_data.h5`: This file contains the output variables of each successfully converged PROCESS run generated by the `evaluate_uncertainties.py` script. PROCESS output variables can be plotted using using the `hdf_to_scatter_plot.py` script. This file uses the [HDF format](https://www.hdfgroup.org/solutions/hdf5/) and requires [software](https://www.hdfgroup.org/downloads/hdfview/) to view its contents in a human legible format. -- `README.txt`, `process.log`, `MFILE.DAT`, `OUT.DAT`, `SIG_TF.DAT`, `SIG_TF.json`, `PLOT.DAT`: Typical PROCESS output generated by the last run. +- `README.txt`, `process.log`, `MFILE.DAT`, `OUT.DAT`, `SIG_TF.DAT`, `SIG_TF.json`: Typical PROCESS output generated by the last run. ### Usage diff --git a/process/io/process_config.py b/process/io/process_config.py index 7e0b63c888..41458f8958 100755 --- a/process/io/process_config.py +++ b/process/io/process_config.py @@ -117,7 +117,7 @@ def prepare_wdir(self): os.chdir(self.wdir) subprocess.call( [ - "rm -f OUT.DAT MFILE.DAT PLOT.DAT README.txt\ + "rm -f OUT.DAT MFILE.DAT README.txt\ SolverTest.out process.log *.pdf uncertainties.nc time.info" ], shell=True, diff --git a/process/main.py b/process/main.py index c1b3c5f57a..daeb38f89c 100644 --- a/process/main.py +++ b/process/main.py @@ -236,7 +236,6 @@ class VaryRun: Output files: All of them in the work directory specified in the config file OUT.DAT - PROCESS output - PLOT.DAT - PROCESS output MFILE.DAT - PROCESS output process.log - logfile of PROCESS output to stdout README.txt - contains comments from config file diff --git a/process/uncertainties/evaluate_uncertainties.py b/process/uncertainties/evaluate_uncertainties.py index 2437274324..5328c9b2b7 100644 --- a/process/uncertainties/evaluate_uncertainties.py +++ b/process/uncertainties/evaluate_uncertainties.py @@ -13,7 +13,6 @@ Output files: OUT.DAT - PROCESS output -PLOT.DAT - PROCESS output MFILE.DAT - PROCESS output uncertainties_data.h5 - Dataframe of all PROCESS MFILE Outputs morris_method.txt - contains the dictorany of the mean and diff --git a/tests/integration/test_solver.py b/tests/integration/test_solver.py index b6fd9bf47d..7db4e6b9cb 100755 --- a/tests/integration/test_solver.py +++ b/tests/integration/test_solver.py @@ -42,7 +42,6 @@ def test_solver(temp_data): - Output files - Saved to temporary test dir OUT.DAT - PROCESS output of last run - PLOT.DAT - PROCESS output of last run MFILE.DAT - PROCESS output of last run process.log - logfile of PROCESS output to stdout time.info - stores the run time of the inner loop From 5347ca221cd8b84ee07a3ea9bc316a6e5d509d9f Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Thu, 11 Jan 2024 11:29:08 +0000 Subject: [PATCH 3/4] stop data being written to plot.dat and stop plot.dat being produced also remove comment referencing now-deleted plot_dat function also add points for 2d scan to example scan input file --- examples/a_scan_input_file_IN.DAT | 12 +- process/io/mfile.py | 194 ---------------------------- process/scan.py | 2 +- source/fortran/init_module.f90 | 1 - source/fortran/scan.f90 | 24 +--- tests/integration/test_utilities.py | 1 - 6 files changed, 12 insertions(+), 222 deletions(-) diff --git a/examples/a_scan_input_file_IN.DAT b/examples/a_scan_input_file_IN.DAT index 1953db1875..9dca17151d 100644 --- a/examples/a_scan_input_file_IN.DAT +++ b/examples/a_scan_input_file_IN.DAT @@ -239,7 +239,7 @@ boundl(29) = 0.1 bore = 2.0 * fvsbrnni -ixc = 44 +* ixc = 44 fvsbrnni = 0.4 * tdmptf [s] @@ -611,6 +611,14 @@ vftf = 0.3 * Conductor type switch (ITER Nb3Sn) i_tf_sc_mat = 1 +* Scan Variables + +*scan_dim = 2 + nsweep = 17 * bmxlim, maximum peak toroidal field isweep = 11 -sweep = 11., 11.2, 11.4, 11.6, 11.8, 12., 12.2, 12.4, 12.6, 12.8, 13. \ No newline at end of file +sweep = 11., 11.2, 11.4, 11.6, 11.8, 12., 12.2, 12.4, 12.6, 12.8, 13. + +*nsweep_2 = 57 * bt +*isweep_2 = 4 +*sweep_2 = 4., 4.2, 4.4, 4.6 \ No newline at end of file diff --git a/process/io/mfile.py b/process/io/mfile.py index 23534c8a73..eb1e67cad1 100755 --- a/process/io/mfile.py +++ b/process/io/mfile.py @@ -29,7 +29,6 @@ from collections import OrderedDict import logging from sys import stderr -from process.io.python_fortran_dicts import get_dicts import json LOG = logging.getLogger("mfile") @@ -461,199 +460,6 @@ def get_unit(variable_desc): return None -def make_plot_dat( - mfile_data, custom_keys, filename="make_plot_dat.out", file_format="row" -): - """Make a make_plot_dat.out file for this MFILE. - - The output format can be changed with the file_format argument. - - file_format = "row" looks like: - - parameter 1 val1 val2 val3 ... - parameter 2 val1 val2 val3 ... - ... - - file_format = "column" looks like: - - parameter1 parameter2 parameter3 ... - val1 val2 val3 ... - val2 val2 val3 ... - ... - - The default name for the output file is make_plot_dat.out; this can - be overwritten using the filename argument. custom_keys is a list of - variables to output to the make_plot_dat.out. - - Arguments: - mfile_data --> MFILE object - custom_keys --> list of parameters to output - filename --> output filename - file_format --> 'row' or 'column' make_plot_dat.out - - """ - # Load dicts from dicts JSON file - dicts = get_dicts() - - with open(filename, "w") as plot_dat: - - # The first two lines contain the scanning variable and the number of - # scans. These lines are preceded by a # symbol for ease of excluding. - try: - scan_var = int(mfile_data.data["nsweep"].get_scan(-1)) - plot_dat.write( - "# Scanning Variable: {}".format( - dicts["DICT_NSWEEP2VARNAME"][str(scan_var)] + "\n" - ) - ) - sweep_num = int(mfile_data.data["isweep"].get_scan(-1)) - plot_dat.write("# Number of scans: {}".format(str(sweep_num) + "\n")) - plot_dat.close() - except KeyError: - print("File has no scan, continuing...") - - # The order of searching is set so that the output variables are always - # in the same order. i.e. searching custom_keys first as it is a list. - keys = mfile_data.data.keys() - - # Row format - if file_format == "row": - write_row_mplot_dat(filename, custom_keys, mfile_data) - elif file_format == "column": - write_column_mplot_dat(filename, custom_keys, mfile_data) - else: - # If file_format not recognised print error - print( - "# Error >> Format {} not recognised. Use row or column".format( - file_format - ) - ) - - for ckey in custom_keys: - if ckey not in keys: - # For each item in the custom_keys list that isn't in the file - # print out an error. - print(" # Error >> Key: '{}' was NOT found in MFILE.DAT!".format(ckey)) - print(" \t\t (So is NOT in make_plot_dat.out!)") - - -def write_row_mplot_dat(filename, custom_keys, mfile_data): - """Function to make a PLOT.DAT using MFILE in row format""" - - mfile_keys = mfile_data.data.keys() - - lines = [] - for key in custom_keys: - if key in mfile_keys: - # Get the scan values for the row - values = "" - try: - for item in mfile_data.data[key].get_scans(): - values += "{:.4e}".format(item) + " " - except ValueError: - print("Skipped non-number parameter {0}".format(item)) - # values += "\n" - - # Create the file line [name, description, val1, val2, ...] - # Entries are justified to give the impression of fixed - # width columns - lines.append( - mfile_data.data[key].var_description.replace(" ", "_").ljust(45) - + " " - + key.replace(" ", "_").ljust(25) - + " " - + values - + "\n" - ) - - # Write row to file. - if lines != []: - with open(filename, "a") as plot_dat: - for line in lines: - plot_dat.write(line) - - -def write_column_mplot_dat(filename, custom_keys, mfile_data): - """Function to make a PLOT.DAT using MFILE in column format""" - - var_descriptions = "" - var_names = "" - try: - num_scans = int(mfile_data.data["isweep"].get_scan(-1)) - except KeyError: - num_scans = 1 - - val_keys = [] - mfile_keys = mfile_data.data.keys() - - for key in custom_keys: - if key in mfile_keys: - var_descriptions += ( - mfile_data.data[key].var_description.replace(" ", "_").ljust(45) + " " - ) - var_names += key.ljust(10) + " " - val_keys.append(key) - - # Write row to file - with open(filename, "a") as plot_dat: - plot_dat.write(var_names + "\n") - - # Write rows of values. One row for each scan. - for num in range(num_scans): - values = "" - for vkey in val_keys: - values += "{:.4e} ".format(mfile_data.data[vkey].get_scan(num + 1)) - values += "\n" - with open(filename, "a") as plot_dat: - plot_dat.write(values) - - -def read_mplot_conf(filename="make_plot_dat.conf"): - """Read make_plot_dat.conf file and return list of parameters. - - The make_plot_dat.conf file contains the parameters to be output by the - MFILE class to the make_plot_dat.out file. - - Arguments: - filename --> config file name - - Returns: - conf_params --> list of parameters in config file - - """ - # Open config file - with open(filename, "r", encoding="utf-8") as conf_file: - conf_lines = conf_file.readlines() - conf_params = [] - - # For each line check the it is not a comment (#) and if not add it to - # the list of parameters. - for item in conf_lines: - if "#" not in item: - if item.strip("\n") != "": - conf_params.append(item.strip("\n")) - - return conf_params - - -def write_mplot_conf(filename="make_plot_dat.conf"): - """write make_plot_dat.conf file. - - Creates a new/overwrites the existing make_plot_dat.conf file using the - default values listed in PARAMETER_DEFAULTS. - - Arguments: - filename --> config file name - - """ - # Load dicts from dicts JSON file - dicts = get_dicts() - with open(filename, "w") as conf_file: - conf_file.write("# make_plot_dat.out config file.\n") - for item in dicts.PARAMETER_DEFAULTS: - conf_file.write(item + "\n") - - def is_number(val): """Check MFILE data entry""" try: diff --git a/process/scan.py b/process/scan.py index 658cc47e05..832c01fad6 100644 --- a/process/scan.py +++ b/process/scan.py @@ -26,7 +26,7 @@ def run_scan(self): This method calls the optimisation routine VMCON a number of times, by performing a sweep over a range of values of a particular variable. A - number of output variable values are written to the PLOT.DAT file at + number of output variable values are written to the MFILE.DAT file at each scan point, for plotting or other post-processing purposes. """ # Turn off error reporting (until next output) diff --git a/source/fortran/init_module.f90 b/source/fortran/init_module.f90 index 7b13c81f41..9d7202ec0b 100644 --- a/source/fortran/init_module.f90 +++ b/source/fortran/init_module.f90 @@ -148,7 +148,6 @@ subroutine init ! open(unit=nin,file=trim(fileprefix)//'IN.DAT',status='old') open(unit=nout ,file=trim(output_prefix)//'OUT.DAT' ,status='unknown') - open(unit=nplot ,file=trim(output_prefix)//'PLOT.DAT' ,status='unknown') open(unit=mfile ,file=trim(output_prefix)//'MFILE.DAT' ,status='unknown') open(unit=sig_file ,file=trim(output_prefix)//'SIG_TF.DAT',status='unknown') diff --git a/source/fortran/scan.f90 b/source/fortran/scan.f90 index ce5c75800f..b4d4fb1476 100644 --- a/source/fortran/scan.f90 +++ b/source/fortran/scan.f90 @@ -212,7 +212,7 @@ subroutine scan_1d_store_output(iscan, ifail, noutvars_, ipnscns_, outvar) ! Turn off error reporting (until next output) errors_on = .false. - ! Store values for PLOT.DAT output + ! Store values for MFILE.DAT output outvar( 1,iscan) = dble(ifail) outvar( 2,iscan) = sqsumsq outvar( 3,iscan) = coe @@ -402,16 +402,6 @@ subroutine scan_1d_write_plot(iscan, outvar) first_call_1d = .false. end if - ! Finally, write data to PLOT.DAT - write(nplot,'(i8)') isweep - write(nplot,'(a48)') tlabel - write(nplot,'(a25, 1p, 200e11.4)') xlabel,(sweep(iscan),iscan=1,isweep) - - do ivar = 1,noutvars - !write(nplot,'(a25,20e11.4)') plabel(ivar), (outvar(ivar,iscan), iscan=1,isweep) - write(nplot,'(a25, 1p, 200e11.4)') plabel(ivar), (outvar(ivar,iscan), iscan=1,isweep) - end do - end subroutine scan_1d_write_plot subroutine scan_2d_init @@ -597,18 +587,6 @@ subroutine scan_2d_write_plot(iscan, outvar, sweep_1_vals, sweep_2_vals) tlabel = icase - ! Finally, write data to PLOT.DAT - write(nplot,'(i8)') isweep*isweep_2 - write(nplot,'(a48)') tlabel - write(nplot,'(a25, 1p, 200e11.4)') xlabel, (sweep_1_vals(iscan), iscan=1, & - isweep*isweep_2) - write(nplot,'(a25, 1p, 200e11.4)') xlabel_2, (sweep_2_vals(iscan), & - iscan=1, isweep*isweep_2) - - do ivar = 1, noutvars - write(nplot,'(a25, 1p, 200e11.4)') plabel(ivar), (outvar(ivar,iscan), & - iscan=1,isweep*isweep_2) - end do end subroutine scan_2d_write_plot subroutine scan_select(nwp, swp, iscn, vlab, xlab) diff --git a/tests/integration/test_utilities.py b/tests/integration/test_utilities.py index 967eb00334..0e128303cf 100644 --- a/tests/integration/test_utilities.py +++ b/tests/integration/test_utilities.py @@ -15,7 +15,6 @@ logger.info("Running utilities integration tests") # TODO More utilities tests to be implemented -# test_make_plot_dat # test_convert_in_dat From 0e0d92298f7ce0450adb4e3b9d2f89e2ba8dd6c4 Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Thu, 11 Jan 2024 15:50:40 +0000 Subject: [PATCH 4/4] tidy up example scan input file based on review comments --- examples/a_scan_input_file_IN.DAT | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/examples/a_scan_input_file_IN.DAT b/examples/a_scan_input_file_IN.DAT index 9dca17151d..5d38dad819 100644 --- a/examples/a_scan_input_file_IN.DAT +++ b/examples/a_scan_input_file_IN.DAT @@ -239,7 +239,7 @@ boundl(29) = 0.1 bore = 2.0 * fvsbrnni -* ixc = 44 +ixc = 44 fvsbrnni = 0.4 * tdmptf [s] @@ -613,12 +613,6 @@ i_tf_sc_mat = 1 * Scan Variables -*scan_dim = 2 - nsweep = 17 * bmxlim, maximum peak toroidal field isweep = 11 sweep = 11., 11.2, 11.4, 11.6, 11.8, 12., 12.2, 12.4, 12.6, 12.8, 13. - -*nsweep_2 = 57 * bt -*isweep_2 = 4 -*sweep_2 = 4., 4.2, 4.4, 4.6 \ No newline at end of file