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

Add JAX implementation of REGCOIL algorithm and Add Ability to Discretize Current Potentials into Coilsets #579

Open
wants to merge 494 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
494 commits
Select commit Hold shift + click to select a range
648bcc0
fix headers in tutorial
dpanici Jan 31, 2024
c1cb228
Merge branch 'dp/pyREGCOIL' of github.com:PlasmaControl/DESC into dp/…
dpanici Jan 31, 2024
eb32057
Merge branch 'master' into dp/pyREGCOIL
dpanici Feb 1, 2024
a253a86
ensure NFP is int for source grid, make warning test faster
dpanici Feb 1, 2024
71a7a24
remove some redundant tests
dpanici Feb 1, 2024
d1f8122
Merge branch 'master' into dp/pyREGCOIL
dpanici Feb 1, 2024
057f5db
Merge branch 'master' into dp/pyREGCOIL
dpanici Feb 1, 2024
e58715b
Merge branch 'master' into dp/pyREGCOIL
dpanici Feb 2, 2024
ba2a122
add test for modular coil cutting
dpanici Feb 3, 2024
333baa5
Merge branch 'master' into dp/pyREGCOIL
dpanici Feb 4, 2024
846495b
move plotting functions for regcoil to plotting.py
dpanici Feb 8, 2024
72e88ce
Merge branch 'master' into dp/pyREGCOIL
dpanici Feb 9, 2024
c5a287b
fix typo in plot function:
dpanici Feb 9, 2024
6388362
fix another typo in plotting function:
dpanici Feb 9, 2024
6e789de
add missing source grid to plot function
dpanici Feb 9, 2024
857b418
more plotting fixes, add recalc flag if grid is different than what t…
dpanici Feb 9, 2024
4164e15
update notebook figs and use latest functions
dpanici Feb 12, 2024
216314f
Merge branch 'master' into dp/pyREGCOIL
dpanici Feb 13, 2024
3ae17ba
Merge branch 'dp/io-hotfix' into dp/pyREGCOIL
dpanici Feb 13, 2024
979a6a7
add missing attributes to ellNFP4 test equilibrium
dpanici Feb 13, 2024
86f5665
fix incorrect kwargs and args in tests
dpanici Feb 13, 2024
d8efb23
fix plot test bug
dpanici Feb 13, 2024
926af54
reduce grid size
dpanici Feb 13, 2024
c5e1cd7
Merge branch 'master' into dp/pyREGCOIL
dpanici Feb 13, 2024
335c241
add markersize kwarg to plot
dpanici Feb 13, 2024
cfac90a
Merge branch 'dp/pyREGCOIL' of github.com:PlasmaControl/DESC into dp/…
dpanici Feb 13, 2024
2612b8e
adjust tols for test
dpanici Feb 14, 2024
274e823
Merge branch 'master' into dp/pyREGCOIL
dpanici Feb 15, 2024
87654f3
fix kwarg name change
dpanici Feb 15, 2024
bc066c5
fix tests, add external field grid argument to run regcoil, and have …
dpanici Feb 16, 2024
736991c
update recalculation criteria in plot fxn
dpanici Feb 16, 2024
cd3b35c
Merge branch 'master' into dp/pyREGCOIL
dpanici Feb 20, 2024
ce55d74
Merge branch 'master' into dp/pyREGCOIL
dpanici Feb 20, 2024
119d036
Merge branch 'master' into dp/pyREGCOIL
dpanici Feb 22, 2024
d838330
Merge branch 'master' into dp/pyREGCOIL
dpanici Feb 26, 2024
9bfb282
fix some bugs in coil cutting that pop up when the contours are not m…
dpanici Feb 26, 2024
b254db1
Merge branch 'dp/pyREGCOIL' of github.com:PlasmaControl/DESC into dp/…
dpanici Feb 26, 2024
83dc2ae
add test for warning
dpanici Feb 26, 2024
739773d
change plot function so that the field attributes are not overwritten
dpanici Feb 27, 2024
7136f8d
add K mag plot
dpanici Feb 28, 2024
60753d9
Merge branch 'master' into dp/pyREGCOIL
dpanici Feb 28, 2024
61c6dff
Merge branch 'master' into dp/pyREGCOIL
dpanici Mar 6, 2024
fef55b2
Merge branch 'master' into dp/pyREGCOIL
dpanici Mar 6, 2024
5277f61
Merge branch 'master' into dp/pyREGCOIL
dpanici Mar 6, 2024
7a03147
Merge branch 'master' into dp/pyREGCOIL
dpanici Mar 8, 2024
8dc06d9
fix type
dpanici Mar 8, 2024
e9c116d
Merge branch 'master' into dp/pyREGCOIL
dpanici Mar 9, 2024
a3e8ec7
fix error when external field is saved in regcoil data
dpanici Mar 11, 2024
49fdd6c
Merge branch 'master' into dp/pyREGCOIL
dpanici Mar 16, 2024
524b6d3
fix bug in compute
dpanici Mar 16, 2024
0c838f9
some changes for single stage
dpanici Mar 18, 2024
0e195da
Merge branch 'master' into dp/pyREGCOIL
dpanici Mar 19, 2024
28d227a
add quad weights to surface reg
dpanici Mar 20, 2024
4a98c7e
Merge branch 'master' into dp/pyREGCOIL
dpanici Mar 29, 2024
c82a758
fix comment
dpanici Mar 30, 2024
fd8a5d5
Merge branch 'master' into dp/pyREGCOIL
dpanici Apr 1, 2024
3acbff4
add virtual casing current to regcoil calc
dpanici Apr 1, 2024
151c0b6
remove fixme
dpanici Apr 1, 2024
0ec3bdb
Merge branch 'master' into dp/pyREGCOIL
dpanici Apr 8, 2024
148c2dd
add vacuum flag, update notebook, fix bug where in plotting, the exte…
dpanici Apr 8, 2024
676ff7e
add better default grid for regcoil solve, fix error that can happen …
dpanici Apr 11, 2024
f7d2517
move run_regcoil to a separate file and have it return family of surf…
dpanici Apr 11, 2024
5c9b2a0
Merge branch 'master' into dp/pyREGCOIL
dpanici Apr 11, 2024
f00c098
add ignore for deprecation warning with matplotlib collections, fix t…
dpanici Apr 12, 2024
7ad397e
fix path
dpanici Apr 12, 2024
f9b7019
fix tests
dpanici Apr 12, 2024
f977f72
fix more tests
dpanici Apr 12, 2024
a482be0
update plotting to accept lists, update notebook
dpanici Apr 12, 2024
c74e19f
fix plotting bug where it always included plasma current
dpanici Apr 13, 2024
ba2cb86
Merge branch 'master' into dp/pyREGCOIL
dpanici Apr 17, 2024
dac67c7
add surface current reg as a special case for test
dpanici Apr 17, 2024
93c5d87
change test to use precise QA, update tests
dpanici Apr 19, 2024
335299b
add new figs, disable runtime warning temporarily
dpanici Apr 19, 2024
7edafe4
add comment
dpanici Apr 19, 2024
c26ab10
add transforms to build method of QuadraticFlux if field is a Surface…
dpanici Apr 19, 2024
079ea30
Merge branch 'dp/quadratic-flux-transform' into dp/pyREGCOIL
dpanici Apr 19, 2024
eb584b4
fix test
dpanici Apr 26, 2024
98be741
remove the fitting step in test
dpanici Apr 26, 2024
7ec01f8
reduce number of coils for test
dpanici Apr 26, 2024
bbfe336
Merge branch 'master' into dp/pyREGCOIL
dpanici May 31, 2024
c97d6fd
remove minimum distance calc
dpanici May 31, 2024
3d9a932
remove unneeded comment in test
dpanici May 31, 2024
3d4296a
edit docstring, add comment to test
dpanici May 31, 2024
c135f40
remove ignore in setup.cfg
dpanici May 31, 2024
0707d58
remove unneeded test and eq
dpanici May 31, 2024
610da80
remove unneeded test
dpanici May 31, 2024
4a538c2
remove unneeded test
dpanici May 31, 2024
46c2a17
update fixparamters name in notebook
dpanici May 31, 2024
6ea87fe
change compute to _compute in _coils.py
dpanici Jun 17, 2024
71c83fc
Merge branch 'master' into dp/pyREGCOIL
dpanici Jun 17, 2024
8c06a11
Merge branch 'master' into dp/pyREGCOIL
dpanici Jun 17, 2024
4ab1c0d
have plot tests close unneeded figures
dpanici Jun 18, 2024
18c3cc4
Merge branch 'dp/quadratic-flux-transform' into dp/pyREGCOIL
dpanici Jun 18, 2024
2872778
Merge branch 'master' into dp/pyREGCOIL
dpanici Jun 21, 2024
80c5a91
Merge branch 'dp/quadratic-flux-transform' into dp/pyREGCOIL
dpanici Jun 21, 2024
48316fe
Merge branch 'dp/quadratic-flux-transform' into dp/pyREGCOIL
dpanici Jun 21, 2024
a47457f
Merge branch 'master' into dp/pyREGCOIL
dpanici Jun 21, 2024
edf7fe2
Merge branch 'dp/quadratic-flux-transform' into dp/pyREGCOIL
dpanici Jun 27, 2024
7cbe46e
Merge branch 'master' into dp/pyREGCOIL
dpanici Jul 2, 2024
72451c2
Merge branch 'dp/quadratic-flux-transform' into dp/pyREGCOIL
dpanici Jul 2, 2024
87cf4ce
remove unneeded plot test
dpanici Jul 2, 2024
7c90148
remove unneeded tets
dpanici Jul 2, 2024
c4d21c5
Merge branch 'master' into dp/pyREGCOIL
dpanici Jul 6, 2024
57c071e
address some comments
dpanici Jul 6, 2024
5411559
remove unneeded asarray
dpanici Jul 6, 2024
7d5fd86
allow To_CoilSet to take advantage of FP symmetry for modular coils
dpanici Jul 6, 2024
6e273cb
fix some comments
dpanici Jul 6, 2024
8ad2103
increase test cov
dpanici Jul 6, 2024
8a52460
fix tutorial
dpanici Jul 7, 2024
349dc05
allow MixedCoilSet.from_symmetry to work when the given coils are not…
dpanici Jul 7, 2024
ce49884
move contour finding for To_CoilSet to a util function
dpanici Jul 7, 2024
3559474
replace contour finding from matplotlib with skimage
dpanici Jul 8, 2024
aed4c80
update changelog
dpanici Jul 8, 2024
4ab27ff
fix test warning
dpanici Jul 8, 2024
8adb311
Merge branch 'master' into dp/pyREGCOIL
dpanici Jul 8, 2024
4580947
Merge branch 'master' into dp/pyREGCOIL
rahulgaur104 Jul 9, 2024
7584538
address some comments
dpanici Jul 10, 2024
0fc8c87
fix docstring and remove to_fourier
dpanici Jul 15, 2024
955bb5d
address comments in _coils.py
dpanici Jul 15, 2024
7e0620f
address some comments
dpanici Jul 15, 2024
165c9fb
add missing line in docstring
dpanici Jul 15, 2024
09aa8db
Merge branch 'master' into dp/pyREGCOIL
dpanici Jul 15, 2024
8170038
Merge branch 'master' into dp/pyREGCOIL
dpanici Jul 16, 2024
afee0bb
fix doc issue
dpanici Jul 16, 2024
9831549
fix test
dpanici Jul 16, 2024
e9e8f6f
dont ask for xyz basis in surf current obj
dpanici Jul 16, 2024
9e34982
Merge branch 'master' into dp/pyREGCOIL
dpanici Jul 22, 2024
5d1c947
fix test
dpanici Jul 22, 2024
66cc809
Merge branch 'master' into dp/pyREGCOIL
dpanici Jul 22, 2024
3a2caea
fix notebook
dpanici Jul 22, 2024
7f28ad5
Merge branch 'dp/pyREGCOIL' of github.com:PlasmaControl/DESC into dp/…
dpanici Jul 22, 2024
19906e1
fix other issues in notebook
dpanici Jul 22, 2024
30300ae
Merge branch 'master' into dp/pyREGCOIL
dpanici Jul 24, 2024
b5b9ef3
Merge branch 'master' into dp/pyREGCOIL
dpanici Jul 26, 2024
325830f
add surf current reg to API
dpanici Jul 26, 2024
482eecc
Merge branch 'master' into dp/pyREGCOIL
dpanici Aug 5, 2024
7fab1fc
remove modular coil cut test from regcoiil, add simpler test, remove …
dpanici Aug 6, 2024
b23e997
Merge branch 'dp/pyREGCOIL' of github.com:PlasmaControl/DESC into dp/…
dpanici Aug 6, 2024
09d7f6c
remove more unneeded regcoil tests, add a coil cutting test for helic…
dpanici Aug 6, 2024
febcec3
fix docstring reference
dpanici Aug 6, 2024
4f02f07
update figures, reduce number of scan in test for regcoil
dpanici Aug 6, 2024
921547a
Merge branch 'master' into dp/pyREGCOIL
dpanici Aug 8, 2024
a258dce
fix stell_sym in contour finding
dpanici Aug 8, 2024
510f609
Merge branch 'dp/pyREGCOIL' of github.com:PlasmaControl/DESC into dp/…
dpanici Aug 8, 2024
ce36f11
remove intersection check, remove TODO
dpanici Aug 8, 2024
499ca9b
remove fixme
dpanici Aug 8, 2024
a548032
make regcoil function more efficient with SVD
dpanici Aug 8, 2024
6412936
make to_CoilSet always return a CoilSet
dpanici Aug 8, 2024
1543b59
add missing grid
dpanici Aug 8, 2024
afed2f1
fix notebook
dpanici Aug 8, 2024
3938484
Merge branch 'master' into dp/pyREGCOIL
dpanici Aug 8, 2024
b6a0525
fix some notebook typos
dpanici Aug 8, 2024
0f0a1ea
Merge branch 'dp/pyREGCOIL' of github.com:PlasmaControl/DESC into dp/…
dpanici Aug 8, 2024
cc913ba
add area element weighting to regcoil calculation, update notebook
dpanici Aug 9, 2024
5b9a855
fix error
dpanici Aug 9, 2024
4445e9f
change current_helicity to a tuple to reflect paper
dpanici Aug 9, 2024
342aea6
update plots
dpanici Aug 9, 2024
7d2c173
rename alpha to lambda_regularization
dpanici Aug 9, 2024
2ba168c
Merge branch 'master' into dp/pyREGCOIL
dpanici Aug 9, 2024
725815a
update plot test
dpanici Aug 10, 2024
ff65cbe
Merge branch 'dp/pyREGCOIL' of github.com:PlasmaControl/DESC into dp/…
dpanici Aug 10, 2024
c165bf3
update arg name in notebook
dpanici Aug 10, 2024
0d96661
Merge branch 'master' into dp/pyREGCOIL
dpanici Aug 11, 2024
e6bab25
Merge branch 'master' into dp/pyREGCOIL
dpanici Aug 12, 2024
89ee374
add surface element to surfaec current obj
dpanici Aug 14, 2024
65ba0e8
fix typos in REGCOIL tutorial
daniel-dudt Aug 19, 2024
c173357
Merge branch 'master' into dp/pyREGCOIL
dpanici Aug 20, 2024
45b7ca7
fix doc build error
dpanici Aug 20, 2024
9bb9b2b
Merge branch 'dp/pyREGCOIL' of github.com:PlasmaControl/DESC into dp/…
dpanici Aug 20, 2024
78e3eca
Merge branch 'master' into dp/pyREGCOIL
ddudt Aug 20, 2024
75b0de4
Merge branch 'master' into dp/pyREGCOIL
ddudt Aug 23, 2024
d515e2a
Merge branch 'master' into dp/pyREGCOIL
ddudt Aug 25, 2024
63f0ed7
Merge branch 'master' into dp/pyREGCOIL
ddudt Aug 25, 2024
56f848f
fix import
dpanici Sep 5, 2024
e75ce64
Merge branch 'master' into dp/pyREGCOIL
dpanici Sep 5, 2024
688ec6c
add more correct regularization option
dpanici Sep 23, 2024
ecf36bc
use lstsq, fix doc error
dpanici Sep 24, 2024
06215c5
Merge branch 'master' into dp/pyREGCOIL
dpanici Sep 24, 2024
1a49dec
fix import
dpanici Sep 25, 2024
4797dea
fix missing fixture
dpanici Sep 25, 2024
0b1c77c
Merge branch 'master' into dp/pyREGCOIL
dpanici Sep 25, 2024
9b7cdf4
fix docstring
dpanici Sep 25, 2024
c29fe2a
fix helical coil toroidal current calc in regcoil:
dpanici Sep 26, 2024
a25465f
note about p nonzero and q zero
dpanici Sep 26, 2024
9f33691
fix print format string
dpanici Sep 26, 2024
5761bdb
update notebook
dpanici Sep 26, 2024
8a15000
Merge branch 'master' into dp/pyREGCOIL
dpanici Sep 27, 2024
d0a3c15
Merge branch 'master' into dp/pyREGCOIL
dpanici Oct 2, 2024
b647b00
fix docstring error
dpanici Oct 2, 2024
4e7cc7e
add normalization for surfacecurrentregularization
dpanici Oct 2, 2024
2812ae7
fix abs in normalization
dpanici Oct 2, 2024
f0ad61b
fix docstring again hopefully
dpanici Oct 2, 2024
7cd0c5b
add missing if statement
dpanici Oct 2, 2024
65ce96a
change offset surface to use base sym
dpanici Oct 2, 2024
f90582a
remove TODO and make num_coils positional
dpanici Oct 2, 2024
77e237b
add note on jit/AD compatibility
dpanici Oct 2, 2024
c211a5f
make find xyz standalone and private
dpanici Oct 2, 2024
2dc266c
Merge branch 'master' into dp/pyREGCOIL
dpanici Oct 2, 2024
dfe1d1c
make find xyz standalone and private
dpanici Oct 2, 2024
a91fe2a
address some comments
dpanici Oct 3, 2024
069ecad
address further comments
dpanici Oct 3, 2024
2e8e35f
change np trapz to jnp trapezoid, fix axisym test
dpanici Oct 3, 2024
2beb620
remove trapezoid call
dpanici Oct 3, 2024
40f6555
move G_ext calc to util fxn
dpanici Oct 3, 2024
3ca79f3
change lstsq to solve with cholesky, update plot, fix bug in plot whe…
dpanici Oct 3, 2024
c4ba607
address some smaller comments
dpanici Oct 3, 2024
e8ce8d7
more small changes
dpanici Oct 3, 2024
a60c276
Merge branch 'master' into dp/pyREGCOIL
dpanici Oct 3, 2024
169f03a
add rtol to tests
dpanici Oct 4, 2024
32f9bd7
change test
dpanici Oct 4, 2024
d523a06
further address comments
dpanici Oct 4, 2024
5474e54
make function logic clearer
dpanici Oct 4, 2024
373d0c1
have run regcoil always return a list
dpanici Oct 4, 2024
950582a
fix plotting
dpanici Oct 4, 2024
8ec81d4
add cmap option
dpanici Oct 4, 2024
38ae106
update plotting
dpanici Oct 4, 2024
6ee875e
plot changes
dpanici Oct 4, 2024
32a7d90
up test tol
dpanici Oct 4, 2024
2f57857
Merge branch 'master' into dp/pyREGCOIL
dpanici Oct 4, 2024
6100497
Merge branch 'master' into dp/pyREGCOIL
dpanici Oct 14, 2024
4f976e8
increase conftest resolution
dpanici Oct 14, 2024
bea645d
add logic for no net pol current
dpanici Oct 14, 2024
037e49d
change linspace to arange
dpanici Oct 14, 2024
c5620d3
update plots
dpanici Oct 14, 2024
1d4d20a
fix some titles and some warnings when calling To_CoilSet
dpanici Oct 14, 2024
68373fe
have run_regcoil not modify original field
dpanici Oct 14, 2024
b2e90bc
remove redundant calculations
dpanici Oct 14, 2024
e513df2
change regcoil regularization to use hessian call
dpanici Oct 14, 2024
967a580
add logic for fwd/rev mode
dpanici Oct 14, 2024
c2b3436
change which test regcoil example uses simple as regularization, upda…
dpanici Oct 15, 2024
2ff2065
change notebook wording slightly
dpanici Oct 15, 2024
80f6f33
Merge branch 'master' into dp/pyREGCOIL
dpanici Oct 15, 2024
4d8c56a
address some comments
dpanici Oct 15, 2024
c07c893
simplify Bn fxn calls
dpanici Oct 15, 2024
5fd7a05
simplify K fxns in regcoil fxn
dpanici Oct 15, 2024
66b560a
add figsize to To_CoilSet
dpanici Oct 15, 2024
193182e
change contour kwarg to filled
dpanici Oct 15, 2024
fa1caa0
fix docstring error, change K weighting
dpanici Oct 16, 2024
b202a5e
Merge branch 'master' into dp/pyREGCOIL
dpanici Oct 16, 2024
6e738ea
change weighting of quad flux so that it matches regcoil problem when…
dpanici Oct 16, 2024
baf9dfc
add flag to change weighiting for quadratic flux
dpanici Oct 16, 2024
8a70f31
change name of fxn, and remove plotting utility and place in tutorial…
dpanici Oct 16, 2024
192fb8a
add simple test for Surface Current Regularization obj
dpanici Oct 16, 2024
7a64752
remove import
dpanici Oct 16, 2024
f2873e2
add tests for rest of surf current topology types
dpanici Oct 16, 2024
91c33cd
fix test
dpanici Oct 16, 2024
e6d85be
change fxn name, add test for warnings etc
dpanici Oct 16, 2024
8118fe7
Merge branch 'master' into dp/pyREGCOIL
dpanici Oct 16, 2024
6f571e1
rerun tutorial
dpanici Oct 17, 2024
59cb549
Merge branch 'master' into dp/pyREGCOIL
dpanici Oct 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions desc/field_line_tracing_DESC_from_coilset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# git checkout dp/coils for this script to work
dpanici marked this conversation as resolved.
Show resolved Hide resolved

from desc import set_device

set_device("gpu")
dpanici marked this conversation as resolved.
Show resolved Hide resolved
import os

# %matplotlib inline
import sys
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [flake8] <402> reported by reviewdog 🐶
module level import not at top of file

import time

import jax.numpy as np
import matplotlib.pyplot as plt
dpanici marked this conversation as resolved.
Show resolved Hide resolved
import numpy as nnp
from jax import grad, jit, vmap
Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'jax.grad' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'jax.jit' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'jax.vmap' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [flake8] <402> reported by reviewdog 🐶
module level import not at top of file

from scipy.interpolate import interp1d
Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'scipy.interpolate.interp1d' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [flake8] <402> reported by reviewdog 🐶
module level import not at top of file


from desc.coils import Coil, CoilSet, FourierPlanarCoil, XYZCoil
Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'desc.coils.Coil' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'desc.coils.FourierPlanarCoil' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'desc.coils.XYZCoil' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [flake8] <402> reported by reviewdog 🐶
module level import not at top of file

from desc.equilibrium import EquilibriaFamily, Equilibrium
Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'desc.equilibrium.EquilibriaFamily' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'desc.equilibrium.Equilibrium' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [flake8] <402> reported by reviewdog 🐶
module level import not at top of file

from desc.grid import LinearGrid
from desc.io import load
dpanici marked this conversation as resolved.
Show resolved Hide resolved
from desc.magnetic_fields import (
Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'desc.magnetic_fields.SumMagneticField' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'desc.magnetic_fields.ToroidalMagneticField' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [flake8] <402> reported by reviewdog 🐶
module level import not at top of file

SumMagneticField,
ToroidalMagneticField,
field_line_integrate,
)
from desc.plotting import plot_1d, plot_2d, plot_comparison, plot_surfaces
Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'desc.plotting.plot_1d' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'desc.plotting.plot_2d' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'desc.plotting.plot_comparison' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'desc.plotting.plot_surfaces' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [flake8] <402> reported by reviewdog 🐶
module level import not at top of file

from utils import get_coilset_from_MAKEGRID_or_regcoil
Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <401> reported by reviewdog 🐶
'utils.get_coilset_from_MAKEGRID_or_regcoil' imported but unused

Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [flake8] <402> reported by reviewdog 🐶
module level import not at top of file


################## Inputs ################
# coil .txt file in MAKEGRID format
# vacuum equilibrium to compare against
################# outputs #################
# poincare plot at phi=0 of the surfaces
# plot of Bnormal on the LCFS from the coils


# Field line tracing



dpanici marked this conversation as resolved.
Show resolved Hide resolved
# first arg : coil file
dpanici marked this conversation as resolved.
Show resolved Hide resolved

fname = str(sys.argv[1])
eqname = str(sys.argv[2])
if len(sys.argv) > 3:
ntransit = int(
sys.argv[3]
) # how many times to trace the field line going across phi=0 plane
else:
ntransit = 100
R0 = 703.5 / 1000
Z0 = 0
r = 36.5 / 1000


coils = CoilSet.from_makegrid_coilfile(fname)

t0 = time.time()
phis = np.arange(0, ntransit * 2 * np.pi, 2 * np.pi)
npts = 15
# was 0.9, just changed it temporarily
rrr = np.linspace(
R0 - 0.7 * r, R0 + 0.7 * r, npts
) # initial R positions of field-lines to trace
# set initial Z positions to zero
print("Beginning Field Line Integration")
# integrate field lines
field_R, field_Z = field_line_integrate(rrr, np.zeros_like(rrr), phis, coils)

t_elapse = time.time() - t0


R_list = []
# save data
dirname = f"{fname.strip('.txt')}"
import os
Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <811> reported by reviewdog 🐶
redefinition of unused 'os' from line 6

Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [flake8] <402> reported by reviewdog 🐶
module level import not at top of file


if not os.path.isdir(dirname):
dpanici marked this conversation as resolved.
Show resolved Hide resolved
os.mkdir(dirname)
for i in range(field_R.shape[1]):
nnp.savetxt(
f"{dirname}/trace_{ntransit}_transits_R_{i}.txt", nnp.asarray(field_R[:, i])
)
nnp.savetxt(
f"{dirname}/trace_{ntransit}_transits_Z_{i}.txt", nnp.asarray(field_Z[:, i])
)


# read data again and plot

fig, ax = plt.subplots(figsize=(8, 8))

for i in range(npts):
field_R = nnp.genfromtxt(f"{dirname}/trace_{ntransit}_transits_R_{i}.txt")
field_Z = nnp.genfromtxt(f"{dirname}/trace_{ntransit}_transits_Z_{i}.txt")

if nnp.max(nnp.abs(field_R)) < 4:
plt.scatter(field_R, field_Z, s=1)
else:
plt.scatter(field_R, field_Z, s=1)


plt.ylabel("Z")
plt.xlabel("R")
R0_ves = 0.7035
a_ves = 0.0365
theta = np.linspace(0, 2 * np.pi, 100)
R_ves = R0_ves + a_ves * np.cos(theta)
Z_ves = a_ves * np.sin(theta)
plt.plot(R_ves, Z_ves, "k", label="Vacuum vessel")
a_lim = 0.0365 - 8 / 1000
theta = np.linspace(0, 2 * np.pi, 100)
R_lim = R0_ves + a_lim * np.cos(theta)
Z_lim = a_lim * np.sin(theta)
plt.plot(R_lim, Z_lim, "r--", label="8mm from vessel")
plt.legend()
plt.ylabel("Z")
plt.xlabel("R")
plt.xlim([0.66, 0.74])
plt.ylim([-0.04, 0.04])


plt.savefig(f"{dirname}/trace{ntransit}_transits.png")


print(
f"{dirname} field line tracing done, took {t_elapse} seconds which is {t_elapse/60} mins or {t_elapse/3600} hours"
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [flake8] <501> reported by reviewdog 🐶
line too long (119 > 88 characters)

)
Loading
Loading