_Laplacian

it.grypho.scala.leonardo.vector._Laplacian
case class _Laplacian(e: _Expression, coords: Vector[_Variable], system: CoordinateSystem) extends _VectorOperator

laplacian(f, x, y, …) — the Laplacian of a scalar field, a scalar.

Defined as div(grad(f)) rather than as its own sum of second derivatives, so the two can never disagree. That definition is why the curvilinear systems needed no change here: composing the curvilinear grad and div yields (1/J)·Σᵢ ∂/∂qᵢ (J/hᵢ² · ∂f/∂qᵢ), which is exactly the general orthogonal-curvilinear Laplacian — a formula written out separately would have been a second definition to keep in step, and this one cannot drift.

A vector argument stays symbolic, and now for a load-bearing reason rather than a cautious one: outside Cartesian coordinates the vector Laplacian is not the component-wise scalar Laplacian (it is grad(div F) − curl(curl F)), so answering it by mapping this scalar formula over the components would be wrong in exactly the systems the curvilinear systems add.

Value parameters

coords

the ordered coordinate tuple

e

the scalar field

system

the coordinate system (only Cartesian evaluates)

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait _Expression
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def eval(env: Environment): Either[_Expression, _Value]

Reduces this expression in the given environment.

Reduces this expression in the given environment.

Value parameters

env

variable bindings and display precision

Attributes

Returns

Right(v) when all free variables resolved to concrete values; Left(e) when reduction is partial or impossible

Definition Classes
override def rebuild(c: List[_Expression]): _Expression

Reconstructs the same node shape with replacement sub-expressions.

Reconstructs the same node shape with replacement sub-expressions.

Value parameters

newChildren

replacements in the same order and count as children

Attributes

Definition Classes

Inherited methods

override def children: List[_Expression]

Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.

Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.

Attributes

Definition Classes
Inherited from:
_VectorOperator
protected def column(cs: Vector[_Expression]): _Matrix

Builds a column vector from its components, simplified.

Builds a column vector from its components, simplified.

Attributes

Inherited from:
_VectorOperator
protected def componentsOf(x: _Expression, env: Environment): Option[Vector[_Expression]]

Reads e as an n×1 vector field: its components, or None when it is not one.

Reads e as an n×1 vector field: its components, or None when it is not one.

A literal matrix is read without evaluating it, and that ordering is load-bearing: the components must be differentiated before any point is substituted. Evaluating first would collapse [[x^2], [y^3]] to a dense _MatrixValue as soon as the coordinates happen to be bound — every cell a constant, every derivative zero, and a confidently wrong answer rather than a refusal.

Only a non-literal argument is evaluated, which covers the variable-bound-to-a-matrix case (the general lesson that matrix-vs-scalar cannot always be decided at parse time). An Environment holds _Values, so such a binding is necessarily a dense _MatrixValue: its cells are constants and their derivatives are legitimately zero.

A field is a column (n×1); a row vector is a different object and is refused.

Attributes

Inherited from:
_VectorOperator
protected def d(x: _Expression, i: Int): _Expression

∂x/∂coords(i), simplified.

∂x/∂coords(i), simplified.

Attributes

Inherited from:
_VectorOperator
protected def h: Vector[_Expression]

The scale factors, or an empty vector when the request is ill-posed (guarded by wellPosed at every use site).

The scale factors, or an empty vector when the request is ill-posed (guarded by wellPosed at every use site).

Attributes

Inherited from:
_VectorOperator
protected def handedness: Int

Orientation of the ordered basis: +1 right-handed, -1 left-handed.

Orientation of the ordered basis: +1 right-handed, -1 left-handed.

Only curl reads this, and it must. The curl formula below is derived for a right-handed (q₁, q₂, q₃); SphericalMaths exchanges the last two coordinates of Spherical, and swapping two basis vectors flips the orientation, so the same formula returns −curl there. grad, div and laplacian involve no cross product and are orientation-free, which is why the sign lives here rather than in each operator.

Attributes

Inherited from:
_VectorOperator
protected def jacobianFactor: _Expression

The Jacobian factor h₁·h₂·…, the volume element's coefficient.

The Jacobian factor h₁·h₂·…, the volume element's coefficient.

Attributes

Inherited from:
_VectorOperator
def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product
protected def scaleFactors: Option[Vector[_Expression]]

The scale factors (h₁, h₂, …) for this coordinate system and tuple.

The scale factors (h₁, h₂, …) for this coordinate system and tuple.

Every operator below is written once, in terms of these; Cartesian is the h = 1 case, which is why generalising the formulas left its results untouched. None when the system cannot describe this tuple — cylindrical and spherical are three-dimensional, and a request in any other arity is refused rather than answered in the wrong geometry.

Attributes

Inherited from:
_VectorOperator
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Inherited from:
_VectorOperator
protected def total(terms: Vector[_Expression]): _Expression

Sums a list of terms, folding to 0 when empty.

Sums a list of terms, folding to 0 when empty.

Attributes

Inherited from:
_VectorOperator
protected def wellPosed: Boolean

True when the request is one this tier can answer at all: a coordinate tuple with no repeats, in an arity the coordinate system supports. grad(f, x, x) names no basis and is refused rather than silently producing a duplicated component.

True when the request is one this tier can answer at all: a coordinate tuple with no repeats, in an arity the coordinate system supports. grad(f, x, x) names no basis and is refused rather than silently producing a duplicated component.

Attributes

Inherited from:
_VectorOperator

Inherited fields

lazy val freeVars: Set[String]

Cached set of free variable names; O(1) after the first access.

Cached set of free variable names; O(1) after the first access.

Attributes

Inherited from:
_Expression