-
Notifications
You must be signed in to change notification settings - Fork 41
Implement from_input_file for Equilibrium, update docs with this info
#1327
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
Changes from all commits
e61501f
b57eafc
f07a2c3
227d611
5eeed15
a01dbb3
06abfc0
9511bd0
30e562c
ae91b4f
25e475b
586af7d
c9f8657
b6d1a1f
19ed3a8
0d2163e
8de9ca7
429f2ec
02d8023
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||
|
|
||||
| import copy | ||||
| import numbers | ||||
| import warnings | ||||
| from collections.abc import MutableSequence | ||||
|
|
||||
| import numpy as np | ||||
|
|
@@ -26,6 +27,7 @@ | |||
| ZernikeRZToroidalSection, | ||||
| ) | ||||
| from desc.grid import Grid, LinearGrid, QuadratureGrid, _Grid | ||||
| from desc.input_reader import InputReader | ||||
| from desc.io import IOAble | ||||
| from desc.objectives import ( | ||||
| ForceBalance, | ||||
|
|
@@ -2035,6 +2037,55 @@ def from_near_axis( | |||
|
|
||||
| return eq | ||||
|
|
||||
| @classmethod | ||||
| def from_input_file(cls, path, **kwargs): | ||||
| """Create an Equilibrium from information in a DESC or VMEC input file. | ||||
|
|
||||
| Parameters | ||||
| ---------- | ||||
| path : Path-like or str | ||||
| Path to DESC or VMEC input file. | ||||
| **kwargs : dict, optional | ||||
| keyword arguments to pass to the constructor of the | ||||
| Equilibrium being created. | ||||
|
|
||||
| Returns | ||||
| ------- | ||||
| Equilibrium : Equilibrium | ||||
| Equilibrium generated from the given input file. | ||||
|
|
||||
| """ | ||||
| inputs = InputReader().parse_inputs(path)[-1] | ||||
| if (inputs["bdry_ratio"] is not None) and (inputs["bdry_ratio"] != 1): | ||||
| warnings.warn( | ||||
| "`bdry_ratio` is intended as an input for the continuation method." | ||||
| "`bdry_ratio`=1 uses the given surface modes as is, any other scalar " | ||||
| "value will scale the non-axisymmetric modes by that value. The " | ||||
| "final value of `bdry_ratio` in the input file is " | ||||
| f"{inputs['bdry_ratio']}, this means the created Equilibrium won't " | ||||
| "have the given surface but a scaled version instead." | ||||
| ) | ||||
| inputs["surface"][:, 1:3] = inputs["surface"][:, 1:3].astype(int) | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably handled somewhere in the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are not, I checked and inputs["surface"] has floats for the mode number parts of it. Probably we should handle in input reader, you're right
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
DESC/desc/equilibrium/utils.py Line 62 in f5abd60
|
||||
| # remove the keys (pertaining to continuation and solver tols) | ||||
| # that an Equilibrium does not need | ||||
| unused_keys = [ | ||||
| "pres_ratio", | ||||
| "bdry_ratio", | ||||
| "pert_order", | ||||
| "ftol", | ||||
| "xtol", | ||||
| "gtol", | ||||
| "maxiter", | ||||
| "objective", | ||||
| "optimizer", | ||||
| "bdry_mode", | ||||
| "output_path", | ||||
| "verbose", | ||||
| ] | ||||
| [inputs.pop(key) for key in unused_keys] | ||||
| inputs.update(kwargs) | ||||
| return cls(**inputs) | ||||
|
|
||||
| def solve( | ||||
| self, | ||||
| objective="force", | ||||
|
|
||||
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.