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

Gamma_c (Nemov and Velasco et. al) Γ_c #1042

Merged
merged 128 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
a4f947f
Add Gamma_c to neoclassical compute quantities
unalmis Jun 2, 2024
069036f
Merge branch 'ripple' into Gamma_c
unalmis Jun 3, 2024
2cea638
Update thing after merge
unalmis Jun 3, 2024
03694a0
Merge branch 'ripple' into Gamma_c
unalmis Jun 4, 2024
c17a9df
Add Gamma_c plot
unalmis Jun 4, 2024
c616ee5
Merge branch 'ripple' into Gamma_c
unalmis Jun 12, 2024
e0dffc6
Merge branch 'ripple' into Gamma_c
unalmis Jun 12, 2024
4947bee
Add Gamma_c objective function
unalmis Jun 13, 2024
08af99d
Merge branch 'ripple' into Gamma_c
unalmis Jun 13, 2024
9979ab5
Fix docstring
unalmis Jun 13, 2024
0810075
Merge branch 'ripple' into Gamma_c
unalmis Jun 18, 2024
5956349
Update Gamma_c test after merge
unalmis Jun 18, 2024
39f9ade
Merge branch 'ripple' into Gamma_c
unalmis Jun 18, 2024
19b58ba
Merge branch 'ripple' into Gamma_c
unalmis Jun 22, 2024
802e4ba
Merge branch 'ripple' into Gamma_c
unalmis Jun 22, 2024
b6f0614
Merge branch 'ripple' into Gamma_c
unalmis Jun 24, 2024
a6c29df
Fix calls to rtz_grid after merge
unalmis Jun 24, 2024
36d5e82
Merge branch 'ripple' into Gamma_c
unalmis Jun 25, 2024
18960f8
Merge branch 'ripple' into Gamma_c
unalmis Jun 25, 2024
f3361cb
average before integration to reduce computation
unalmis Jun 25, 2024
10e9937
Merge branch 'ripple' into Gamma_c
unalmis Jul 2, 2024
e8f240d
Merge branch 'ripple' into Gamma_c
unalmis Jul 5, 2024
ad7f2b6
Merge branch 'ripple' into Gamma_c
unalmis Jul 11, 2024
e6adeb2
remove unused jitable arg causing error
dpanici Jul 16, 2024
1462d28
remove unneeded jitable call
dpanici Jul 17, 2024
0bf73b4
Merge branch 'ripple' into Gamma_c
unalmis Jul 20, 2024
7a50240
Merge branch 'ripple' into Gamma_c
unalmis Jul 25, 2024
0348288
Merge branch 'ripple' into Gamma_c
unalmis Jul 25, 2024
1c8d4eb
Only get profiles in objective build method
unalmis Jul 25, 2024
29903ed
Merge branch 'ripple' into Gamma_c
unalmis Jul 25, 2024
2ab29a9
Add num_wells parameter to increase performance
unalmis Jul 25, 2024
6b7bcfb
Merge branch 'ripple' into Gamma_c
unalmis Jul 25, 2024
a0d68fe
Merge branch 'ripple' into Gamma_c
unalmis Jul 25, 2024
67586ff
Add num_wells to Gamma_c objective
unalmis Jul 25, 2024
204dea8
Merge branch 'ripple' into Gamma_c
unalmis Jul 26, 2024
6ec5bd2
Add num_wells as static parameter to compute fun
unalmis Jul 26, 2024
29d1e8d
Merge branch 'ripple' into Gamma_c
unalmis Jul 26, 2024
2c54f9d
Specify kwargs for trapezoid integration after quadax API changes fro…
unalmis Jul 26, 2024
921f4d5
Add Nemov's Gamma_c
unalmis Aug 5, 2024
5ca2630
Remove hanging plt.show() from last commit
unalmis Aug 5, 2024
cd3b6b6
Fix comment
unalmis Aug 5, 2024
4577d4f
Fix another comment
unalmis Aug 5, 2024
d528b33
Merge branch 'ripple' into Gamma_c
unalmis Aug 7, 2024
67d0662
Merge branch 'ripple' into Gamma_c
unalmis Aug 18, 2024
4595546
Fix reshape error raised by JAX by reverting average before pitch int…
unalmis Aug 18, 2024
f0ad787
Merge branch 'ripple' into Gamma_c
unalmis Aug 18, 2024
e0dfd61
Merge branch 'ku/angles' into Gamma_c
unalmis Aug 18, 2024
75bc784
Use general angles rather than stream function aliases
unalmis Aug 18, 2024
72fb5e6
Merge branch 'ripple' into Gamma_c
unalmis Aug 20, 2024
75c9333
Merge branch 'ripple' into Gamma_c
unalmis Sep 3, 2024
d2bfe12
Merge branch 'ripple' into Gamma_c
unalmis Sep 4, 2024
2363303
Atone for B0 name change made in pull request #1168
unalmis Sep 4, 2024
4cea229
Merge branch 'ripple' into Gamma_c
unalmis Sep 4, 2024
ba758d6
Merge branch 'ripple' into Gamma_c
unalmis Sep 4, 2024
4216094
Merge branch 'ripple' into Gamma_c
unalmis Sep 4, 2024
d94ecd6
Update Gamma_c objective for recent changes on master
unalmis Sep 4, 2024
5cd7ebd
Add Gamma_c_Nemov baseline image for test
unalmis Sep 4, 2024
df2938e
Merge branch 'ripple' into Gamma_c
unalmis Sep 15, 2024
717426f
Merge branch 'ripple' into Gamma_c
unalmis Sep 15, 2024
c2e455d
Allow using other Gamma_c in objective
unalmis Sep 15, 2024
3d44b04
Merge branch 'ripple' into Gamma_c
unalmis Sep 16, 2024
9ed4a47
black format
unalmis Sep 16, 2024
070626b
Merge branch 'ripple' into Gamma_c
unalmis Sep 16, 2024
246427b
Merge branch 'ripple' into Gamma_c
unalmis Sep 16, 2024
621cb71
Merge branch 'ripple' into Gamma_c
unalmis Sep 17, 2024
a5a257b
Merge branch 'ripple' into Gamma_c
unalmis Sep 17, 2024
4d3169b
Merge branch 'ripple' into Gamma_c
unalmis Sep 17, 2024
55f8aa5
Merge branch 'master' into Gamma_c
unalmis Sep 18, 2024
9498ad4
Merge branch 'ripple' into Gamma_c
unalmis Sep 18, 2024
7894b41
Merge branch 'ripple' into Gamma_c
unalmis Sep 19, 2024
9acc900
Use infinite period for alpha
unalmis Sep 19, 2024
e31b602
Use better quadrature for part of integral in Nemov Gamma_c
unalmis Sep 21, 2024
a574827
Add quad2 kwargs for weak singular integrals
unalmis Sep 21, 2024
cff5494
Merge branch 'ripple' into Gamma_c
unalmis Sep 22, 2024
503f0d6
Avoid redundant computation of bounce points
unalmis Sep 22, 2024
362f198
Merge branch 'ripple' into Gamma_c
unalmis Sep 22, 2024
48d92fb
Merge branch 'ripple' into Gamma_c
unalmis Sep 22, 2024
3714827
Merge branch 'ripple' into Gamma_c
unalmis Sep 22, 2024
1739b3e
Merge branch 'ripple' into Gamma_c
unalmis Sep 22, 2024
9dac89e
Document that Velasco's expression converges to zero
unalmis Sep 24, 2024
5a8e861
Merge branch 'ripple' into Gamma_c
unalmis Sep 24, 2024
7268ad8
Update after merging
unalmis Sep 24, 2024
b58a1bd
Merge branch 'ripple' into Gamma_c
unalmis Sep 25, 2024
5b668ee
Merge branch 'ripple' into Gamma_c
unalmis Sep 26, 2024
eef81f6
Merge branch 'ripple' into Gamma_c
unalmis Sep 26, 2024
507a30c
Merge branch 'ripple' into Gamma_c
unalmis Sep 26, 2024
021b28a
Add chunk_size option
unalmis Sep 26, 2024
1a62674
Merge branch 'ripple' into Gamma_c
unalmis Sep 27, 2024
3f465d6
Merge branch 'ripple' into Gamma_c
unalmis Sep 27, 2024
157359d
Merge branch 'ripple' into Gamma_c
unalmis Sep 29, 2024
53ea40b
Merge branch 'ripple' into Gamma_c
unalmis Sep 29, 2024
779f57c
Make sure API is compatible for Gamma_d etc.
unalmis Sep 29, 2024
954b9ec
address my review comment
unalmis Sep 29, 2024
bc5f6d3
Resolve todo comment out smoothness
unalmis Sep 29, 2024
5b8ccb7
Merge branch 'ripple' into Gamma_c
unalmis Sep 30, 2024
f6aee2c
Merge branch 'ripple' into Gamma_c
unalmis Sep 30, 2024
e5127e0
Merge remote-tracking branch 'refs/remotes/origin/Gamma_c' into Gamma_c
unalmis Sep 30, 2024
21c2e6b
fix method name in gammaC compute call
dpanici Oct 3, 2024
e13bdaf
Merge branch 'ripple' into Gamma_c
unalmis Oct 17, 2024
d5f4473
Update comment about convergence to zero with warning to use adaptive…
unalmis Oct 17, 2024
1797fcc
Merge branch 'ripple' into Gamma_c
unalmis Oct 17, 2024
b83fed8
Merge branch 'ripple' into Gamma_c
unalmis Oct 19, 2024
2e74569
Merge branch 'ripple' into Gamma_c
unalmis Oct 19, 2024
9ffb527
Merge branch 'ripple' into Gamma_c
unalmis Oct 20, 2024
090ef23
Merge branch 'ripple' into Gamma_c
unalmis Oct 20, 2024
5be0f27
Merging ripple
unalmis Oct 20, 2024
7db67d6
Merge branch 'ripple' into Gamma_c
unalmis Oct 30, 2024
563a67c
Merge branch 'ripple' into Gamma_c
unalmis Oct 30, 2024
6c1b647
Merge branch 'ripple' into Gamma_c
unalmis Oct 31, 2024
bcc0dd0
Merge branch 'ripple' into Gamma_c
unalmis Nov 16, 2024
67ba404
Merge branch 'ripple' into Gamma_c
dpanici Nov 22, 2024
158fade
Merge branch 'ripple' into Gamma_c
unalmis Nov 26, 2024
27cfacf
fixing #1288, adding opt tests for Gamma_c
Dec 3, 2024
2f8ba3c
Revert "fixing #1288, adding opt tests for Gamma_c"
Dec 3, 2024
0257d91
Merge branch 'ripple' into Gamma_c
unalmis Dec 5, 2024
57d983f
Merge part 1
unalmis Dec 5, 2024
f7b6267
Merge branch 'ripple' into Gamma_c
unalmis Dec 5, 2024
c3a7296
Merging part 2
unalmis Dec 5, 2024
6057ec5
Merge branch 'ripple' into Gamma_c
unalmis Dec 5, 2024
7860d61
Merge branch 'master' into Gamma_c
unalmis Dec 6, 2024
231c643
Merge branch 'master' into Gamma_c
unalmis Dec 9, 2024
751ce53
Merge branch 'master' into Gamma_c
unalmis Dec 10, 2024
b505e70
Merge branch 'master' into Gamma_c
rahulgaur104 Dec 10, 2024
ec937d5
Review requests
unalmis Dec 10, 2024
86a0c2f
Review request 2
unalmis Dec 10, 2024
3c582e2
Merge branch 'master' into Gamma_c
unalmis Dec 11, 2024
c312aa1
review request to make objective only allow kwarg
unalmis Dec 13, 2024
ce98913
Merge branch 'master' into Gamma_c
unalmis Dec 13, 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
107 changes: 85 additions & 22 deletions desc/compute/_basis_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _b(params, transforms, profiles, data, **kwargs):


@register_compute_fun(
name="e^rho", # ∇ρ is the same in (ρ,θ,ζ) and (ρ,α,ζ) coordinates.
name="e^rho", # ∇ρ is the same in any coordinate system.
label="\\mathbf{e}^{\\rho}",
units="m^{-1}",
units_long="inverse meters",
Expand Down Expand Up @@ -927,7 +927,7 @@ def _e_sup_theta_zz(params, transforms, profiles, data, **kwargs):


@register_compute_fun(
name="e^zeta", # ∇ζ is the same in (ρ,θ,ζ) and (ρ,α,ζ) coordinates.
name="e^zeta", # ∇ζ is the same in any coordinate system.
label="\\mathbf{e}^{\\zeta}",
units="m^{-1}",
units_long="inverse meters",
Expand Down Expand Up @@ -2449,10 +2449,10 @@ def _e_sub_theta_over_sqrt_g(params, transforms, profiles, data, **kwargs):
)
def _e_sub_vartheta_rp(params, transforms, profiles, data, **kwargs):
# constant ρ and ϕ
e_vartheta = (
data["e_theta"].T * data["phi_z"] - data["e_zeta"].T * data["phi_t"]
) / (data["theta_PEST_t"] * data["phi_z"] - data["theta_PEST_z"] * data["phi_t"])
data["e_theta_PEST"] = e_vartheta.T
data["e_theta_PEST"] = (
(data["e_theta"].T * data["phi_z"] - data["e_zeta"].T * data["phi_t"])
/ (data["theta_PEST_t"] * data["phi_z"] - data["theta_PEST_z"] * data["phi_t"])
).T
Copy link
Collaborator Author

@unalmis unalmis Aug 5, 2024

Choose a reason for hiding this comment

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

Made this cosmetic change so that it shows up in git diff and reviewer can confirm new quantities of this form are correct by comparison.

return data


Expand All @@ -2473,11 +2473,13 @@ def _e_sub_vartheta_rp(params, transforms, profiles, data, **kwargs):
)
def _e_sub_phi_rv(params, transforms, profiles, data, **kwargs):
# constant ρ and ϑ
e_phi = (
data["e_zeta"].T * data["theta_PEST_t"]
- data["e_theta"].T * data["theta_PEST_z"]
) / (data["theta_PEST_t"] * data["phi_z"] - data["theta_PEST_z"] * data["phi_t"])
data["e_phi|r,v"] = e_phi.T
data["e_phi|r,v"] = (
(
data["e_zeta"].T * data["theta_PEST_t"]
- data["e_theta"].T * data["theta_PEST_z"]
)
/ (data["theta_PEST_t"] * data["phi_z"] - data["theta_PEST_z"] * data["phi_t"])
).T
return data


Expand All @@ -2499,10 +2501,10 @@ def _e_sub_phi_rv(params, transforms, profiles, data, **kwargs):
def _e_sub_rho_vp(params, transforms, profiles, data, **kwargs):
# constant ϑ and ϕ
data["e_rho|v,p"] = (
data["e_rho"].T
- data["e_vartheta"].T * data["theta_PEST_r"]
- data["e_phi|r,v"].T * data["phi_r"]
).T
data["e_rho"]
- data["e_vartheta"] * data["theta_PEST_r"][:, jnp.newaxis]
- data["e_phi|r,v"] * data["phi_r"][:, jnp.newaxis]
)
return data


Expand Down Expand Up @@ -3206,7 +3208,28 @@ def _e_sub_zeta_zz(params, transforms, profiles, data, **kwargs):
data["Z_zzz"],
]
).T
return data


@register_compute_fun(
name="grad(phi)",
label="\\nabla \\phi",
units="m^{-1}",
units_long="Inverse meters",
description="Gradient of cylindrical toroidal angle ϕ.",
dim=3,
params=[],
transforms={},
profiles=[],
coordinates="rtz",
data=["R", "0"],
parameterization=[
"desc.equilibrium.equilibrium.Equilibrium",
"desc.geometry.surface.FourierRZToroidalSurface",
],
)
def _grad_phi(params, transforms, profiles, data, **kwargs):
data["grad(phi)"] = jnp.column_stack([data["0"], 1 / data["R"], data["0"]])
return data


Expand Down Expand Up @@ -3456,7 +3479,7 @@ def _e_sub_theta_rp(params, transforms, profiles, data, **kwargs):
label="\\mathbf{e}_{\\rho} |_{\\alpha, \\zeta}",
units="m",
units_long="meters",
description="Tangent vector along radial field line label",
description="Covariant radial basis vector in (ρ, α, ζ) Clebsch coordinates.",
dim=3,
params=[],
transforms={},
Expand All @@ -3477,7 +3500,7 @@ def _e_rho_az(params, transforms, profiles, data, **kwargs):
label="\\mathbf{e}_{\\alpha}",
units="m",
units_long="meters",
description="Tangent vector along poloidal field line label",
description="Covariant poloidal basis vector in (ρ, α, ζ) Clebsch coordinates.",
dim=3,
params=[],
transforms={},
Expand All @@ -3496,8 +3519,8 @@ def _e_alpha(params, transforms, profiles, data, **kwargs):
label="\\partial_{\\theta} \\mathbf{e}_{\\alpha}",
units="m",
units_long="meters",
description="Tangent vector along poloidal field line label, derivative wrt"
" DESC poloidal angle",
description="Covariant poloidal basis vector in (ρ, α, ζ) Clebsch coordinates,"
" derivative wrt DESC poloidal angle",
dim=3,
params=[],
transforms={},
Expand All @@ -3518,8 +3541,8 @@ def _e_alpha_t(params, transforms, profiles, data, **kwargs):
label="\\partial_{\\zeta} \\mathbf{e}_{\\alpha}",
units="m",
units_long="meters",
description="Tangent vector along poloidal field line label, "
"derivative wrt DESC toroidal angle",
description="Covariant poloidal basis vector in (ρ, α, ζ) Clebsch coordinates, "
"derivative wrt DESC toroidal angle at fixed ρ,θ.",
dim=3,
params=[],
transforms={},
Expand Down Expand Up @@ -3603,7 +3626,7 @@ def _e_zeta_ra_a(params, transforms, profiles, data, **kwargs):
units="m",
units_long="meters",
description="Tangent vector along (collinear to) field line, "
"derivative wrt DESC toroidal angle",
"derivative wrt DESC toroidal angle at fixed ρ,θ.",
dim=3,
params=[],
transforms={},
Expand Down Expand Up @@ -3679,3 +3702,43 @@ def _d_ell_d_zeta_z(params, transforms, profiles, data, **kwargs):
dot(data["(e_zeta|r,a)_z|r,a"], data["e_zeta|r,a"]) / data["|e_zeta|r,a|"]
)
return data


@register_compute_fun(
name="e_alpha|r,p",
label="\\mathbf{e}_{\\alpha} |_{\\rho, \\phi}",
units="m",
units_long="meters",
description="Covariant poloidal basis vector in (ρ, α, ϕ) Clebsch coordinates.",
dim=3,
params=[],
transforms={},
profiles=[],
coordinates="rtz",
data=["e_theta", "alpha_t", "e_zeta", "alpha_z", "phi_t", "phi_z"],
)
def _e_alpha_rp(params, transforms, profiles, data, **kwargs):
data["e_alpha|r,p"] = (
(data["e_theta"].T * data["phi_z"] - data["e_zeta"].T * data["phi_t"])
/ (data["alpha_t"] * data["phi_z"] - data["alpha_z"] * data["phi_t"])
).T
return data


@register_compute_fun(
name="|e_alpha|r,p|",
label="|\\mathbf{e}_{\\alpha} |_{\\rho, \\phi}|",
units="m",
units_long="meters",
description="Norm of covariant poloidal basis vector in (ρ, α, ϕ) Clebsch "
"coordinates.",
dim=1,
params=[],
transforms={},
profiles=[],
coordinates="rtz",
data=["e_alpha|r,p"],
)
def _e_alpha_rp_norm(params, transforms, profiles, data, **kwargs):
data["|e_alpha|r,p|"] = jnp.linalg.norm(data["e_alpha|r,p"], axis=-1)
return data
19 changes: 19 additions & 0 deletions desc/compute/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3153,6 +3153,25 @@ def _theta_PEST_rt(params, transforms, profiles, data, **kwargs):
return data


@register_compute_fun(
name="theta_PEST_rz",
label="\\partial_{\\rho \\zeta} \\vartheta",
units="rad",
units_long="radians",
description="PEST straight field line poloidal angular coordinate, derivative wrt "
"radial and DESC toroidal coordinate",
dim=1,
params=[],
transforms={},
profiles=[],
coordinates="rtz",
data=["lambda_rz"],
)
def _theta_PEST_rz(params, transforms, profiles, data, **kwargs):
data["theta_PEST_rz"] = data["lambda_rz"]
return data


@register_compute_fun(
name="theta_PEST_rrt",
label="\\partial_{\\rho \\rho \\theta} \\vartheta",
Expand Down
Loading
Loading