Draft: Extending custom reference states to active and passive scalar fields.#586
Conversation
This is done by creating a new input file type, based on the reference state file but for scalar fields alone.
These can be set using `chi_a_custom_reference_file` and `chi_p_custom_reference_file` for active and passive scalar fields
respectively. Other new namelist parameters are:
```
override_chi_a_constant, override_chi_p_constant,
chi_a_constants, chi_p_constants,
with_custom_chi_a_constants, with_custom_chi_p_constants,
with_custom_chi_a_functions, with_custom_chi_p_functions
```
which do the equivalent of their reference state parameters but for active and passive scalar fields.
Currently it is possible to set reference states for:
```
constants = ['dchirefdr_scale', 'kappa_chi_scale', 'source_chi_scale', 'buoy_chi_scale']
functions = ['dchirefdr', 'kappa_chi', 'source_chi', 'd_ln_kappa_chi', 'buoy_chi']
```
The buoyancy constant and function will be ignored for passive scalar fields.
Hooked up the dchiref in the assembly of the scalar fields as well as the source terms.
Also fixed some typos and deprecation warnings.
This is untested and undocumented so far. More to come.
…mented (but untested).
The test currently compares running an augmented source T case with an augmented source chi case with and without advecting a reference state. I haven't been able to get the same answer generated with and without advecting the reference state yet. Implementing this test involved allowing rmin and rmax to be available always to generic input generation (rayleigh_spectral_input.py).
| # )+ end of grouping | ||
| # - from http://rick.measham.id.au/paste/explain.pl | ||
| r = re.compile(r'(?:[^,; '+os.linesep+'([{]|\([^)]*\)|\[[^]]*\]|\{[^}]*\})+') | ||
| r = re.compile(r'(?:[^,; '+os.linesep+'([{]|\\([^)]*\\)|\\[[^]]*\\]|\\{[^}]*\\})+') |
There was a problem hiding this comment.
This is just a fix for a warning I came across while developing everything else here.
| return m_max | ||
|
|
||
| def radial_extents(rmin=None, rmax=None, aspect_ratio=None, shell_depth=None): | ||
| def radial_extents(rmin=None, rmax=None, aspect_ratio=None, shell_depth=None, throw=True): |
There was a problem hiding this comment.
This modification allows this function to be called regardless of whether our function depends on radius or not and therefore makes rmax and rmin available more generally. It will still throw an error if it can't make the conversion and the conversion is needed (but it won't throw if the conversion is still not needed).
Though unrelated to the PR specifically it is a necessary change for the test.
| endif | ||
| Call stdout%print('Source requires both d_3 and g_3 to be set.') | ||
| if (active) Call stdout%print('Buoyancy requires both d_4 and g_5 to be set.') | ||
| Call stdout%print('Reference dchidr requires g_1 to be set (sets d_11 to 1 if unspecified).') |
There was a problem hiding this comment.
I think this should be d_1 not d_11.
There was a problem hiding this comment.
Should be fixed now, thanks!
| Read(15) dummy ! n_chi_functions | ||
| Read(15) n_scalars | ||
| if (n_scalars .gt. n_l_scalars) then | ||
| Call stdout%print('ERROR: number of scalars in the custom reference file') |
There was a problem hiding this comment.
I think since the code continues to try to read the file, it should be a "WARNING" (this is part of the larger warning/error issue of #423 so not unique to this part of the code). Also perhaps the print message should say what the code does in this case? It looks like it ignores n_l_scalars from main_input and just reads whatever is in the custom file...
There was a problem hiding this comment.
I've modified the ERROR -> WARNING and stated what will happen if you carry on.
I've also tried changing the logic underneath so that n_scalars and n_l_scalars are used appropriately. This is untested however as all the tests have nscalars == n_l_scalars.
| Read(15) ((fset(i, j), i = 1, n_chi_functions), j = 1, n_scalars) | ||
| Read(15) ((input_constants(i, j), i = 1, n_chi_constants), j = 1, n_scalars) | ||
|
|
||
| ! Cset(i) is 1 if a constant(i) was set; it is 0 otherwise. |
There was a problem hiding this comment.
make this set(i,j) in comments...
…ead from main_input). Also fixing a comment and an error/warning message.
Another shoutout to Loren for spotting this, thanks!
illorenzo7
left a comment
There was a problem hiding this comment.
I just checked all this over the last few days and it looks good to me! Merging.
illorenzo7
left a comment
There was a problem hiding this comment.
I just checked all this over the last few days and it looks good to me! Merging.
|
Thanks @illorenzo7 ! |
This pull request extends custom references states to active and passive scalar fields by adding a new custom reference state file type. One of these files can be set for active and passive scalar fields and each file contains the reference states for all active or passive scalar fields respectively.
These file names can be set using
chi_a_custom_reference_fileandchi_p_custom_reference_filefor active and passive scalar fields respectively. Other new namelist parameters are:which do the equivalent of their reference state parameters but for active and passive scalar fields.
Using these files it is currently possible to set reference states for:
Note that the buoyancy constant and function will be ignored for passive scalar fields.
Within Rayleigh this also required dchiref and the source terms to be activated (they were previously turned off).
Also fixed some typos and deprecation warnings.
A test has been added in
tests/chi_custom_referencethat provides example input files. The test runs a case using the existing implementation in temperature and checks that the new implementation for scalar fields produces the same answer.Documentation has been updated
doc/source/User_Guide/arbitrary_scalar_fields.txt.