Magnetics: Fields, Derivatives, and Phasors

Sample fields and calculate gradients, divergence, curl, and Laplacians. Use phasors to calculate the Poynting vector and Joule losses.

Choose operators for your field

Use a scalar field for the gradient and Laplacian, and a vector field for divergence and curl. Specify the axes, component order, and query points. In the time-averaged power calculation, the phasor convention conjugates the second field. Pass the complete complex phasor.

Operation reference

Jump to an operation

field.magnitude

B contains the field components along the component axis, with shape N×3 for a list of points. The operation returns √Σ|component|² in the same units.

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Regular grid axes, N × 3 matrix, or 4D vector tensor (regular_axes_or_N_by_3_or_4D_vector)
Units
Input field units, W/m² for power density
Result
Numerical and diagnostic fields
Purpose
Vector field magnitude
gxtxt_api_call("MAGNETICS_API_v1", "field.magnitude", args)
Recorded result · field.magnitude

Download the example script (ZIP).

Example operands preview

[
  {
    "kind": "empty"
  },
  {
    "kind": "array",
    "shape": [
      2,
      3
    ],
    "real": [
      1.0,
      0.0,
      2.0,
      2.0,
      0.0,
      1.0
    ],
    "imaginary": [
      1.0,
      0.0,
      0.0,
      0.0,
      0.0,
      -1.0
    ]
  },
  {
    "kind": "empty"
  }
]

Result preview

{
  "magnitude": {
    "dtype": "float64",
    "shape": [
      2,
      1
    ],
    "values": [
      2.449489742783178,
      2.449489742783178
    ]
  }
}

field.phasor

B contains the complex field. Compare the magnitude and phase of each component by reconstructing the value from its real and imaginary parts.

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Regular grid axes, N × 3 matrix, or 4D vector tensor (regular_axes_or_N_by_3_or_4D_vector)
Units
Input field units, W/m² for power density
Result
Numerical and diagnostic fields
Purpose
Phasor representation of the field
gxtxt_api_call("MAGNETICS_API_v1", "field.phasor", args)
Recorded result · field.phasor

Download the example script (ZIP).

Example operands preview

[
  {
    "kind": "empty"
  },
  {
    "kind": "array",
    "shape": [
      2,
      3
    ],
    "real": [
      1.0,
      0.0,
      2.0,
      2.0,
      0.0,
      1.0
    ],
    "imaginary": [
      1.0,
      0.0,
      0.0,
      0.0,
      0.0,
      -1.0
    ]
  },
  {
    "kind": "empty"
  }
]

Result preview

{
  "magnitude": {
    "dtype": "float64",
    "shape": [
      2,
      1
    ],
    "values": [
      2.449489742783178,
      2.449489742783178
    ]
  },
  "phase_rad": {
    "dtype": "float64",
    "shape": [
      2,
      3
    ],
    "values": [
      0.7853981633974483,
      0.0,
      0.0,
      0.0,
      0.0,
      -0.7853981633974483
    ]
  },
  "real": {
    "dtype": "float64",
    "shape": [
      2,
      3
    ],
    "values": [
      1.0,
      0.0,
      2.0,
      2.0,
      0.0,
      1.0
    ]
  },
  "imaginary": {
    "dtype": "float64",
    "shape": [
      2,
      3
    ],
    "values": [
      1.0,
      0.0,
      0.0,
      0.0,
      0.0,
      -1.0
    ]
  },
  "conjugate_real": {
    "dtype": "float64",
    "shape": [
      2,
      3
    ],
    "values": [
      1.0,
      0.0,
      2.0,
      2.0,
      0.0,
      1.0
    ]
  },
  "conjugate_imaginary": {
    "dtype": "float64",
    "shape": [
      2,
      3
    ],
    "values": [
      -1.0,
      -0.0,
      -0.0,
      -0.0,
      -0.0,
      1.0
    ]
  }
}

field.normal_component

B contains the vectors and C the normals. The operation normalizes nonzero normals and also returns the tangential component.

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Regular grid axes, N × 3 matrix, or 4D vector tensor (regular_axes_or_N_by_3_or_4D_vector)
Units
Input field units, W/m² for power density
Result
Numerical and diagnostic fields
Purpose
Normal component of the field
gxtxt_api_call("MAGNETICS_API_v1", "field.normal_component", args)
Recorded result · field.normal_component

Download the example script (ZIP).

Example operands preview

[
  {
    "kind": "empty"
  },
  {
    "kind": "array",
    "shape": [
      2,
      3
    ],
    "real": [
      1.0,
      0.0,
      2.0,
      2.0,
      0.0,
      1.0
    ],
    "imaginary": [
      1.0,
      0.0,
      0.0,
      0.0,
      0.0,
      -1.0
    ]
  },
  {
    "kind": "array",
    "shape": [
      2,
      3
    ],
    "real": [
      0.0,
      0.0,
      0.0,
      1.0,
      1.0,
      0.0
    ]
  }
]

Result preview

{
  "value_real": {
    "dtype": "float64",
    "shape": [
      2,
      1
    ],
    "values": [
      0.0,
      2.0
    ]
  },
  "value_imaginary": {
    "dtype": "float64",
    "shape": [
      2,
      1
    ],
    "values": [
      0.0,
      0.0
    ]
  },
  "tangential_real": {
    "dtype": "float64",
    "shape": [
      2,
      3
    ],
    "values": [
      1.0,
      0.0,
      2.0,
      0.0,
      0.0,
      1.0
    ]
  },
  "tangential_imaginary": {
    "dtype": "float64",
    "shape": [
      2,
      3
    ],
    "values": [
      1.0,
      0.0,
      0.0,
      0.0,
      0.0,
      -1.0
    ]
  }
}

field.sample

A is the cell containing the grid axes, B is the field, and C contains the query coordinates. Keep the query points within the grid domain.

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Regular grid axes, N × 3 matrix, or 4D vector tensor (regular_axes_or_N_by_3_or_4D_vector)
Units
Input field units, W/m² for power density
Result
Numerical and diagnostic fields
Purpose
Field sampling at query points
gxtxt_api_call("MAGNETICS_API_v1", "field.sample", args)
Recorded result · field.sample

Download the example script (ZIP).

Example operands preview

[
  {
    "kind": "cell",
    "shape": [
      1,
      3
    ],
    "items": [
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      },
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      },
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      }
    ]
  },
  {
    "kind": "array",
    "shape": [
      3,
      3,
      3,
      3
    ],
    "real": [
      0.0,
      1.0,
      3.0,
      0.0,
      1.0,
      3.0,
      0.0,
      1.0,
      3.0,
      0.0
    ]
  },
  {
    "kind": "array",
    "shape": [
      1,
      3
    ],
    "real": [
      0.5,
      0.5,
      0.5
    ]
  }
]

Result preview

{
  "component1_real": 0.5,
  "component1_imaginary": 0.0,
  "component2_real": 0.5,
  "component2_imaginary": 0.0,
  "component3_real": 0.5,
  "component3_imaginary": 0.0
}

field.gradient

A contains the axes and B the scalar field. The result gives derivatives in the physical coordinate directions, in field units per coordinate unit.

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Regular grid axes, N × 3 matrix, or 4D vector tensor (regular_axes_or_N_by_3_or_4D_vector)
Units
Input field units, W/m² for power density
Result
Numerical and diagnostic fields
Purpose
Scalar field gradient
gxtxt_api_call("MAGNETICS_API_v1", "field.gradient", args)
Recorded result · field.gradient

Download the example script (ZIP).

Example operands preview

[
  {
    "kind": "cell",
    "shape": [
      1,
      3
    ],
    "items": [
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      },
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      },
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      }
    ]
  },
  {
    "kind": "array",
    "shape": [
      3,
      3,
      3
    ],
    "real": [
      0.0,
      1.0,
      3.0,
      2.0,
      3.0,
      5.0,
      6.0,
      7.0,
      9.0,
      3.0
    ]
  },
  {
    "kind": "empty"
  }
]

Result preview

{
  "axis1_real": {
    "dtype": "float64",
    "shape": [
      3,
      3,
      3
    ],
    "values": [
      1.0,
      1.0,
      1.0,
      1.0,
      1.0,
      1.0,
      1.0,
      1.0,
      1.0,
      1.0,
      1.0,
      1.0
    ]
  },
  "axis1_imaginary": {
    "dtype": "float64",
    "shape": [
      3,
      3,
      3
    ],
    "values": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  },
  "axis2_real": {
    "dtype": "float64",
    "shape": [
      3,
      3,
      3
    ],
    "values": [
      2.0,
      2.0,
      2.0,
      2.0,
      2.0,
      2.0,
      2.0,
      2.0,
      2.0,
      2.0,
      2.0,
      2.0
    ]
  },
  "axis2_imaginary": {
    "dtype": "float64",
    "shape": [
      3,
      3,
      3
    ],
    "values": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  },
  "axis3_real": {
    "dtype": "float64",
    "shape": [
      3,
      3,
      3
    ],
    "values": [
      3.0,
      3.0,
      3.0,
      3.0,
      3.0,
      3.0,
      3.0,
      3.0,
      3.0,
      3.0,
      3.0,
      3.0
    ]
  },
  "axis3_imaginary": {
    "dtype": "float64",
    "shape": [
      3,
      3,
      3
    ],
    "values": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  }
}

field.divergence

A contains the axes and B the vector field with a last dimension of size 3. The operation sums the derivatives of the corresponding components.

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Regular grid axes, N × 3 matrix, or 4D vector tensor (regular_axes_or_N_by_3_or_4D_vector)
Units
Input field units, W/m² for power density
Result
Numerical and diagnostic fields
Purpose
Vector field divergence
gxtxt_api_call("MAGNETICS_API_v1", "field.divergence", args)
Recorded result · field.divergence

Download the example script (ZIP).

Example operands preview

[
  {
    "kind": "cell",
    "shape": [
      1,
      3
    ],
    "items": [
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      },
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      },
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      }
    ]
  },
  {
    "kind": "array",
    "shape": [
      3,
      3,
      3,
      3
    ],
    "real": [
      0.0,
      1.0,
      3.0,
      0.0,
      1.0,
      3.0,
      0.0,
      1.0,
      3.0,
      0.0
    ]
  },
  {
    "kind": "empty"
  }
]

Result preview

{
  "value_real": {
    "dtype": "float64",
    "shape": [
      3,
      3,
      3
    ],
    "values": [
      3.0,
      3.0,
      3.0,
      3.0,
      3.0,
      3.0,
      3.0,
      3.0,
      3.0,
      3.0,
      3.0,
      3.0
    ]
  },
  "value_imaginary": {
    "dtype": "float64",
    "shape": [
      3,
      3,
      3
    ],
    "values": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  }
}

field.curl

A contains the axes and B the vector field. Use the handedness of the basis when interpreting the curl components.

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Regular grid axes, N × 3 matrix, or 4D vector tensor (regular_axes_or_N_by_3_or_4D_vector)
Units
Input field units, W/m² for power density
Result
Numerical and diagnostic fields
Purpose
Vector field curl
gxtxt_api_call("MAGNETICS_API_v1", "field.curl", args)
Recorded result · field.curl

Download the example script (ZIP).

Example operands preview

[
  {
    "kind": "cell",
    "shape": [
      1,
      3
    ],
    "items": [
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      },
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      },
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      }
    ]
  },
  {
    "kind": "array",
    "shape": [
      3,
      3,
      3,
      3
    ],
    "real": [
      0.0,
      1.0,
      3.0,
      0.0,
      1.0,
      3.0,
      0.0,
      1.0,
      3.0,
      0.0
    ]
  },
  {
    "kind": "empty"
  }
]

Result preview

{
  "value_real": {
    "dtype": "float64",
    "shape": [
      3,
      3,
      3,
      3
    ],
    "values": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  },
  "value_imaginary": {
    "dtype": "float64",
    "shape": [
      3,
      3,
      3,
      3
    ],
    "values": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  }
}

field.dot

A and B are fields with matching component shapes. The operation conjugates the first operand. The result is in the product of the input units.

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Regular grid axes, N × 3 matrix, or 4D vector tensor (regular_axes_or_N_by_3_or_4D_vector)
Units
Input field units, W/m² for power density
Result
Numerical and diagnostic fields
Purpose
Hermitian inner product of three-component complex fields
gxtxt_api_call("MAGNETICS_API_v1", "field.dot", args)
Recorded result · field.dot

Download the example script (ZIP).

Example operands preview

[
  {
    "kind": "array",
    "shape": [
      2,
      3
    ],
    "real": [
      1.0,
      0.0,
      2.0,
      2.0,
      0.0,
      1.0
    ],
    "imaginary": [
      1.0,
      0.0,
      0.0,
      0.0,
      0.0,
      -1.0
    ]
  },
  {
    "kind": "array",
    "shape": [
      2,
      3
    ],
    "real": [
      1.0,
      0.0,
      2.0,
      2.0,
      0.0,
      1.0
    ],
    "imaginary": [
      1.0,
      0.0,
      0.0,
      0.0,
      0.0,
      -1.0
    ]
  },
  {
    "kind": "empty"
  }
]

Result preview

{
  "value_real": {
    "dtype": "float64",
    "shape": [
      2,
      1
    ],
    "values": [
      6.0,
      6.0
    ]
  },
  "value_imaginary": {
    "dtype": "float64",
    "shape": [
      2,
      1
    ],
    "values": [
      0.0,
      0.0
    ]
  }
}

field.cross

A and B are three-component fields. Operand order determines the direction of the cross product.

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Regular grid axes, N × 3 matrix, or 4D vector tensor (regular_axes_or_N_by_3_or_4D_vector)
Units
Input field units, W/m² for power density
Result
Numerical and diagnostic fields
Purpose
Cross product of three-component fields
gxtxt_api_call("MAGNETICS_API_v1", "field.cross", args)
Recorded result · field.cross

Download the example script (ZIP).

Example operands preview

[
  {
    "kind": "array",
    "shape": [
      2,
      3
    ],
    "real": [
      1.0,
      0.0,
      2.0,
      2.0,
      0.0,
      1.0
    ],
    "imaginary": [
      1.0,
      0.0,
      0.0,
      0.0,
      0.0,
      -1.0
    ]
  },
  {
    "kind": "array",
    "shape": [
      2,
      3
    ],
    "real": [
      1.0,
      0.0,
      2.0,
      2.0,
      0.0,
      1.0
    ],
    "imaginary": [
      1.0,
      0.0,
      0.0,
      0.0,
      0.0,
      -1.0
    ]
  },
  {
    "kind": "empty"
  }
]

Result preview

{
  "value_real": {
    "dtype": "float64",
    "shape": [
      2,
      3
    ],
    "values": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  },
  "value_imaginary": {
    "dtype": "float64",
    "shape": [
      2,
      3
    ],
    "values": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  }
}

field.time_average_power

A and B are the two fields used to calculate average power. Use the conjugated product for phasors and read the real part for time-averaged active power.

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Regular grid axes, N × 3 matrix, or 4D vector tensor (regular_axes_or_N_by_3_or_4D_vector)
Units
Input field units, W/m² for power density
Result
Numerical and diagnostic fields
Purpose
Complex Poynting vector and active and reactive power densities
gxtxt_api_call("MAGNETICS_API_v1", "field.time_average_power", args)
Recorded result · field.time_average_power

Download the example script (ZIP).

Example operands preview

[
  {
    "kind": "array",
    "shape": [
      2,
      3
    ],
    "real": [
      1.0,
      0.0,
      2.0,
      2.0,
      0.0,
      1.0
    ],
    "imaginary": [
      1.0,
      0.0,
      0.0,
      0.0,
      0.0,
      -1.0
    ]
  },
  {
    "kind": "array",
    "shape": [
      2,
      3
    ],
    "real": [
      0.0,
      0.0,
      0.0,
      1.0,
      1.0,
      0.0
    ]
  },
  {
    "kind": "empty"
  }
]

Result preview

{
  "value_real": {
    "dtype": "float64",
    "shape": [
      2,
      3
    ],
    "values": [
      1.0,
      -0.5,
      -0.5,
      0.0,
      0.0,
      0.0
    ]
  },
  "value_imaginary": {
    "dtype": "float64",
    "shape": [
      2,
      3
    ],
    "values": [
      -0.0,
      0.5,
      -0.5,
      -0.0,
      0.0,
      0.0
    ]
  },
  "active_power_density": {
    "dtype": "float64",
    "shape": [
      2,
      3
    ],
    "values": [
      1.0,
      -0.5,
      -0.5,
      0.0,
      0.0,
      0.0
    ]
  },
  "reactive_power_density": {
    "dtype": "float64",
    "shape": [
      2,
      3
    ],
    "values": [
      -0.0,
      0.5,
      -0.5,
      -0.0,
      0.0,
      0.0
    ]
  },
  "unit": "W/m^2"
}

field.laplacian

A contains the axes and B the scalar field. The result is the sum of the second derivatives, in field units per distance squared.

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Regular grid axes, N × 3 matrix, or 4D vector tensor (regular_axes_or_N_by_3_or_4D_vector)
Units
Input field units, W/m² for power density
Result
Numerical and diagnostic fields
Purpose
Laplacian of a 3D scalar field on a nonuniform grid
gxtxt_api_call("MAGNETICS_API_v1", "field.laplacian", args)
Recorded result · field.laplacian

Download the example script (ZIP).

Example operands preview

[
  {
    "kind": "cell",
    "shape": [
      1,
      3
    ],
    "items": [
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      },
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      },
      {
        "kind": "array",
        "shape": [
          3,
          1
        ],
        "real": [
          0.0,
          1.0,
          3.0
        ]
      }
    ]
  },
  {
    "kind": "array",
    "shape": [
      3,
      3,
      3
    ],
    "real": [
      0.0,
      1.0,
      9.0,
      1.0,
      2.0,
      10.0,
      9.0,
      10.0,
      18.0,
      1.0
    ]
  },
  {
    "kind": "empty"
  }
]

Result preview

{
  "value_real": {
    "dtype": "float64",
    "shape": [
      3,
      3,
      3
    ],
    "values": [
      6.0,
      6.0,
      6.0,
      6.0,
      6.0,
      6.0,
      6.0,
      6.0,
      6.0,
      6.0,
      6.0,
      6.0
    ]
  },
  "value_imaginary": {
    "dtype": "float64",
    "shape": [
      3,
      3,
      3
    ],
    "values": [
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0,
      0.0
    ]
  }
}

field.joule_loss

A is E and B is the current density J. When using peak-amplitude phasors, set phasor to obtain the time average.

Access
Registered in the Python Job
Arguments
Typed operands a, b, and c, with an optional typed options struct.
Shape
Regular grid axes, N × 3 matrix, or 4D vector tensor (regular_axes_or_N_by_3_or_4D_vector)
Units
Input field units, W/m² for power density
Result
Numerical and diagnostic fields
Purpose
Joule loss density from E and J
gxtxt_api_call("MAGNETICS_API_v1", "field.joule_loss", args)
Recorded result · field.joule_loss

Download the example script (ZIP).

Example operands preview

[
  {
    "kind": "array",
    "shape": [
      2,
      3
    ],
    "real": [
      1.0,
      0.0,
      2.0,
      2.0,
      0.0,
      1.0
    ],
    "imaginary": [
      1.0,
      0.0,
      0.0,
      0.0,
      0.0,
      -1.0
    ]
  },
  {
    "kind": "array",
    "shape": [
      2,
      3
    ],
    "real": [
      1.0,
      0.0,
      2.0,
      2.0,
      0.0,
      1.0
    ],
    "imaginary": [
      1.0,
      0.0,
      0.0,
      0.0,
      0.0,
      -1.0
    ]
  },
  {
    "kind": "empty"
  },
  {
    "kind": "struct",
    "fields": {
      "phasor": {
        "kind": "array",
        "shape": [
          1,
          1
        ],
        "real": [
          1
        ]
      }
    }
  }
]

Result preview

{
  "loss_density": {
    "dtype": "float64",
    "shape": [
      2,
      1
    ],
    "values": [
      3.0,
      3.0
    ]
  },
  "unit": "W/m^3"
}