Steve Roper

95 Reputation

2 Badges

2 years, 19 days

MaplePrimes Activity


These are questions asked by Steve Roper

I have noticed that fieldplot3d can fail when calling a procedure that contains if statements.  It appears that fieldplot3d is attempting to evaluate the statements within the procedure, instead of simply calling the procedure with numerical values.

We are still on lockdown in the UK, and this has kept me amused for a while now.  But I have run out of ideas and could really use some help!

fieldplot3d_and_if_statements.mw

I would like to be able to calculate 3D vector dot products using the spherical coordinate system, but so far I have not been sucessful.  A few suggestions would be greatly appreciated!

These are my failed attempts:
 

Calculating dot products using spherical coordinatesNULL

With Physics Vectors

 

with(Physics[Vectors])

Setup(mathematicalnotation = true)``

Setup(coordinatesystems = spherical)

[coordinatesystems = {X}]

(1.1)

k_ := _phi*c+_r*a+_theta*b

_phi*c+_r*a+_theta*b

(1.2)

k_.k_

a^2+b^2+c^2

(1.3)

I was hoping for the dot product to be calculated using the spherical coordinate system, but this is the cartesian dot product.

NULL

With Vector Calulus

 

restart

with(VectorCalculus)``

SetCoordinates('spherical'[r, phi, theta])

spherical[r, phi, theta]

(2.1)

``

k := VectorField([a, b, c], coords = spherical[r, phi, theta])

Vector(3, {(1) = a, (2) = b, (3) = c})

(2.2)

k.k

a^2+b^2+c^2

(2.3)

This is also the cartesian dot product.

NULL


 

Download Calculating_dot_products_using_spherical_coordinates.mw

I am looking for an elegant way in which to find a vector that is perpendicular to another vector.  The attached worksheet shows one method, but this can result in a divide by zero error.  I could write a procedure to detect and avoid the divide by zero error, but this feels like a sledgehammer to crack a nut :-)

Another method might be to rotate the vector by PI/2, but I'm not sure how to do this.

Any suggestions would be gratefully received!

Perpendicular_Vectors.mw

 

 

 

I'm attempting to use Maple to study Maxwell's Equations, but as a newbie to Maple, I quickly became stuck :-)

For some context, this link shows how it is possible to accomplish this using Mathematica:

https://www.wolfram.com/mathematica/new-in-10/inactive-objects/study-maxwells-equations.html

This is how I have attempted the same in Maple:

Maxwell's Equations

NULL

Initialise

 

restart

with(Physics[Vectors])

[`&x`, `+`, `.`, ChangeBasis, ChangeCoordinates, Component, Curl, DirectionalDiff, Divergence, Gradient, Identify, Laplacian, Nabla, Norm, Setup, diff]

(1.1)

Setup(mathematicalnotation = true)

[mathematicalnotation = true]

(1.2)

``

````

Maxwell's Equations

 

Maxwell_1 := Curl(E__field_(x, y, z, t)) = -(diff(B__flux_(x, y, z, t), t))

Physics:-Vectors:-Curl(E__field_(x, y, z, t)) = -(diff(B__flux_(x, y, z, t), t))

(2.1)

Maxwell_2 := Curl(H__field_(x, y, z, t)) = diff(D__flux_(x, y, z, t), t)

Physics:-Vectors:-Curl(H__field_(x, y, z, t)) = diff(D__flux_(x, y, z, t), t)

(2.2)

Maxwell_3 := Divergence(D__flux_(x, y, z, t)) = 0

Physics:-Vectors:-Divergence(D__flux_(x, y, z, t)) = 0

(2.3)

Maxwell_4 := Divergence(B__flux_(x, y, z, t)) = 0

Physics:-Vectors:-Divergence(B__flux_(x, y, z, t)) = 0

(2.4)

``

``

Constitutive Relations

 

Eq_1 := D__flux_(x, y, z, t) = epsilon*E__field_(x, y, z, t)

D__flux_(x, y, z, t) = varepsilon*E__field_(x, y, z, t)

(3.1)

Eq_2 := B__flux_(x, y, z, t) = mu*H__field_(x, y, z, t)

B__flux_(x, y, z, t) = mu*H__field_(x, y, z, t)

(3.2)

``

``

Solution

 

We need to get the Curl of H, to take the Curl of both side of Maxwell_1:

Curl(Maxwell_1)

Physics:-Vectors:-Curl(Physics:-Vectors:-Curl(E__field_(x, y, z, t))) = -Physics:-Vectors:-Curl(diff(B__flux_(x, y, z, t), t))

(4.1)

Now substitute B for H:

subs(Eq_2, %)

Physics:-Vectors:-Curl(Physics:-Vectors:-Curl(E__field_(x, y, z, t))) = -Physics:-Vectors:-Curl(diff(mu*H__field_(x, y, z, t), t))

(4.2)

OK, we manage to get Curl of H, so now we need to substitute the Curl of H with an expression in D.

subs(Maxwell_2, %)

Physics:-Vectors:-Curl(Physics:-Vectors:-Curl(E__field_(x, y, z, t))) = -mu*Physics:-Vectors:-Curl(diff(H__field_(x, y, z, t), t))

(4.3)

Well that didn't work, so try to seperate the Curl of H so that we can substitute for D.``

collect(%, Curl(H__field_(x, y, z, t)))

Physics:-Vectors:-Curl(Physics:-Vectors:-Curl(E__field_(x, y, z, t))) = -mu*Physics:-Vectors:-Curl(diff(H__field_(x, y, z, t), t))

(4.4)

simplify(%)

Physics:-Vectors:-Curl(Physics:-Vectors:-Curl(E__field_(x, y, z, t))) = -mu*Physics:-Vectors:-Curl(diff(H__field_(x, y, z, t), t))

(4.5)

collect(%, Curl(H__field_(x, y, z, t)))

Physics:-Vectors:-Curl(Physics:-Vectors:-Curl(E__field_(x, y, z, t))) = -mu*Physics:-Vectors:-Curl(diff(H__field_(x, y, z, t), t))

(4.6)

``

``

``

SortProducts(%, [H__field_(x, y, z, t)], totheleft)

SortProducts(Physics:-Vectors:-Curl(Physics:-Vectors:-Curl(E__field_(x, y, z, t))) = -mu*Physics:-Vectors:-Curl(diff(H__field_(x, y, z, t), t)), [H__field_(x, y, z, t)], totheleft)

(4.7)

``

``

``

``

``

isolate(%, H__field_(x, y, z, t))

SortProducts(Physics:-Vectors:-Curl(Physics:-Vectors:-Curl(E__field_(x, y, z, t))) = -mu*Physics:-Vectors:-Curl(diff(H__field_(x, y, z, t), t)), [H__field_(x, y, z, t)], totheleft) = 0

(4.8)

``

``

``

``

``

``

NULL

NULL

``

 

I need to be able to rearrange equation 4.3 so that I can substitute for Curl of H using Maxwell_2.  Any suggestions would be gratefully received!
 

Download Maxwells_Equations.mw

Page 1 of 1