-
Notifications
You must be signed in to change notification settings - Fork 26
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
Make plotting utilities for field line trajectories, |B| from MagneticField
objects, and B vector arrow plots in 3D
#1413
Comments
For now, But for now, you can achieve what you want by changing the source code slightly like this. Btw, I assume you want to be able to plot the magnitude of the magnetic field created by coils on the last closed flux surface. Here, DESC/desc/magnetic_fields/_core.py Line 347 in 2741269
change the line 347 by Bnorm = jnp.linalg.norm(B, axis=-1) This should change the plotted quantity to be the magnitude of the magnetic field created by coils. You may also want to change the title of the 3D figure here, Line 976 in 3c3dadc
Something like, label = r"$\mathbf{|B|} ~(\mathrm{T})$" This is a hacky way of doing it. So, I only recommend using it for plotting purposes, not during actual optimization! |
What do you mean by "3D magnetic field" specifically? our If you want to plot something in 3D from only a MagneticField object, you'd have to specify what surface in space you want to plot on (if you want something like Which of these is the desired functionality? |
Currently we can plot Bn using plot_3d : what if i want to plot this : Also ,it would be great if we could plot magnetic field vector (arrow plot) or magnetic field line trajectories. |
So, if you make the changes I provided and call the function as it is, fig = plot_3d(
eq.surface, "B*n", field=optimized_coilset, field_grid=coil_grid, grid=plot_grid
)
fig = plot_coils(optimized_coilset, fig=fig)
fig.show() It should work. I tested it. Maybe you didn't restart your kernel and the changes in the source files is not reflected...
If you call it like this, the
I believe this can be done. For vector plots, we can use |
It worked thanks for the suggestion @YigitElma. |
MagneticField
objects, and B vector arrow plots in 3D
Hi,
I am quite new at using DESC.In the Stage-Two Filamentary Coil Optimization tutorial , i want to compute the magnetic field due to coils using the following command [magnetic_field = coilset.compute_magnetic_field(coords, basis="rpz")] after that how can i 3d plot the magnetic field along with the coilset.
The text was updated successfully, but these errors were encountered: