In physics, we deal with two kinds of quantities – scalars and vectors.
A scalar is an entity which only has a magnitude – no direction. Examples of
scalar quantities include mass, electric charge, temperature, distance, etc.
A vector, on the other hand, is an entity that is characterized by a
magnitude and a direction. Examples of vector quantities are displacement,
velocity, magnetic field, etc.
A scalar can be depicted just by a number, for e.g. a temperature of 300 K.
On the other hand, vectorial quantities like acceleration are usually denoted
by a vector. Given a vector , the magnitude of the
corresponding quantity can be calculated as the magnitude of the vector
itself , while the direction would be specified
by a unit vector in the direction of the original vector,
.
For example, consider a displacement of
m,
where , as per standard convention, ,
and represent unit vectors
in the , and
directions respectively. Therefore, it can be concluded that the distance
traveled is
m = m. The direction of travel is given by the unit vector
.
In general, a is a vector or scalar quantity that can be
specified everywhere in space as a function of position (Note that in general
a field may also be dependent on time and other custom variables). In this
module, we deal with 3-dimensional spaces only. Hence, a field is defined as
a function of the , and coordinates corresponding
to a location in 3D space.
For example, temperate in 3 dimensional space (a temperature field) can be
written as – a scalar function of the position.
An example of a scalar field in electromagnetism is the electric potential.
In a similar manner, a vector field can be defined as a vectorial function
of the location of any point in space.
For instance, every point on the earth may be considered to be in the
gravitational force field of the earth. We may specify the field by the
magnitude and the direction of acceleration due to gravity
(i.e. force per unit mass ) at every point in space.
To give an example from electromagnetism, consider an electric potential
of form , a scalar field in 3D space. The corresponding
conservative electric field can be computed as the gradient of the electric
potential function, and expressed as .
The magnitude of this electric field can in turn be expressed
as a scalar field of the form
.
In sympy.physics.vector, every ReferenceFrame instance is
assigned basis vectors corresponding to the , and
directions. These can be accessed using the attributes named x, y and
z respectively. Hence, to define a vector of the form
with respect
to a given frame , you would do
Vector math and basic calculus operations with respect to vectors have
already been elaborated upon in other sections of this module’s
documentation.
On the other hand, base scalars (or coordinate variables) are implemented
as special SymPy Symbols assigned to every frame, one for each
direction from , and . For a frame
R, the , and
base scalar Symbols can be accessed using the R[0], R[1]
and R[2] expressions respectively.
Therefore, to generate the expression for the aforementioned electric
potential field , you would have to do
In string representation, R_x denotes the base
scalar assigned to ReferenceFrameR. Essentially, R_x is
the string representation of R[0].
Scalar fields can be treated just as any other SymPy expression, for any
math/calculus functionality. Hence, to differentiate the above electric
potential with respect to (i.e. R[0]), you would have to use the
diff function.
Like vectors (and vector fields), scalar fields can also be re-expressed in
other frames of reference, apart from the one they were defined in – assuming
that an orientation relationship exists between the concerned frames. This can
be done using the sympy.physics.vector.vector.Vector.express method, in a way
similar to vectors - but with the variables parameter set to
True.
Moreover, considering scalars can also be functions of time just as vectors,
differentiation with respect to time is also possible. Depending on the
Symbols present in the expression and the frame
with respect to which the time differentiation is being done, the output will
change/remain the same.
A curl is a mathematical operator that describes an infinitesimal rotation of a
vector in 3D space. The direction is determined by the right-hand rule (along the
axis of rotation), and the magnitude is given by the magnitude of rotation.
In the 3D Cartesian system, the curl of a 3D vector ,
denoted by is given by -
Consider a scalar field in 3D space. The gradient of this field
is defined as the vector of the 3 partial derivatives of with respect to
, and in the , and
directions respectively.
In the 3D Cartesian system, the gradient of a scalar field ,
denoted by is given by -
In vector calculus, a conservative field is a field that is the gradient of
some scalar field. Conservative fields have the property that their line
integral over any path depends only on the end-points, and is independent
of the path between them.
A conservative vector field is also said to be ‘irrotational’, since the
curl of a conservative field is always zero.
In physics, conservative fields represent forces in physical systems where
energy is conserved.
We have previously mentioned that every conservative field can be defined as
the gradient of some scalar field. This scalar field is also called the ‘scalar
potential field’ corresponding to the aforementioned conservative field.
The scalar potential difference, or simply ‘potential difference’,
corresponding to a conservative vector field can be defined as the difference
between the values of its scalar potential function at two points in space.
This is useful in calculating a line integral with respect to a conservative
function, since it depends only on the endpoints of the path.