Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
318 commits
Select commit Hold shift + click to select a range
2c51f8c
comment
joaopedrobiu6 Sep 29, 2023
8e6c56c
comments
joaopedrobiu6 Sep 29, 2023
416ad92
Update _tracer.py
joaopedrobiu6 Sep 29, 2023
c5a7a29
commit
joaopedrobiu6 Sep 29, 2023
b530b9d
input file
joaopedrobiu6 Sep 29, 2023
13a30d1
optimization objective updated
joaopedrobiu6 Oct 2, 2023
6faa667
changed tolerances
joaopedrobiu6 Oct 2, 2023
164e054
optimization output lenght
joaopedrobiu6 Oct 2, 2023
597e525
DESC equilibrium for testing
joaopedrobiu6 Oct 2, 2023
3f77650
optimization
joaopedrobiu6 Oct 2, 2023
f1174af
optimization changes
joaopedrobiu6 Oct 2, 2023
58ccf3d
minor changes
joaopedrobiu6 Oct 2, 2023
2b3d1c3
removed solving the equilibrium
joaopedrobiu6 Oct 2, 2023
7151137
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Oct 2, 2023
f6596e3
new equilibrium for testing optimization
joaopedrobiu6 Oct 3, 2023
2d6c5c7
changed some stuff
joaopedrobiu6 Oct 3, 2023
797ab59
changed equilibrium
joaopedrobiu6 Oct 7, 2023
13200d9
update
joaopedrobiu6 Oct 7, 2023
3017a74
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Oct 8, 2023
b61f9d3
optimzation test
joaopedrobiu6 Oct 9, 2023
4826640
Merge branch 'jb/DPS' of github.com:joaopedrobiu6/DESC into jb/DPS
joaopedrobiu6 Oct 9, 2023
e39482d
ups
joaopedrobiu6 Oct 9, 2023
421947f
optimization changez
joaopedrobiu6 Oct 9, 2023
5e0a6a0
opti
joaopedrobiu6 Oct 11, 2023
96eebb7
changed the optimization equilibrium
joaopedrobiu6 Oct 11, 2023
9de16a8
added some changes to DESC
rogeriojorge Oct 12, 2023
c8b5152
same
rogeriojorge Oct 12, 2023
0ba0e90
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Oct 13, 2023
9426607
Merge branch 'PlasmaControl:master' into jb/diffrax
joaopedrobiu6 Oct 13, 2023
0226e76
update tracer and opt
joaopedrobiu6 Oct 13, 2023
9791e1c
optimization changed some stuff
joaopedrobiu6 Oct 13, 2023
f36002c
gpu setting
joaopedrobiu6 Oct 13, 2023
4e98eb5
compare
joaopedrobiu6 Oct 16, 2023
212aeb8
organized the folder
joaopedrobiu6 Oct 17, 2023
a29bdf1
trying new equilibrium
joaopedrobiu6 Oct 17, 2023
9a3c149
changed optimization to ellipse
joaopedrobiu6 Oct 17, 2023
2ab68ee
added equilibria
joaopedrobiu6 Oct 17, 2023
b2f29b6
added some comments
joaopedrobiu6 Oct 20, 2023
f849337
optimization
joaopedrobiu6 Oct 21, 2023
f4693c6
DPS total file
joaopedrobiu6 Oct 21, 2023
4467ba8
optimization debug
joaopedrobiu6 Oct 21, 2023
57af62d
should work now
joaopedrobiu6 Oct 21, 2023
1cab5fb
updates
joaopedrobiu6 Oct 21, 2023
f2a92c2
wrong objective lol
joaopedrobiu6 Oct 21, 2023
a08a9db
output to file
joaopedrobiu6 Oct 21, 2023
fbb3f50
dps
joaopedrobiu6 Oct 21, 2023
087f772
i think now its done
joaopedrobiu6 Oct 21, 2023
b7fecb5
added rory's toroidal equilibrium
joaopedrobiu6 Oct 21, 2023
71ec8cf
changed the energy
joaopedrobiu6 Oct 23, 2023
11ceab0
update
joaopedrobiu6 Oct 23, 2023
14092d1
commit for testing
joaopedrobiu6 Oct 23, 2023
3ca6297
new equilibrium
joaopedrobiu6 Oct 24, 2023
8ed659c
test new equilibriu
joaopedrobiu6 Oct 24, 2023
f104c2a
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Oct 24, 2023
20f00ca
dps update all boundaries are free
joaopedrobiu6 Oct 26, 2023
fd191b9
new equilibrium for testing...
joaopedrobiu6 Oct 26, 2023
52a4645
new tryout
joaopedrobiu6 Oct 26, 2023
818ea86
lets try
joaopedrobiu6 Oct 27, 2023
ab1f3cf
new test for landreman paul
joaopedrobiu6 Oct 27, 2023
c686bb7
new tryouts
joaopedrobiu6 Oct 27, 2023
09e95f9
delete outputs
joaopedrobiu6 Oct 27, 2023
cb89034
DPS and sweeping for tryout
joaopedrobiu6 Oct 27, 2023
070d099
jobslurms
joaopedrobiu6 Oct 27, 2023
4f30eb2
changed range
joaopedrobiu6 Oct 30, 2023
4beefef
print info
joaopedrobiu6 Oct 30, 2023
67f72d7
commit
joaopedrobiu6 Oct 30, 2023
e87cce8
weight added
joaopedrobiu6 Oct 30, 2023
39c4898
objfunction is now multiplied by 10e8
joaopedrobiu6 Oct 31, 2023
369dc39
upload
joaopedrobiu6 Oct 31, 2023
168654f
changed the energy
joaopedrobiu6 Oct 31, 2023
2d2f42f
asdas
joaopedrobiu6 Oct 31, 2023
6784860
update
joaopedrobiu6 Oct 31, 2023
9a1aa0e
testing
joaopedrobiu6 Nov 1, 2023
a72c670
lets try this way
joaopedrobiu6 Nov 1, 2023
3443f29
changed energy value
joaopedrobiu6 Nov 1, 2023
bb14a4e
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Nov 2, 2023
39c4743
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Nov 4, 2023
396ff40
update
joaopedrobiu6 Nov 7, 2023
744154f
Merge branch 'jb/DPS' of github.com:joaopedrobiu6/DESC into jb/DPS
joaopedrobiu6 Nov 7, 2023
213042a
added files
Oct 17, 2023
b0c60c9
things
joaopedrobiu6 Nov 7, 2023
0f1cd2a
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 7, 2023
435c553
new objective way baby
joaopedrobiu6 Nov 7, 2023
02a2bc7
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 7, 2023
67d7706
initial commit for METAL compatibility
rogeriojorge Nov 7, 2023
aa2d12c
updates
joaopedrobiu6 Nov 7, 2023
a60c5b2
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 7, 2023
7b2ab3a
removed numpy and some tweaks
joaopedrobiu6 Nov 7, 2023
86960cb
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 7, 2023
07dee72
jacobian
joaopedrobiu6 Nov 8, 2023
69ea4a5
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 8, 2023
702e5bb
jacobian
joaopedrobiu6 Nov 8, 2023
c6e41a7
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 8, 2023
6545ab2
grad
joaopedrobiu6 Nov 8, 2023
a83ca85
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 8, 2023
b3b5e12
save text
joaopedrobiu6 Nov 8, 2023
7d43276
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 8, 2023
bab85c6
try again
joaopedrobiu6 Nov 8, 2023
ae7c8ca
sewwp
joaopedrobiu6 Nov 8, 2023
aecaa6f
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 8, 2023
4d3170d
update on creationism
joaopedrobiu6 Nov 8, 2023
5d040a6
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 8, 2023
1675214
time
joaopedrobiu6 Nov 8, 2023
de2bc81
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 8, 2023
46679bc
elipse
joaopedrobiu6 Nov 8, 2023
5ba1655
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 8, 2023
14c120e
new equilibrium for testing
joaopedrobiu6 Nov 9, 2023
f159709
Merge pull request #1 from rogeriojorge/master
rogeriojorge Nov 9, 2023
a0bfa6b
adding parallel option for sweeping
rogeriojorge Nov 9, 2023
9dee174
sweeping error
rogeriojorge Nov 9, 2023
a2cf2d5
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Nov 10, 2023
4c5a2e4
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 10, 2023
8d8f24c
commit
joaopedrobiu6 Nov 10, 2023
20763ed
Merge branch 'jb/DPS' of github.com:joaopedrobiu6/DESC into jb/DPS
joaopedrobiu6 Nov 10, 2023
d58f382
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 10, 2023
9807f48
equilibrium for tests
joaopedrobiu6 Nov 10, 2023
547dd88
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 10, 2023
8e025f7
changed for yet another test
joaopedrobiu6 Nov 10, 2023
4acf3d8
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 10, 2023
4fa9f6e
test this...
joaopedrobiu6 Nov 10, 2023
dd706f5
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 10, 2023
884f70e
sweeping boundaries
joaopedrobiu6 Nov 10, 2023
f0f2a4e
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 10, 2023
d30cd21
new eq for tests
joaopedrobiu6 Nov 10, 2023
10837de
erge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into jb…
Nov 10, 2023
b858090
commit
joaopedrobiu6 Nov 17, 2023
49e8457
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Nov 17, 2023
8ce06a5
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 17, 2023
9d5a28b
DPS.py changes
joaopedrobiu6 Nov 17, 2023
5b41d47
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 17, 2023
16624d8
Merge branch 'PlasmaControl:master' into jb/diffrax
joaopedrobiu6 Nov 17, 2023
c8919f0
removed copy=True for optimize
joaopedrobiu6 Nov 21, 2023
f0eae48
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 21, 2023
8240194
small mistake
joaopedrobiu6 Nov 21, 2023
2322dd0
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 21, 2023
fb3e880
update
joaopedrobiu6 Nov 21, 2023
e038210
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 21, 2023
b70bb82
false
joaopedrobiu6 Nov 21, 2023
75e1ba3
z
joaopedrobiu6 Nov 21, 2023
7cb6c22
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 21, 2023
0ebbb6f
optimize iota too
joaopedrobiu6 Nov 22, 2023
03fbc3d
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 22, 2023
0a67c71
testing stuff
joaopedrobiu6 Nov 22, 2023
e5a0074
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 22, 2023
3ddbd9b
testing
joaopedrobiu6 Nov 22, 2023
c07b05c
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 22, 2023
571316b
updates 24/1
joaopedrobiu6 Nov 24, 2023
3d7601a
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 24, 2023
711f18e
new eq
joaopedrobiu6 Nov 24, 2023
6bb2d8f
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 24, 2023
e93d444
aspect ratio
joaopedrobiu6 Nov 24, 2023
ea44ca1
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 24, 2023
860566f
aspect ratio error
joaopedrobiu6 Nov 24, 2023
376fd65
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 24, 2023
aca35dd
current set to zero
joaopedrobiu6 Nov 24, 2023
a98ce1a
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 24, 2023
4338a19
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Nov 25, 2023
bd97aa7
DPS.py update and ipynb removed from tracking
joaopedrobiu6 Nov 25, 2023
d65c927
Merge branch 'jb/DPS' of github.com:joaopedrobiu6/DESC into jb/DPS
joaopedrobiu6 Nov 25, 2023
f541fda
updates to DPS.py
joaopedrobiu6 Nov 25, 2023
33974cc
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 25, 2023
a3b7651
ipdate
joaopedrobiu6 Nov 25, 2023
9d75e78
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 25, 2023
f7fdb22
ok
joaopedrobiu6 Nov 25, 2023
2c560f1
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 25, 2023
1dc2bc4
aaa
joaopedrobiu6 Nov 25, 2023
cd502c1
erge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into jb…
Nov 25, 2023
1c9363b
speed test
joaopedrobiu6 Nov 25, 2023
c667f29
deleted a file
joaopedrobiu6 Nov 25, 2023
5202a99
erge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into jb…
Nov 25, 2023
214332d
gitignore
joaopedrobiu6 Nov 25, 2023
42529fb
Merge branch 'jb/DPS' of https://github.com/joaopedrobiu6/DESC into j…
Nov 25, 2023
51ecd1d
slurms out!
joaopedrobiu6 Nov 25, 2023
7e88e0b
updates
joaopedrobiu6 Nov 25, 2023
3816939
FixAspect Ratio
joaopedrobiu6 Nov 26, 2023
77c40d0
changed T_max
joaopedrobiu6 Nov 26, 2023
977e2f1
trying to optimized with aspect ratio taken innto account
joaopedrobiu6 Nov 26, 2023
36b7384
particle tracer update
joaopedrobiu6 Nov 27, 2023
2c809eb
organization
joaopedrobiu6 Nov 27, 2023
abee158
try new optimization
joaopedrobiu6 Nov 27, 2023
86d7b1c
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Nov 27, 2023
1e2b718
changed particle's energy
joaopedrobiu6 Nov 27, 2023
afbbcb7
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Nov 29, 2023
5a443e2
Revert "speed test"
joaopedrobiu6 Nov 29, 2023
60abda8
commit
joaopedrobiu6 Nov 29, 2023
342b611
Revert "trying to optimized with aspect ratio taken innto account"
joaopedrobiu6 Nov 29, 2023
bb8d59b
Revert "new eq"
joaopedrobiu6 Nov 29, 2023
8282693
added equilibrium
joaopedrobiu6 Nov 29, 2023
f2293d6
set deriv_mode to rev
joaopedrobiu6 Nov 29, 2023
191dc41
remove metal
joaopedrobiu6 Nov 29, 2023
e37dffd
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Nov 30, 2023
49d48b3
dps update
joaopedrobiu6 Nov 30, 2023
48f7f13
update
joaopedrobiu6 Nov 30, 2023
3758b95
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Nov 30, 2023
f140b04
class updates
joaopedrobiu6 Nov 30, 2023
08e9e4f
changed some stuff
joaopedrobiu6 Nov 30, 2023
baa23ff
ndim array to float change
joaopedrobiu6 Nov 30, 2023
62f6353
sbatch update
joaopedrobiu6 Nov 30, 2023
d8417db
slurm file - added 1 min to change node
joaopedrobiu6 Nov 30, 2023
76f08fc
added all the equilibria
joaopedrobiu6 Nov 30, 2023
20d5cbb
added data analysis notebook for visualization
joaopedrobiu6 Dec 1, 2023
ec6b169
Merge branch 'jb/diffrax' into jb/DPS
joaopedrobiu6 Dec 1, 2023
887eb64
okay now
joaopedrobiu6 Dec 1, 2023
3fa1665
revert
joaopedrobiu6 Dec 1, 2023
b31fb0a
new eq!
joaopedrobiu6 Dec 1, 2023
fb8d7d8
update
joaopedrobiu6 Dec 1, 2023
4f8fa30
remove commnets
joaopedrobiu6 Dec 1, 2023
f9dd88b
multi_DPS
joaopedrobiu6 Dec 15, 2023
cd9b2b1
multi dps for only two particles
joaopedrobiu6 Dec 15, 2023
3c9d8b3
comparison must be separated
joaopedrobiu6 Dec 15, 2023
edcb53b
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Dec 19, 2023
4973ff5
trying with one zeta
joaopedrobiu6 Dec 20, 2023
e2e26d3
Merge branch 'jb/DPS' into main
joaopedrobiu6 Feb 2, 2024
6bfbfbd
Merge pull request #8 from joaopedrobiu6/main
joaopedrobiu6 Feb 2, 2024
ee1f0ba
comparison files in DPS fork
joaopedrobiu6 Feb 8, 2024
23a9907
Merge branch 'master' of github.com:PlasmaControl/DESC into jb/DPS
joaopedrobiu6 Jun 27, 2024
8b04e83
merge
joaopedrobiu6 Jun 27, 2024
0ba16db
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Jun 27, 2024
191bd22
trying to make it work
joaopedrobiu6 Jun 27, 2024
2d8a378
tracer working
joaopedrobiu6 Jun 27, 2024
c195166
optimization works but must be studied carefully
joaopedrobiu6 Jun 27, 2024
80522fe
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Jul 16, 2024
0dff2f6
removed DS_Store
joaopedrobiu6 Jul 16, 2024
06f09c4
Merge branch 'jb/DPS' of github.com:joaopedrobiu6/DESC into jb/DPS
joaopedrobiu6 Jul 16, 2024
d55407b
multiparticle tracing
joaopedrobiu6 Jul 26, 2024
d8bd11c
gpu
joaopedrobiu6 Jul 26, 2024
5af3a24
jax
joaopedrobiu6 Jul 26, 2024
0c1e5f3
particle tracer had numpy function
joaopedrobiu6 Jul 26, 2024
d34afa2
visualization tool update
joaopedrobiu6 Jul 26, 2024
b1efca5
optimization trial 1
joaopedrobiu6 Jul 28, 2024
c7230ef
slurm update
joaopedrobiu6 Jul 28, 2024
6a46c04
updated slurm name
joaopedrobiu6 Jul 28, 2024
b6c8aed
forgot module load on job slurm
joaopedrobiu6 Jul 28, 2024
fc4224c
changed objective
joaopedrobiu6 Jul 28, 2024
532957d
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Jul 28, 2024
59b2baf
changed bounds for forcebalance
joaopedrobiu6 Jul 28, 2024
f59b2f2
updated the objective function
joaopedrobiu6 Jul 28, 2024
3c843f4
tracer objective
joaopedrobiu6 Jul 28, 2024
89c0053
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Jul 31, 2024
2ea1a68
updated the objetive function
joaopedrobiu6 Aug 1, 2024
82da3e0
optimization params update
joaopedrobiu6 Aug 1, 2024
3ba174d
updated slurm for optimization.py
joaopedrobiu6 Aug 1, 2024
6bf58a4
added new equilibrium
joaopedrobiu6 Aug 1, 2024
18da01b
small change in jit position
joaopedrobiu6 Aug 1, 2024
efe843d
test
joaopedrobiu6 Aug 1, 2024
464ed14
updated the objetive funcion to the sum of the average deviation
joaopedrobiu6 Aug 5, 2024
7f6a5d9
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Nov 15, 2024
524680e
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Nov 19, 2024
4b81788
Merge branch 'PlasmaControl:master' into jb/DPS
joaopedrobiu6 Nov 27, 2024
7226ecb
Merge branch 'master' into jb/DPS
dpanici Mar 6, 2025
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
Binary file added .DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
},
"python.formatting.provider": "none"
}
1 change: 1 addition & 0 deletions desc/compute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
_profiles,
_stability,
_surface,
_particle
)
from .data_index import all_kwargs, allowed_kwargs, data_index
from .geom_utils import rpz2xyz, rpz2xyz_vec, xyz2rpz, xyz2rpz_vec
Expand Down
97 changes: 97 additions & 0 deletions desc/compute/_particle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
from desc.backend import jnp

from .data_index import register_compute_fun


@register_compute_fun(
name="psidot",
label="\\dot{\\psi}",
units="",
units_long="",
description="Time derivative of psi",
dim=1,
params=["Psi"],
transforms={},
profiles=[],
coordinates="rtz",
data=["|B|", "B", "grad(|B|)", "grad(psi)"],
vpar = "vpar",
mu = "mu",
m_q = "m_q"
)
def _psidot(params, transforms, profiles, data, **kwargs):
m_q = kwargs.get("m_q", 1.673e-27/1.6e-19)
mu = kwargs.get("mu")
vpar = kwargs.get("vpar")
data["psidot"] = (jnp.sum(jnp.cross(data["B"], data["grad(|B|)"], axis=-1) * data["grad(psi)"], axis=-1) * ((m_q*(1/data["|B|"]**3)) * ((mu*data["|B|"].T).T + vpar**2)).T).T * (2*jnp.pi/params["Psi"])
return data

Check warning on line 27 in desc/compute/_particle.py

View check run for this annotation

Codecov / codecov/patch

desc/compute/_particle.py#L23-L27

Added lines #L23 - L27 were not covered by tests


@register_compute_fun(
name="thetadot",
label="\\dot{\\theta}",
units="rad/s",
units_long="radians / second",
description="Time derivative of theta",
dim=1,
params=[],
transforms={},
profiles=[],
coordinates="rtz",
data=["|B|", "B", "grad(|B|)", "e^theta"],
vpar = "vpar",
mu = "mu",
m_q = "m_q"
)
def _thetadot(params, transforms, profiles, data, **kwargs):
m_q = kwargs.get("m_q", 1.673e-27/1.6e-19)
mu = kwargs.get("mu")
vpar = kwargs.get("vpar")
data["thetadot"] = (vpar/data["|B|"]) * jnp.sum(data["B"] * data["e^theta"], axis=-1) + (m_q/(data["|B|"]**3))*(mu*data["|B|"] + vpar**2)*jnp.sum(jnp.cross(data["B"], data["grad(|B|)"], axis=-1) * data["e^theta"], axis=-1)
return data

Check warning on line 51 in desc/compute/_particle.py

View check run for this annotation

Codecov / codecov/patch

desc/compute/_particle.py#L47-L51

Added lines #L47 - L51 were not covered by tests

@register_compute_fun(
name="zetadot",
label="\\dot{\\zeta}",
units="rad/s",
units_long="radians / second",
description="Time derivative of zeta",
dim=1,
params=[],
transforms={},
profiles=[],
coordinates="rtz",
data=["|B|", "B", "e^zeta"],
vpar = "vpar",
mu = "mu",
m_q = "m_q"
)
def _zetadot(params, transforms, profiles, data, **kwargs):
m_q = kwargs.get("m_q", 1.673e-27/1.6e-19)
mu = kwargs.get("mu")
vpar = kwargs.get("vpar")
data["zetadot"] = (vpar/data["|B|"]) * jnp.sum(data["B"] * data["e^zeta"], axis=-1) + (m_q/(data["|B|"]**3))*(mu*data["|B|"] + vpar**2)*jnp.sum(jnp.cross(data["B"], data["grad(|B|)"], axis=-1) * data["e^zeta"], axis=-1)
return data

Check warning on line 74 in desc/compute/_particle.py

View check run for this annotation

Codecov / codecov/patch

desc/compute/_particle.py#L70-L74

Added lines #L70 - L74 were not covered by tests

@register_compute_fun(
name="vpardot",
label="\\dot{\\vpar}",
units="m/s",
units_long="meters / second",
description="Time derivative of the parallel velocity",
dim=1,
params=[],
transforms={},
profiles=[],
coordinates="rtz",
data=["|B|", "B", "grad(|B|)", "b"],
vpar = "vpar",
mu = "mu",
m_q = "m_q"
)
def _vpardot(params, transforms, profiles, data, **kwargs):
m_q = kwargs.get("m_q", 1.673e-27/1.6e-19)
mu = kwargs.get("mu")
vpar = kwargs.get("vpar")
data["vpardot"] = -mu * jnp.sum(data["b"] * data["grad(|B|)"], axis=-1)
return data

Check warning on line 97 in desc/compute/_particle.py

View check run for this annotation

Codecov / codecov/patch

desc/compute/_particle.py#L93-L97

Added lines #L93 - L97 were not covered by tests
2 changes: 2 additions & 0 deletions desc/objectives/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@
FixThetaSFL,
)
from .objective_funs import ObjectiveFunction

from ._tracer import ParticleTracer
156 changes: 156 additions & 0 deletions desc/objectives/_tracer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
"""Objectives for optimizing the equilibrium from tracing particles using Diffrax solver"""

import warnings

from desc.backend import jnp
from desc.compute import compute as compute_fun
from desc.compute import get_params, get_profiles, get_transforms
from desc.grid import Grid
from jax.experimental.ode import odeint as jax_odeint
from functools import partial
from jax import jit, vmap
from .objective_funs import _Objective

class ParticleTracer(_Objective):
"""Particle Tracer using Guiding Center equations of motion.

Parameters
----------
eq : Equilibrium, optional
Equilibrium that will be optimized to satisfy the Objective.
target : float, ndarray, optional
Target value(s) of the objective. Only used if bounds is None.
len(target) must be equal to Objective.dim_f
bounds : tuple, optional
Lower and upper bounds on the objective. Overrides target.
len(bounds[0]) and len(bounds[1]) must be equal to Objective.dim_f
weight : float, ndarray, optional
Weighting to apply to the Objective, relative to other Objectives.
len(weight) must be equal to Objective.dim_f
normalize : bool
Whether to compute the error in physical units or non-dimensionalize.
normalize_target : bool
Whether target and bounds should be normalized before comparing to computed
values. If `normalize` is `True` and the target is in physical units,
this should also be set to True.
output_time : ndarray
Values of time where the system is evaluated.
initial_conditions : tuple, array
Initial conditions (psi, theta, zeta, vpar) to solve the system of equations.
Starting state of the system.
initial_parameters : tuple, array
Parameters needed in the system, such as the magnetic momentum, mu, and the mass-charge ratio, m_q.
compute_option: str
Select the compute() output. Can be "optimization" for the optimization metric; "tracer" for the full
solution of the system; "average psi/theta/zeta/vpar" for the mean value of psi/theta/zeta/vpar in the
computed time.
deriv_mode : {"auto", "fwd", "rev"}
Specify how to compute jacobian matrix, either forward mode or reverse mode AD.
"auto" selects forward or reverse mode based on the size of the input and output
of the objective. Has no effect on self.grad or self.hess which always use
reverse mode and forward over reverse mode respectively.
name : str
Name of the objective function.
"""

_scalar = False
_linear = False
_units = ""
_print_value_fmt = "System solution: {:10.3e}"

def __init__(
self,
eq=None,
target=None,
bounds=None,
weight=1,
normalize=True,
normalize_target=True,
output_time=None,
initial_conditions=None,
initial_parameters=None,
compute_option=None,
tolerance = 1.4e-8,
deriv_mode = "rev",
name="Particle Tracer"
):
self.output_time = output_time
self.initial_conditions=jnp.asarray(initial_conditions)
self.initial_parameters=jnp.asarray(initial_parameters)
self.compute_option=compute_option
self.tolerance = tolerance

Check warning on line 81 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L77-L81

Added lines #L77 - L81 were not covered by tests

if target is None and bounds is None:
target = 0

Check warning on line 84 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L83-L84

Added lines #L83 - L84 were not covered by tests

super().__init__(

Check warning on line 86 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L86

Added line #L86 was not covered by tests
things=eq,
target=target,
bounds=bounds,
weight=weight,
normalize=normalize,
normalize_target=normalize_target,
deriv_mode=deriv_mode,
name=name,
)

self._print_value_fmt = (

Check warning on line 97 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L97

Added line #L97 was not covered by tests
"System solution for initial conditions"
)

def build(self, eq=None, use_jit=True, verbose=1):

self._data_keys = ["psidot", "thetadot", "zetadot", "vpardot"]
self._args = get_params(

Check warning on line 104 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L103-L104

Added lines #L103 - L104 were not covered by tests
self._data_keys,
obj="desc.equilibrium.equilibrium.Equilibrium",
has_axis=False,
)

self.charge = 1.6e-19
self.mass = 1.673e-27
self.Energy = 3.52e6*self.charge
eq = eq or self._things[0]

Check warning on line 113 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L110-L113

Added lines #L110 - L113 were not covered by tests

if self.compute_option == "optimization":
self._dim_f = 1
elif self.compute_option == "tracer":
self._dim_f = [len(self.output_time), 4]
elif self.compute_option.startswith("average "):
self._dim_f = 1

Check warning on line 120 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L115-L120

Added lines #L115 - L120 were not covered by tests

super().build(use_jit=use_jit, verbose=verbose)

Check warning on line 122 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L122

Added line #L122 was not covered by tests

def compute(self, params, constants=None):

constants = constants or self.constants

Check warning on line 126 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L126

Added line #L126 was not covered by tests

@jit
def system(initial_conditions = self.initial_conditions, t = self.output_time, initial_parameters = self.initial_parameters):
psi, theta, zeta, vpar = initial_conditions
grid = Grid(jnp.array([jnp.sqrt(psi), theta, zeta]).T, spacing=jnp.zeros((3,)).T, jitable=True, sort=False)
transforms = get_transforms(self._data_keys, self._things[0], grid, jitable=True)
profiles = get_profiles(self._data_keys, self._things[0], grid)
data = compute_fun("desc.equilibrium.equilibrium.Equilibrium", self._data_keys, params, transforms, profiles,

Check warning on line 134 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L128-L134

Added lines #L128 - L134 were not covered by tests
mu=initial_parameters[0], m_q=initial_parameters[1], vpar=vpar)

return jnp.array([data[f"{key}dot"] for key in ['psi', 'theta', 'zeta', 'vpar']])

Check warning on line 137 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L137

Added line #L137 was not covered by tests

initial_conditions_jax = jnp.array(self.initial_conditions, dtype=jnp.float64)
initial_parameters_jax = jnp.array(self.initial_parameters, dtype=jnp.float64)

Check warning on line 140 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L139-L140

Added lines #L139 - L140 were not covered by tests


#solution = jax_odeint(partial(system_jit, initial_parameters=self.initial_parameters), initial_conditions_jax, self.output_time, rtol=self.tolerance)
intfun = lambda initial_conditions_jax, initial_parameters_jax: jax_odeint(partial(system, initial_parameters=initial_parameters_jax),

Check warning on line 144 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L144

Added line #L144 was not covered by tests
initial_conditions_jax, self.output_time, rtol=self.tolerance)

solution = vmap(intfun)(initial_conditions_jax, initial_parameters_jax)

Check warning on line 147 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L147

Added line #L147 was not covered by tests

if self.compute_option == "optimization":
new = jnp.repeat(solution[:, :, 0][:, 0:1], solution[:, :, 0].shape[1], axis=1)
return jnp.sum(jnp.mean((solution[:, :, 0] - new)**2, axis=-1), axis=-1)
elif self.compute_option == "tracer":
return solution
elif self.compute_option.startswith("average "):
index = ["psi", "theta", "zeta", "vpar"].index(self.compute_option.split()[-1])
return jnp.mean(solution[:, index])

Check warning on line 156 in desc/objectives/_tracer.py

View check run for this annotation

Codecov / codecov/patch

desc/objectives/_tracer.py#L149-L156

Added lines #L149 - L156 were not covered by tests
4 changes: 4 additions & 0 deletions dps/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.png
*.ipynb
*.txt
*.out
Loading
Loading