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
48 changes: 26 additions & 22 deletions documentation/proc-pages/development/standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

--------------------

## Line Length
##  Line Length

For optimal readability, a limit of 79 characters for maximum line length has been encouraged, as recommended in [PEP8](https://peps.python.org/pep-0008/). This is below the maximum line length of 132 characters for Fortran (to prevent compilation errors) and prevents long lines that run on past the edge of the screen wasting programmers time with scrolling.

Expand All @@ -13,7 +13,7 @@ For optimal readability, a limit of 79 characters for maximum line length has be
## Double declarations

PROCESS uses the Fortran 2008+ intrinsic precision module as shown in the example below. The
use statement will need to be at the module level. See the
use statement will need to be at the module level. See the
[fortran wiki](http://fortranwiki.org/fortran/show/Real+precision) for more information.

```fortran
Expand Down Expand Up @@ -102,7 +102,6 @@ $$

This means the variable represents the fraction of the TF coil area taken up by the winding pack.


--------------

#### System designations
Expand All @@ -118,10 +117,10 @@ Below are a few shorthand designations for different systems that should be used
- Shield: `_shld_`
- Central Solenoid: `_cs_`
- Heating & Current Drive: `_hcd_`
- Electron cyclotron current drive: `_eccd_`
- Ion cyclotron current drive: `_iccd_`
- Electron Bernstein Wave: `_ebw_`
- Neutral Beam: `_nb_`
- Electron cyclotron current drive: `_eccd_`
- Ion cyclotron current drive: `_iccd_`
- Electron Bernstein Wave: `_ebw_`
- Neutral Beam: `_nb_`
- Centre post: `_cp_` Should only be used for ST's

If the variables are physics variables and do not belong to a system then:
Expand Down Expand Up @@ -221,7 +220,6 @@ This should be used for units of $\text{kg} \cdot \text{m}^{-2}\text{s}^{-1}$

---------------------


##### Densities

- Densities should start with the `den_` prefix
Expand Down Expand Up @@ -348,6 +346,11 @@ The unit declaration `_fpy` can be used to specify that it is the full-power yea

---------------------

##### Stress

- Stresses should start with the `s_` prefix followed by the type of stress, for example `s_shear_`.

---------------------

##### Variables representing fractions

Expand All @@ -365,12 +368,13 @@ Variables used within constraint equations to scale iteration variables (f-value

---------------------

### Length
### Variable Length

Try to keep names to a sensible length while also keeping the name explicit and descriptive.

---------------------


### Physical Type

The physical type of the variable should form the first part of the variable name, e.g. for plasma resistance the variable should be named:
Expand Down Expand Up @@ -408,7 +412,7 @@ fusion_power_MW = 1000.0d0

With `f2py` you may encounter a Fortran error where the variable with units at the end in capital letters is not recognised. If so for the meantime put the units in their lowercase form. This problem will be solved in the future by full Pythonisation.

---------------------
---------------------

### Coordinates and dimensions

Expand Down Expand Up @@ -471,7 +475,7 @@ ii
| `a_plasma` | Plasma area | m2 |
| `rad_div_target` | Divertor target angle | radians |
| `deg_div_target` | Divertor target angle | deg |
| `sig_tf_r` | TF radial stress | Pa |
| `s_shear_tf` | TF shear stress | Pa |
| `` | | |

Please see issue [#940](https://github.com/ukaea/PROCESS/issues/940) to discuss new conventions.
Expand Down Expand Up @@ -557,15 +561,14 @@ class ExampleClass:

- Comments above apply to code below.


## Code Documentation Using FORD

PROCESS uses FORD (FORtran Documentation) to automatically generate documentation from comments
in the FORTRAN code. FORD parses FORTRAN source to understand the structure of the project as well
PROCESS uses FORD (FORtran Documentation) to automatically generate documentation from comments
in the FORTRAN code. FORD parses FORTRAN source to understand the structure of the project as well
as picking up "docmarked" comments in the source to create the documentation.

Regular Fortran comments are prefixed with a "!"; these are ignored by FORD and don't go into
the documentation. FORD comments are prefixed by a "!!", called a docmark; these are picked up
Regular Fortran comments are prefixed with a "!"; these are ignored by FORD and don't go into
the documentation. FORD comments are prefixed by a "!!", called a docmark; these are picked up
by FORD and go into the documentation.

The "!!" docmark goes after the statement it documents. For example, to document variables:
Expand All @@ -582,20 +585,21 @@ real(kind(1.0D0)) :: alpha_rate_density = 0.0D0
```

...and to document modules:

```fortran
module global_variables
!! Module containing miscellaneous global variables
!! This module contains miscellaneous global variables not
!! well-suited to any of the other 'variables' modules.
```

This documentation will appear in the
[FORD docs](http://process.gitpages.ccfe.ac.uk/process/ford_site/index.html) section in the
left-hand navigation bar. Within this site, the "Variables" section in the top navigation bar
provides variable descriptions in the same manner as the original "vardes" page.
This documentation will appear in the
[FORD docs](http://process.gitpages.ccfe.ac.uk/process/ford_site/index.html) section in the
left-hand navigation bar. Within this site, the "Variables" section in the top navigation bar
provides variable descriptions in the same manner as the original "vardes" page.

To document a statement before it occurs in the source, use "!>". However, it is encouraged to
use "!!" for consistency. The rationale behind this and further information is included on the
To document a statement before it occurs in the source, use "!>". However, it is encouraged to
use "!!" for consistency. The rationale behind this and further information is included on the
[FORD wiki](https://github.com/Fortran-FOSS-Programmers/ford/wiki/Writing-Documentation).

The FORD project on github can be found [here](https://github.com/Fortran-FOSS-Programmers/ford).
Expand Down
4 changes: 4 additions & 0 deletions process/io/obsolete_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@
"tfwmatmax": "temp_fw_max",
"fw_channel_length": "len_fw_channel",
"denw": None,
"s_tresca_oh": "s_shear_cs_peak",
"sig_tf_tresca_max": "s_shear_tf_peak",
"s_tresca_cond_cear": "s_shear_cea_tf_cond",
"sig_tf_tresca": "s_shear_tf",
"rjconpf": "j_pf_coil_wp_peak",
"oh_steel_frac": "f_a_cs_steel",
"vf": "f_a_pf_coil_void",
Expand Down
4 changes: 2 additions & 2 deletions process/io/plot_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2625,11 +2625,11 @@ def plot_magnetics_info(axis, mfile_data, scan):
"vs_plasma_ind_ramp"
].get_scan(scan)

sig_case = 1.0e-6 * mfile_data.data[f"sig_tf_tresca_max({i_tf_bucking})"].get_scan(
sig_case = 1.0e-6 * mfile_data.data[f"s_shear_tf_peak({i_tf_bucking})"].get_scan(
scan
)
sig_cond = 1.0e-6 * mfile_data.data[
f"sig_tf_tresca_max({i_tf_bucking + 1})"
f"s_shear_tf_peak({i_tf_bucking + 1})"
].get_scan(scan)

if i_tf_sup == 1:
Expand Down
8 changes: 4 additions & 4 deletions process/pfcoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,13 +1216,13 @@ def ohcalc(self):
areaspf = pfv.f_a_cs_steel * pfv.a_cs_poloidal

if pfv.i_cs_stress == 1:
pfv.s_tresca_oh = max(
pfv.s_shear_cs_peak = max(
abs(pf.sig_hoop - pf.sig_axial),
abs(pf.sig_axial - 0.0e0),
abs(0.0e0 - pf.sig_hoop),
)
else:
pfv.s_tresca_oh = max(
pfv.s_shear_cs_peak = max(
abs(pf.sig_hoop - 0.0e0),
abs(0.0e0 - 0.0e0),
abs(0.0e0 - pf.sig_hoop),
Expand Down Expand Up @@ -2245,8 +2245,8 @@ def outpf(self):
op.ovarre(
self.outfile,
"Maximum shear stress in CS steel for the Tresca criterion (Pa)",
"(s_tresca_oh)",
pfv.s_tresca_oh,
"(s_shear_cs_peak)",
pfv.s_shear_cs_peak,
"OP ",
)
op.ovarre(
Expand Down
Loading