From 5f9326fc9f5735177d2ccff61d9e5b9e7fabd653 Mon Sep 17 00:00:00 2001 From: unalmis Date: Thu, 11 Jul 2024 18:20:46 -0400 Subject: [PATCH 1/3] Document basis input data --- desc/compute/utils.py | 7 ++++++- desc/equilibrium/equilibrium.py | 4 +++- desc/geometry/core.py | 4 +++- desc/geometry/curve.py | 4 +++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/desc/compute/utils.py b/desc/compute/utils.py index 491e4ebddf..f26517dcc9 100644 --- a/desc/compute/utils.py +++ b/desc/compute/utils.py @@ -53,7 +53,9 @@ def compute(parameterization, names, params, transforms, profiles, data=None, ** Profile objects for pressure, iota, current, etc. Defaults to attributes of self data : dict of ndarray - Data computed so far, generally output from other compute functions + Data computed so far, generally output from other compute functions. + All vectors v = [vᴿ, v^ϕ, vᶻ] should be given in contravariant components + of the cylindrical basis coordinates R,ϕ,Z (shorthand is ``rpz``). Returns ------- @@ -121,6 +123,9 @@ def _compute( ): """Same as above but without checking inputs for faster recursion. + All vectors v = [vᴿ, v^ϕ, vᶻ] in ``data`` should be given in contravariant + components of the cylindrical basis coordinates R,ϕ,Z (shorthand is ``rpz``). + We need to directly call this function in objectives, since the checks in above function are not compatible with JIT. This function computes given names while using recursion to compute dependencies. If you want to call this function, you diff --git a/desc/equilibrium/equilibrium.py b/desc/equilibrium/equilibrium.py index 3a635ae22e..e250d4db5d 100644 --- a/desc/equilibrium/equilibrium.py +++ b/desc/equilibrium/equilibrium.py @@ -811,7 +811,9 @@ def compute( Profile objects for pressure, iota, current, etc. Defaults to attributes of self data : dict of ndarray - Data computed so far, generally output from other compute functions + Data computed so far, generally output from other compute functions. + All vectors v = [vᴿ, v^ϕ, vᶻ] should be given in contravariant components + of the cylindrical basis coordinates R,ϕ,Z (shorthand is ``rpz``). override_grid : bool If True, override the user supplied grid if necessary and use a full resolution grid to compute quantities and then downsample to user requested diff --git a/desc/geometry/core.py b/desc/geometry/core.py index 3d39ffe85c..ff8975c52b 100644 --- a/desc/geometry/core.py +++ b/desc/geometry/core.py @@ -98,7 +98,9 @@ def compute( transforms : dict of Transform Transforms for R, Z, lambda, etc. Default is to build from grid data : dict of ndarray - Data computed so far, generally output from other compute functions + Data computed so far, generally output from other compute functions. + All vectors v = [vᴿ, v^ϕ, vᶻ] should be given in contravariant components + of the cylindrical basis coordinates R,ϕ,Z (shorthand is ``rpz``). override_grid : bool If True, override the user supplied grid if necessary and use a full resolution grid to compute quantities and then downsample to user requested diff --git a/desc/geometry/curve.py b/desc/geometry/curve.py index 4d7c5c6860..541b33ab81 100644 --- a/desc/geometry/curve.py +++ b/desc/geometry/curve.py @@ -717,7 +717,9 @@ def compute( transforms : dict of Transform Transforms for R, Z, lambda, etc. Default is to build from grid data : dict of ndarray - Data computed so far, generally output from other compute functions + Data computed so far, generally output from other compute functions. + All vectors v = [vᴿ, v^ϕ, vᶻ] should be given in contravariant components + of the cylindrical basis coordinates R,ϕ,Z (shorthand is ``rpz``). override_grid : bool If True, override the user supplied grid if necessary and use a full resolution grid to compute quantities and then downsample to user requested From 263a1b08eea93ccccd124ef4ac8efd1e87e348ae Mon Sep 17 00:00:00 2001 From: unalmis Date: Fri, 12 Jul 2024 00:51:52 -0400 Subject: [PATCH 2/3] See here for justification of changes: https://github.com/PlasmaControl/DESC/pull/1124/files#r1675232638 --- desc/compute/utils.py | 5 +++-- desc/equilibrium/equilibrium.py | 5 +++-- desc/geometry/core.py | 5 +++-- desc/geometry/curve.py | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/desc/compute/utils.py b/desc/compute/utils.py index f26517dcc9..9d5365fc69 100644 --- a/desc/compute/utils.py +++ b/desc/compute/utils.py @@ -54,8 +54,9 @@ def compute(parameterization, names, params, transforms, profiles, data=None, ** of self data : dict of ndarray Data computed so far, generally output from other compute functions. - All vectors v = [vᴿ, v^ϕ, vᶻ] should be given in contravariant components - of the cylindrical basis coordinates R,ϕ,Z (shorthand is ``rpz``). + Any vector v = v¹ R̂ + v² ϕ̂ + v³ Ẑ should be given in components + v = [v¹, v², v³] where R̂, ϕ̂, Ẑ are the normalized basis vectors + of the cylindrical coordinates R, ϕ, Z. Returns ------- diff --git a/desc/equilibrium/equilibrium.py b/desc/equilibrium/equilibrium.py index e250d4db5d..bfcd721716 100644 --- a/desc/equilibrium/equilibrium.py +++ b/desc/equilibrium/equilibrium.py @@ -812,8 +812,9 @@ def compute( of self data : dict of ndarray Data computed so far, generally output from other compute functions. - All vectors v = [vᴿ, v^ϕ, vᶻ] should be given in contravariant components - of the cylindrical basis coordinates R,ϕ,Z (shorthand is ``rpz``). + Any vector v = v¹ R̂ + v² ϕ̂ + v³ Ẑ should be given in components + v = [v¹, v², v³] where R̂, ϕ̂, Ẑ are the normalized basis vectors + of the cylindrical coordinates R, ϕ, Z. override_grid : bool If True, override the user supplied grid if necessary and use a full resolution grid to compute quantities and then downsample to user requested diff --git a/desc/geometry/core.py b/desc/geometry/core.py index ff8975c52b..a19b2b818e 100644 --- a/desc/geometry/core.py +++ b/desc/geometry/core.py @@ -99,8 +99,9 @@ def compute( Transforms for R, Z, lambda, etc. Default is to build from grid data : dict of ndarray Data computed so far, generally output from other compute functions. - All vectors v = [vᴿ, v^ϕ, vᶻ] should be given in contravariant components - of the cylindrical basis coordinates R,ϕ,Z (shorthand is ``rpz``). + Any vector v = v¹ R̂ + v² ϕ̂ + v³ Ẑ should be given in components + v = [v¹, v², v³] where R̂, ϕ̂, Ẑ are the normalized basis vectors + of the cylindrical coordinates R, ϕ, Z. override_grid : bool If True, override the user supplied grid if necessary and use a full resolution grid to compute quantities and then downsample to user requested diff --git a/desc/geometry/curve.py b/desc/geometry/curve.py index 541b33ab81..6217457586 100644 --- a/desc/geometry/curve.py +++ b/desc/geometry/curve.py @@ -718,8 +718,9 @@ def compute( Transforms for R, Z, lambda, etc. Default is to build from grid data : dict of ndarray Data computed so far, generally output from other compute functions. - All vectors v = [vᴿ, v^ϕ, vᶻ] should be given in contravariant components - of the cylindrical basis coordinates R,ϕ,Z (shorthand is ``rpz``). + Any vector v = v¹ R̂ + v² ϕ̂ + v³ Ẑ should be given in components + v = [v¹, v², v³] where R̂, ϕ̂, Ẑ are the normalized basis vectors + of the cylindrical coordinates R, ϕ, Z. override_grid : bool If True, override the user supplied grid if necessary and use a full resolution grid to compute quantities and then downsample to user requested From 1c6e191b593e80cf22d47e3135c283d1a9087773 Mon Sep 17 00:00:00 2001 From: unalmis Date: Fri, 12 Jul 2024 00:54:16 -0400 Subject: [PATCH 3/3] Same as commit 263a1b0 --- desc/compute/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/desc/compute/utils.py b/desc/compute/utils.py index 9d5365fc69..2147d41bbe 100644 --- a/desc/compute/utils.py +++ b/desc/compute/utils.py @@ -124,8 +124,9 @@ def _compute( ): """Same as above but without checking inputs for faster recursion. - All vectors v = [vᴿ, v^ϕ, vᶻ] in ``data`` should be given in contravariant - components of the cylindrical basis coordinates R,ϕ,Z (shorthand is ``rpz``). + Any vector v = v¹ R̂ + v² ϕ̂ + v³ Ẑ should be given in components + v = [v¹, v², v³] where R̂, ϕ̂, Ẑ are the normalized basis vectors + of the cylindrical coordinates R, ϕ, Z. We need to directly call this function in objectives, since the checks in above function are not compatible with JIT. This function computes given names while