Message Boards Message Boards

0
|
5004 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

TranslationTransform a VectorPlot3D or a DensityPlot3D object?

Posted 6 years ago

Hi,

The question said it all. Graphics primitives can be GeometricTransformed as the heart desire, and display them with Graphics or Graphics3D. On the other hand the different available YourfavoritePlots are also graphic objects but I see now easy way to move them around. Translate and TranslationTransform for example does not work on the scalar or vector fields as they are working on graphics primitives. I am wondering if any manipulations of the different fields like translation and rotation is possible for them without doing a CoordinateTransform.

In particular I have a vector field fixed to the origo. I would like it to be fixed to the {x0,y0,z0} != {0,0,0} point. Simply by adding {x0,y0,z0} to the vector field does not give the desired result.

Thanks ahead, János

POSTED BY: Janos Lobb
2 Replies
Posted 6 years ago

Here is for example the magnetic scalar field:

(* Get the "magnetic scalar potential" *)

rbm = Entity["PhysicalSystem", "RectangularBarMagnet"][
   "MagneticScalarPotential"];

(* Make "magnetic scalar potential" Active and replace the \ subscripted parameter with a non-subscripted one *)

rbmmsp[m0_, a_, b_, c_, x_, y_, z_] := 
  Activate[rbm] //. 
   QuantityVariable[Subscript["M", 0], "Magnetization"] -> 
    QuantityVariable["m0", "Magnetization"];

(* Create the magnetic field *)

rbmmf[m0_, a_, b_, c_, x_, y_, 
   z_] := -D[
    rbmmsp[m0, a, b, c, x, y, 
     z], {{QuantityVariable["x", "Length"], 
      QuantityVariable["y", "Length"], 
      QuantityVariable["z", "Length"]}}];

(* Create the non-QuantityVariable /nqv/ magnetic field *)

nqvrbmmf[m0_, a_, b_, c_, x_, y_, z_ ] := 
 rbmmf[m0, a, b, c, x, y, 
   z] /. {QuantityVariable["m0", "Magnetization"] -> m0, 
   QuantityVariable["x", "Length"] -> x, 
   QuantityVariable["y", "Length"] -> y, 
   QuantityVariable["z", "Length"] -> z, 
   QuantityVariable["a", "Length"] -> a , 
   QuantityVariable["b", "Length"] -> b, 
   QuantityVariable["c", "Length"] -> c} 

Now the field can be displayed for example by ContourPlot3D as:

ContourPlot3D[
Evaluate[Norm[nqvrbmmf[mu0, a, b, c, x, y, z]]], {x, -1.5*a, 
5.5*a + 4*gap}, {y, -2*b, 2*b}, {z, -3.5*c, 1.5*c}, 
MaxRecursion -> 0, PlotPoints -> 30, 
Contours -> {10^2, 5*10^2, 10^3, 5*10^3, 10^4, 5*10^4, 10^5, 
2*10^5}, Mesh -> None, 
ContourStyle -> (Directive[Opacity[0.66], #1] &) /@ 
Table[ColorData["RedBlueTones"][xi], {xi, 1, 0, -1/16}], 
BoxRatios -> Automatic]// ReplaceAll[#, {mu0 -> 10^6, a -> 0.01, b -> 0.01, c -> 0.01, gap -> 0.001}] & // Quiet

enter image description here

or with VectorPlot3D:

VectorPlot3D[
    nqvrbmmf[mu0, a, b, c, x, y, z] , {x, -1.5*a, 
     5.5*a + 4*gap}, {y, -2*b, 2*b}, {z, -3.5*c, 1.5*c + R}, 
    VectorPoints -> {40, 20, 30}, BoxRatios -> Automatic, 
    Axes -> True, PlotLegends -> Automatic, 
    PlotRange -> {{-0.015, 0.059}, {-0.02, 0.02}, {-0.035, 0.115}}] //
    ReplaceAll[#, {mu0 -> 10^6, a -> 0.01, b -> 0.01, c -> 0.01, 
      gap -> 0.001, R -> 0.1}] & // Quiet 

enter image description here

Now, I can "move" this field for example by the z-axis up by replacing the "z" variable with "z-R" variable in the field signature and display with VectorPlot3D like this:

VectorPlot3D[
   nqvrbmmf[mu0, a, b, c, x, y, z - R] , {x, -1.5*a, 
    5.5*a + 4.0*gap}, {y, -2.0*b, 2.0*b}, {z, -3.5*c, 1.5*c + R}, 
   VectorPoints -> {40, 20, 30}, BoxRatios -> Automatic, Axes -> True,
    PlotLegends -> Automatic, 
   PlotRange -> {{-0.015, 0.059}, {-0.02, 0.02}, {-0.035, 0.115}}] // 
  ReplaceAll[#, {mu0 -> 10^6, a -> 0.01, b -> 0.01, c -> 0.01, 
     gap -> 0.001, R -> 0.1}] & // Quiet

enter image description here

My problem is that in further calculations then I always have to refer to "z-R" instead of just simple a "w". I would like to do something like this:

tnqvrbmmf = 
 TransformedField["Cartesian" -> "Cartesian", 
   nqvrbmmf[mu0, a, b, c, x, y, z], {x, y, z - R} -> {u, v, ww}] // 
  Simplify

But it is complaining that {x,y,-0.1+z} is not a non-empty list of valid variables and after some time crashing Mathematica death on.

POSTED BY: Janos Lobb

A relevant code snippet would help

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract