MaplePrimes Posts are for sharing your experiences, techniques and opinions about Maple,
MapleSim and related products, as well as general interests in math and computing.

This post concerns the simulation of a physical system whose behavior is governed by ODEs.
It is likely that some people will think that all which follows is nothing but embellishments or a waste of time.
And in some sense they will be right.
I was thinking the same until I received some sharp remarks at the occasion of a few presentations of my works.
So experience has proven me that doing a presentation in front of project managers with only 2D curves often leads to smiles, not to speak about those who raise their eyes to heaven in front of the poverty of the slides.
Tired of this attitude, I decided to replace these 2D curves with a short film, which of course does not reveal more than what these 2D curves were already revealing, but which is pretty enough for the financing keeps going on.

For those of you who might regret this situation, just consider this work as a demonstration of the capabilities of Maple in 3D rendering.

PS: all the display outputs have been removed to avoid loading an unnecessary huge file.
The two last commands must be uncommented to play the animation.

Newton raphson method is used for optimization of functions and is based on taylor series expansion. Here is the code for a three level newton raphson method.

What are the things you most like to see improved/add to next version of Maple?

This is my list for a starter:

1. Improve the debugger. Debugger is very useful but needs more work. At least be able to see code listing in larger view as one steps in for example. See Matlab debugger for inspiration.

2. Improve Latex. It still does not do fractions well. Posted about this before.

3. Eliminate hangs when using timelimit(). On long runs, random hangs happen when timelimit() do not expire as requested. Posted about this before.

In the present work we are going to demonstrate the importance of the study of vector analysis, with modeling and simulation criteria, using the MapleSim scientific software from MapleSoft. Nowadays, the majority of higher education centers direct their teaching of vector analysis in an abstract way and there are few or no teachers who carry out applications using modeling and simulation. (In spanish)

We have just released an update to Maple, Maple 2020.1.1. This update includes the following:

Correction to a problem that occurred when printing or exporting documents to PDF. If the document included a 3-D plot, nearby text was sometimes missing from the printed/exported document.

Correction to an issue that prevented users from installing between-release updates to the Physics package

This update is available through Tools>Check for Updates in Maple, and is also available from our website on the Maple 2020.1.1 download page. If you are a MapleSim user, you can obtain this update from the corresponding MapleSim menu or MapleSim 2020.1.1 download page.

The strandbeest is a walking machine developed by Theo Jansen. Its cleverly designed legs consist of single-degree-of-freedom linkage mechanisms, actuated by the turning of a wind-powered crankshaft.

His working models are generally large - something of the order of the size of a bus. Look for videos on YouTube. Commercially made small toy models are also available. This one sells for under $10 and it's fun to assemble and works quite well. Beware that the kit consists of over 100 tiny pieces - so assembling it is not for the impatient type.

Here is a Maple worksheet that produces an animated strandbeest. Link lengths are taken from Theo Jansen's video (go to his site above and click on Explains) where he explains that he calculated the optimal link lengths by applying a genetic algorithm.

Here is a Maple animation of a single leg. The yellow disk represents the crankshaft.

And here are two legs working in tandem:

Here is the complete beest, running on six legs. The crankshaft turns at a constant angular velocity.

The toy model noted above runs on twelve legs for greater stability.

This may be of interest to anyone curious about why the effective area of an isotropic antenna is λ^2/4π.

Friis Transmission Equation

Initialise

The Hertzian Dipole antenna

The Hertzian Dipole is a conceptual antenna that carries a constant current along its length.

By laying a number of these small current elements end to end, it is possible to model a physical antenna (such as a half-wave dipole for example). But since we are only interested in obtaining an expression for the effective area of an Isotropic Antenna (in order to derive The Friis Transmission Equation) the Hertzian Dipole will be sufficient for our needs.

Maxwell's Equations

Since the purpose of a radio antenna is to either launch or to receive radio waves, we know that both the antenna, and the space surrounding the antenna, must satisfy Maxwell's Equations. We define Maxwell's Equations in terms of vector functions using spherical coordinates:

Maxwell–Faraday equation:

(3.1)

Ampère's circuital law (with Maxwell's addition):

(3.2)

Gauss' Law:

(3.3)

Gauss' Law for Magnetism:

(3.4)

Where:

E is the electric field strength [Volts/m]

H is the magnetic field strength [Amperes/m]

J is the current density (current per unit area) [Amperes/m^{2}]

ρ is the charge density (charge per unit volume) [Coulombs/m^{3}]

ε is Electric Permittivity

μ is Magnetic Permeability

Helmholtz decomposition

The Helmholtz Decomposition Theorem states that providing a vector field, (F) satisfies appropriate smoothness and decay conditions, it can be decomposed as the sum of components derived from a scalar field, (Φ) called the "scalar potential", and a vector field (A) called the "vector potential".

r is the vector from the origin to the observation point (P) at which we wish to know the scalar or vector potential.

r' is the vector from the origin to the source of the scalar or vector potential (i.e. a point on the Hertzian Dipole antenna).

V'·F(r') is the Divergence of the vector field (F) at source position r'.

V'×F(r') is the Curl of the vector field (F) at source position r'.

Calculating the Scalar Potential for the magnetic Field, H

We know that the Divergence of the magnetic field (H) is zero:

(4.1.1)

And so the magnetic field (H) must have a scalar vector potential of zero:

(4.1.2)

Calculating the Vector Potential for the magnetic Field, H

We know that the Curl of the magnetic field (H) is equal to the sum of current density (J) and the rate of change of the electric filled (E):

(4.2.1)

Since the Hertzian Dipole is a conductor, we need only concern ourselves with the current density (J) when calculating the vector potential (A). Integrating current density (J) over the volume of the antenna, is equivalent to integrating current along the length of the antenna (L).

We know that Maxwell's Equations can be solved for single frequency (monochromatic) fields, so we will excite our antenna with a single frequency current:

(4.2.2)

We can simplify the integral for the vector potential (A) by recognising that:

1.

Our observation point (P) will be a long way from the antenna and so (r) will be very large.

2.

The length of the antenna (L) will be very small and so (r') will be very small.

Since |r|>>|r'|, we can substitute |r-r'| with r.

Because we have decided that the observation point at r will be a long way from the antenna, we must allow for the fact that the observed antenna current will be delayed. The delay will be equal to the distance from the antenna to the observation point |r-r'| (which we have simplified to r), divided by the speed of light (c). The time delay will therefore be approximately equal to r/c and so the observed antenna current becomes:

(4.2.3)

Since the length, L of the antenna will be very small, we can assume that the current is in phase at all points along its length. Working in the Cartesian coordinate system, the final integral for the vector potential for the magnetic field is therefore:

(4.2.4)

We will now convert to the spherical coordinate system, which is more convenient when working with radio antenna radiation patterns:

The radial component of the observed current (and therefore vector potential), will be at a maximum when the observer is on the z-axis (that is when θ=0 or θ=π) and will be zero when the observer is in the x-y-plane:

(4.2.5)

The angular component of the observed current (and therefore vector potential), in the θ direction will be zero when the observer is on the z-axis (that is when θ=0 or θ=π) and will be at a maximum when the observer is in the x-y-plane:

(4.2.6)

Since the observed current (and therefore vector potential) flows along the z-axis, there will be no variation in the Ï• direction. That is to say, that varying Ï• will have no impact on the observed vector potential.

(4.2.7)

And so the vector potential for the magnetic field (H) expressed using spherical coordinate system is:

(4.2.8)

Calculating the Magnetic Field components

The Helmholtz Decomposition Theorem states that providing a vector field (F) satisfies appropriate smoothness and decay conditions, it can be decomposed as the sum of components derived from a scalar field (Φ) called "scalar potential", and a vector field (A) called the vector potential.

F = -VΦ + V×A

And so the magnetic field, H will be:

(4.3.1)

We see that the magnetic field comprises two components, one is inversely proportional to the distance from the antenna (r) and the other falls off with r^{2}. Since we are interested in the far-field radiation pattern for the antenna, we can ignore the r^{2} component and so the expression for the magnetic field reduces to:

(4.3.2)

We can further simplify by substituting ω/c for 2π/λ:

(4.3.3)

Calculating the Poynting Vector

We know that the magnitude of the Poynting Vector (S) can be calculated as the cross product of the electric field vector (E) and the magnetic field vector (H) :

S = -E x H which is analogous to a resistive circuit where power is the product of voltage and current: P=V*I.

We also know that the impedance of free space (Z) can be calculated as the ratio of the electric field (E) and magnetic field (H) vectors: Z= E /H =

This is analogous to a resistive circuit where resistance is the ratio of voltage and current: R=V/I.

This provides two more methods for calculating the Poynting Vector (S):

S = -E·E/Z which is analogous to a resistive circuit where power, P=V^{2}/R, and:

S = -H·H*Z which is analogous to a resistive circuit where power, P=I^{2}R.

Since we have obtained an expression for the magnetic field vector (H), we can derive an expression for the Poynting Vector (S):

(5.1)

We can separate out the time variable part to yield:

(5.2)

Where:

(5.3)

And we can visualise this radiation pattern using Maple's plotting tools:

So the Hertzian Dipole produces a electromagnetic radiation pattern with a pleasing doughnut shape :-)

Calculating Antenna Gain

We can calculate the total power radiated by the Hertzian Dipole by integrating the power flux density over all solid angles dΩ=sin(θ) dθ dφ. Since we have expressed power flux density in terms of watts per square meter, we multiply the solid angle by r^{2} to convert the solid angle expressed in steradians into an area expressed in m^{2}.

(6.1)

We can now use this power to calculate the power flux density that would be produced by an isotropic antenna by dividing the total transmitted power by the area of a sphere with radius r:

(6.2)

The Gain of the Hertzian Dipole is defined as the ratio between the maximum power flux density produced by the Hertzian Dipole and the maximum power flux density produced by the isotropic antenna:

(6.3)

Calculating Radiation Resistance

The input impedance of the Hertzian Dipole will have both a real and a reactive part. The reactive part will be associated with energy storage in the near field and will not contribute to the Poynting Vector in the far-field. For an ideal antenna (with no resistive power loss) the real part will be responsible for the radiated power:

(7.1)

(7.2)

Calculating the power received by a Hertzian Dipole

If an electromagnetic field (E) is incident on the Hertzian Dipole antenna, it will generate an Electro-Motive Force (EMF) at the antenna terminals. The EMF will be at a maximum when the transmitter is on the x-y-plane (that is when θ=π/2) and will be zero when the transmitter is on the z-axis.

For and incident E-field:

(8.1)

The z-axis component will be:

(8.2)

The z-axis component of the E-field will create an EMF at the antenna terminals that will draw charge out of the receiver to each tip of the antenna. We can calculate the work done per unit charge by integrating the z-axis component of (E) over the length of the antenna (L):

(8.3)

In order to extract the maximum possible power from the antenna, we will form a conjugate match between the impedance of the antenna and the load. This means that the load resistance must be the same as the radiation resistance of the antenna. The voltage developed across the load resistance will therefore be half of the open circuit EMF:

(8.4)

And so the power delivered to the load will be:

(8.5)

Calculating the Effective area of an Isotropic Antenna

We can also calculate the power received by the Hertzian Dipole by multiplying the power flux density arriving at the antenna with the effective area of an isotropic antenna and the gain of the Hertzian Dipole relative to an isotropic antenna:

(9.1)

We can express the incident power flux density in terms of electric field strength and wave impedance:

(9.2)

Rearranging, we obtain an expression for the effective area of the isotropic antenna:

(9.3)

The Friis Transmission Equation

We can calculate the power flux density that would be produced by an isotropic antenna at a distance r from the antenna by dividing the total transmitted power P_{tx} by the area of a sphere with radius r:

(10.1)

And so the power flux density that would be produced by an antenna with gain G_{tx} is:

(10.2)

We can calculate the power received by an isotropic antenna by multiplying the power flux density incident onto the antenna with the effective area of an isotropic antenna:

(10.3)

And so the power that would be received by an antenna with gain G_{rx} is:

(10.4)

The free space path loss is defined as the ratio between the received power and the transmitted power:

Question about deflection and vibration of beams occur with some regularity in this forum. Search for "beam" to see several pages of hits.

In this post I present a general approach to calculating the vibrational modes of a beam that applies to both single-span and multi-span beams. The code is not perfectly polished, but it is sufficiently documented to enable the interested user to modify/extend it as needed.

Vibrational modes of multi-span Euler-Bernoulli beams

through Krylov-Dunction functions

Rouben Rostamian 2020-07-19

>

restart;

Note: Maple defines the imaginary unit . We want to use the symbol as the beam's cross-sectional moment of inertia. Therefore we redefine the imaginary unit (for which we have no

use) as and free up the symbol for our use.

>

interface(imaginaryunit=II):

>

with(LinearAlgebra):

>

The Euler-Bernoulli beam equation .

We wish to determine the natural modes of vibration of

a possibly multi-span Euler-Bernoulli beam.

Separate the variables by setting . We get -

whence .

Let . Then

and

The idea behind the Krylov-Duncan technique is to express

in terms an alternative (and equivalent) set of basis functions through ,, as ,

where the functions through are defined in the next section.

In some literature the symbols , are used for these

functions but I find it more sensible to use the indexed function

notation.

The Krylov-Duncan approach is particularly effective in formulating and finding a multi-span beam's natural modes of vibration.

>

>

The Krylov-Duncan functions

The K[i](x) defined by this proc evaluates to the th

Krylov-Duncan function.

Normally the index will be in the set, however the proc is

set up to accept any integer index (positive or negative). The proc evaluates

the index modulo 4 to bring the index into the set . For

instance, K[5](x) and K[-3](x)i are equivalent to K[1](x) .

>

K := proc(x) local n := op(procname);

if not type(n, integer) then return 'procname'(args); else n := 1 + modp(n-1,4); # reduce n modulo 4 end if;

if n=1 then (cosh(x) + cos(x))/2; elif n=2 then (sinh(x) + sin(x))/2; elif n=3 then (cosh(x) - cos(x))/2; elif n=4 then (sinh(x) - sin(x))/2; else error "shouldn't be here!"; end if;

end proc:

Here are the Krylov-Duncan basis functions:

>

seq(print(cat(`K__`,i)(x) = K[i](x)), i=1..4);

and here is what they look like. All grow exponentially for large but are significantly different near the origin.

As noted earlier, in the case of a single-span beam, the modal shapes

are expressed as .

Then, due to the cyclic property of the derivatives of the Krylov-Duncan

functions, we see that: . . . Let us note, in particular, that , , , .

>

A general approach for solving multi-span beams

In a multi-span beam, we write for the deflection of the th span, where

and where is the span's length. The coordinate indicates the

location within the span, with corresponding to the span's left endpoint.

Thus, each span has its own coordinate system.

We assume that the interface of the two adjoining spans is supported on springs

which (a) resist transverse displacement proportional to the displacement (constant of

proportionality of (d for displacement), and (b) resist rotation proportional to the slope (constant of proportionality of (t fortorsion or twist). The spans are numbered

from left to right. The interface conditions between spans and +1 are

1.

The displacements at the interface match: .

2.

The slopes at the interface match (0).

3.

The difference of the moments just to the left and just to the right of the support is due to the torque exerted by the torsional spring:

4.

The difference of the shear forces just to the left and just to the right of the support is due to the force exerted by the linear spring:

The special case of a pinned support corresponds to and . In that case, condition 3 above implies that , and condition 4 implies that

Let us write the displacements and in terms of the Krylov-Duncan

functions as:

Then applying the cyclic properties of the Krylov-Duncan functions described

earlier, the four interface conditions translate to the following system of four equations involving the eight coefficients .

,

which we write as a matrix equation .

That coefficient matrix plays a central role in solving

for modal shapes of multi-span beams. Let's call it .

Note that the value of enters that matrix only in combinations with and . Therefore we introduce the new symbols

, .

The following proc generates the matrix . The parameters and

are optionaland are assigned the default values of infinity and zero, which

corresponds to a pinned support.

The % sign in front of each Krylov function makes the function inert, that is, it prevents it from expanding into trig functions. This is so that we can

see, visually, what our expressions look like in terms of the functions. To

force the evaluation of those inert function, we will apply Maple's value function,

Here is the interface matrix for a pinned support:

>

M_interface(mu, L);

And here is the interface matrix for a general springy support:

>

M_interface(mu, L, 'Kd'=a, 'Kt'=b);

Note: In Maple's Java interface, inert quantities are shown in gray.

Note: The in this matrix is the length of the span to the left of the interface. Recall that it is , not , in the derivation that leads to that matrix.

In a beam consisting of spans, we write the th span's deflection as

Solving the beam amounts to determining the unknowns

which we order as

At each of the interface supports we have a set of four equations as derived above, for a total of equations. Additionally, we have four user-supplied

boundary conditions -- two at the extreme left and two at the extreme right of the

overall beam. Thus, altogether we have equations which then we solve for the

unknown coefficients .

The user-supplied boundary conditions at the left end are two equations, each in the form of a linear combination of the coefficients . We write for the coefficient matrix of that set of equations. Similarly, the user-supplied boundary conditions at the right end are two equations, each in the form of a linear combination of the coefficients . We write for the coefficient matrix of that set of equations. Putting these equations together with those obtained at the interfaces,

we get a linear set of equations represented by a matrix which can be assembled

easily from the matrices , and . In the case of a 4-span beam the

assembled matrix looks like this:

The pattern generalizes to any number of spans in the obvious way.

For future use, here we record a few frequently occurring and matrices.

The following proc builds the overall matrix in the general case. It takes two or three arguments. The first two arguments are the matrices which are called and in the discussion above. If the beam consists of a single span, that's all the information that need be supplied. There is no need for the third argument.

In the case of a multi-span beam, in the third argument we supply the list of the interface matrices , as in , listed in order of the supports, from left to right. An empty list is also acceptable and is interpreted as having no internal supports, i.e., a single-span beam.

>

build_matrix := proc(left_bc::Matrix(2,4), right_bc::Matrix(2,4), interface_matrices::list) local N, n, i, M;

# n is the number of internal supports n := 0;

# adjust n if a third argument is supplied if _npassed = 3 then n := nops(interface_matrices); if n > 0 then for i from 1 to n do if not type(interface_matrices[i], 'Matrix(4,8)') then error "expected a 4x8 matrix for element %1 in the list of interface matrices", i; end if; end do; end if; end if;

N := n + 1; # number of spans

M := Matrix(4*N); M[1..2, 1..4] := left_bc; for i from 1 to n do M[4*i-1..4*i+2, 4*i-3..4*i+4] := interface_matrices[i]; end do; M[4*N-1..4*N, 4*N-3..4*N] := right_bc; return M; end proc:

For instance, for a single-span cantilever beam of length we get the following matrix:

>

build_matrix(M_left_clamped, M_right_free(mu,L));

For a two-span beam with with span lengths of and , and all three supports pinned, we get the following matrix:

The matrix represents a homogeneous linear system (i.e., the right-hand side vector

is zero.) To obtain a nonzero solution, we set the determinant of equal to zero.

That gives us a generally transcendental equation in the single unknown . Normally

the equation has infinitely many solutions. We call these

Remark: In the special case of pinned supports at the interfaces, that is, when , the matrix depends only on the span lengths . It is independent of the parameters that enter the Euler-Bernoulli equations. The frequencies , however, depend on those parameters.

This proc plots the calculated modal shape corresponding to the eigenvalue . The params argument is a set of equations which define the numerical values

of all the parameters that enter the problem's description, such as the span

lengths.

It is assumed that in a multi-span beam, the span lengths are named etc., and in a single-span beam, the length is named .

>

plot_beam := proc(M::Matrix,mu::realcons, params::set) local null_space, N, a_vals, i, j, A, B, P; eval(M, params); eval(%, :-mu=mu); value(%); #print(%); null_space := NullSpace(%); #print(%); if nops(null_space) <> 1 then error "Calculation failed. Increasing Digits and try again"; end if;

N := Dimension(M)[1]/4; # number of spans a_vals := convert([seq(seq(a[i,j], j=1..4), i=1..N)] =~ null_space[1], list);

if N = 1 then eval(add(a[1,j]*K[j](mu*x), j=1..4), a_vals); P[1] := plot(%, x=0..eval(L,params)); else A := 0; B := 0; for i from 1 to N do B := A + eval(L[i], params); eval(add(a[i,j]*K[j](mu*x), j=1..4), a_vals); eval(%, x=x-A): P[i] := plot(%, x=A..B); A := B; end do; unassign('i'); end if; plots:-display([P[i] $i=1..N]);

end proc:

>

A single-span pinned-pinned beam

Here we calculate the natural modes of vibration of a single span

beam, pinned at both ends. The modes are of the form

The matrix is:

>

M := build_matrix(M_left_pinned, M_right_pinned(mu,L));

The characteristic equation:

>

Determinant(M); eq := simplify(value(%)) = 0;

>

solve(eq, mu, allsolutions);

We conclude that the eigenvalues are .

A non-trivial solution of the system is in the null-space of :

>

eval(value(M), mu=n*Pi/L) assuming n::integer; N := NullSpace(%);

Here are the weights that go with the Krylov functions:

>

a_vals := convert([a[1,j] $j=1..4] =~ N[1], set);

and here is the deflection:

>

add(a[1,j]*K[j](mu*x), j=1..4); eval(%, a_vals); # plug in the a_vals calculated above eval(%, mu=n*Pi/L); # assert that n is an integer

We see that the shape functions are simple sinusoids.

>

>

A single-span free-free beam

Here we calculate the natural modes of vibration of a single span

beam, free at both ends. The modes are of the form .

The reasoning behind the calculations is very similar to that in the

previous section, therefore we don't comment on many details.

>

M := build_matrix(M_left_free, M_right_free(mu,L));