-
Notifications
You must be signed in to change notification settings - Fork 49
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
Virtual casing #209
Virtual casing #209
Conversation
… the vmec.boundary quadrature points
…l_casing to containers.
Codecov Report
@@ Coverage Diff @@
## master #209 +/- ##
==========================================
+ Coverage 91.01% 91.23% +0.21%
==========================================
Files 60 62 +2
Lines 7900 8131 +231
==========================================
+ Hits 7190 7418 +228
- Misses 710 713 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
# Only the phi resolution needs to be specified. The theta resolution | ||
# is computed automatically to minimize anisotropy of the grid. | ||
vc = VirtualCasing.from_vmec(filename, nphi=180) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example would be confusing to the users because it appears that nothing is happening after instantiating the VirtualCasing class. My suggestion would to be print some of the important quantities and add comments stating how those quantities are used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit more is done now in this example.
directory, basefile = os.path.split(vmec.output_file) | ||
filename = os.path.join(directory, 'vcasing' + basefile[4:]) | ||
logger.debug(f'New filename: {filename}') | ||
vc.save(filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd not call VirtualCasing.save automatically and instead ask the users to explicitly make a call to save the data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to keep saving as the default. The reason is that 99% of the time, the use case is to run virtual casing once, save the result, and load in the result many times for stage-2 coil optimizations with different parameters. If a user ever wants to not save a file, they can set filename=None
when calling VirtualCasing.from_vmec()
.
src/simsopt/mhd/virtual_casing.py
Outdated
index += 1 | ||
""" | ||
|
||
Btotal_normal = np.sum(B3d * unit_normal, axis=2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btotal_normal
is not used anywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. That line has been removed.
src/simsopt/mhd/virtual_casing.py
Outdated
newvc.__setattr__(variable, newvar) | ||
return newvc | ||
|
||
def plot(self, show=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saving the fig is not enabled. Also, the approach used in the plot method is archaic. Instead, OO-approach should be used to make it more convenient for end-users.
Please refer to https://matplotlib.org/stable/tutorials/introductory/lifecycle.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion is to make plot return fig, axes objects so users can further customize the plots. Then they can decide whether to save or show them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been addressed.
Discussion in Princeton:
|
Here is a list of what I think should be implemented in simsopt concerning the virtual casing principle:
Use-cases for the later (approximating finite beta equilibrium):
|
I think the functionality is all here now. Remaining todo is to fix the docstrings in the virtual_casing class and in the w7x example |
Docs updated. @landreman @mbkumar I think this is ready for review. |
…s virtual casing the 1st time.
Thanks for all your work on this, @florianwechsung . I'm happy for it to be merged now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
This PR provides an interface to the
virtual_casing
package. This will be used to do coil optimization for finite-beta plasmas, replacing the BNORM code in stellopt. The new functions in simsopt adds lots of functionality tovirtual_casing
: providing an interface to Vmec, more tests, ability to save and load results, resample the results to the resolution desired for the stage-2 optimization, plot results, and suggest resolution parameters that minimize grid anisotropy on the surface. Thevirtual_casing
module has also been added to the simsopt containers.Typical usage: