Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ gui_dicts.py_prev
rootdir.py
VFILE.DAT
MFILE.DAT
PLOT.DAT
OUT.DAT
OPT.DAT
SIG_TF.json
tag.num
tests.x
Expand All @@ -57,12 +55,6 @@ KatyTest/*
*.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
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion documentation/proc-pages/io/input-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
254 changes: 128 additions & 126 deletions documentation/proc-pages/io/utilities.md

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion examples/a_scan_input_file_IN.DAT
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,8 @@ vftf = 0.3
* Conductor type switch (ITER Nb3Sn)
i_tf_sc_mat = 1

* Scan Variables

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.
sweep = 11., 11.2, 11.4, 11.6, 11.8, 12., 12.2, 12.4, 12.6, 12.8, 13.
194 changes: 0 additions & 194 deletions process/io/mfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion process/io/process_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion process/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion process/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion process/uncertainties/evaluate_uncertainties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions source/fortran/init_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ 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=opt_file ,file=trim(output_prefix)//'OPT.DAT' ,status='unknown')

! Input any desired new initial values
call input
Expand Down
49 changes: 0 additions & 49 deletions source/fortran/optimiz_module.f90

This file was deleted.

24 changes: 1 addition & 23 deletions source/fortran/scan.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Loading