Skip to content
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

Main input Class #352

Merged
merged 5 commits into from
Feb 18, 2022
Merged

Main input Class #352

merged 5 commits into from
Feb 18, 2022

Conversation

feathern
Copy link
Contributor

This commit adds a main_input class to rayleigh_diagnostics.py. I have found this useful when designing parameter space sweeps. A notebook describing how to use the class has been included in this commit.

Copy link
Member

@cianwilson cianwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @feathern !

Just one possible fix in the code and one comment.

One other quick thought... Since dictionaries aren't ordered is there a risk here of making main_input files hard to diff if the output order changes. Would it be worth considering using OrderedDicts instead? On the namelist level this could also be achieved by keeping the order of the namelists fixed from the time of input but this is currently overridden when a new option is force set.

" mi.vals['problemsize']['n_theta'] = ra_res_ntheta[i]\n",
" mi.vals['reference']['rayleigh_number'] = ra\n",
" mi.vals['reference']['ekman_number'] = ek\n",
"\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to call:

mi.write(file=input_file)

in this loop?

nml_line="&"+nml+"_namelist"+endl
lprint(nml_line)

for var in self.vals[nml].keys():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could save a marginal amount of effort here by iterating using:

for val, var in self.vals[nml].items():

Added missing write statement to end of main_input_demo notebook.
@feathern
Copy link
Contributor Author

Thanks Cian,
I changed the dicts to OrderedDicts and added that missing write statement (good catch). I tried changing the loop, but something a little further down crashed, and I'm in a bit of a hurry. So I'll leave that as it is for now.
-Nick

Copy link
Member

@cianwilson cianwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@cianwilson cianwilson merged commit 937a030 into geodynamics:master Feb 18, 2022
@feathern feathern deleted the main_input branch May 10, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants