POV-Ray : Newsgroups : povray.newusers : How to: Sphere with 3D Electric Field Lines : Re: How to: Sphere with 3D Electric Field Lines Server Time
27 Apr 2024 16:15:15 EDT (-0400)
  Re: How to: Sphere with 3D Electric Field Lines  
From: Johann
Date: 27 Sep 2014 11:40:00
Message: <web.5426d96c266802cb16298ca60@news.povray.org>
> Hi Johann,
>
> I don't have a simple method for the field lines, but perhaps the
> following code makes for a start on the contours. Field lines would
> intersect in a fashion perpendicular to the contours so I can sort of
> see complicated methods to come up with them, but nothing which fits in
> the time I can spend at the moment.
>
> Bill P.

Thanks Bill for your proposal! Just a few minutes ago POV RAY started to render
the image and it took about 14 minutes for 320x240 AA 0.3. I believe that what I
am looking for is relative easy and not so complicated.

I completely understand how bothersome is when someone asks for a solution to
his problem without even to know how to use the tool. Therefore, I would like to
help on this direction. Below I have two sample codes, I found on the Internet
which need to be tweaked by someone with knowledge to give the expected result:

Example Nr.1:
// it creates a sphere with 200 random electric field lines
// it seems on the below code the electric field formula E=KQ/r^2 is not used
and instead it creates random lines around the sphere surface
#include "colors.inc"
light_source { <10,0,-1> color White shadowless }
light_source { <0,0,-10> color White shadowless }
camera {location <2,2,-5> look_at <0,0,0> }
sphere { <0,0,0>,0.4 pigment {Red} }
#declare R1=seed(0);
#declare R=2.5;
#declare c=0;
#while(c <= 300)
 #declare theta=pi*rand(R1);
#declare phi=2.0*pi*rand(R1);
#declare xp=R*sin(theta)*cos(phi);
#declare yp=R*sin(theta)*sin(phi);
#declare zp=R*cos(theta);
cylinder {<0,0,0>,<xp,yp,zp>,0.01 pigment {Orange}}
#declare c=c+1;
#end

If we could modify the above that will include clearly the electric field
formula (if possible to show field line direction), it will be of great help.
Then the second sample I need, it will be two spheres interacting with their
fields.

Example Nr.2 (Brilliant work by Paul Nylander):
//******************************************************************************************
//* Magnetic Field of a Solenoid, copyright by Paul Nylander, bugman123.com,
5/17/06
//* runtime: 1 minute
//******************************************************************************************

#declare mu0=1.25663706144e-6; #declare n=6; #declare R=0.01; #declare
dL=(4/3)*R; #declare r=R/4;
camera{location <13.65,0,16.25>*R look_at 0.4*R*x up -y right
x*image_width/image_height sky -y angle 25}
light_source{<0,0,8*R>,1}

//Solenoid
#include "golds.inc"
#declare begin=1; #declare x1=(0.25-n/2)*dL;
#while(x1<=(n/2-0.25)*dL)
 #declare theta=2*pi*(x1/dL+n/2); #declare p2=<x1,R*sin(theta),-R*cos(theta)>;
 sphere{p2,r texture{T_Gold_5A}} #if(!begin) cylinder{p1,p2,r
texture{T_Gold_1A}} #end
 #declare begin=0; #declare p1=p2; #declare x1=x1+0.005*dL;
#end

//Electromagnetic Field
#declare Sqr=function(X) {X*X};
#declare sign=function(i1) {1-2*floor(2*mod((i1-1)/2,n)/n)}; // i1<n1?1:-1
#declare I=function(i1) {sign(i1)}; // current
#declare xcoil=function(i1)
{(4/3)*R*(mod(i1-1,n)+0.5*floor(2*mod((i1-1)/2,n)/n)-0.5*(n-0.5))};
#declare B=function{(mu0/(2*pi))*sqrt( // magnetic field magnitude
 Sqr(sum(i1,1,2*n,I(i1)*(y-sign(i1)*R)/(Sqr(x-xcoil(i1))+Sqr(y-sign(i1)*R))))+
 Sqr(sum(i1,1,2*n,I(i1)*(x-xcoil(i1))/(Sqr(x-xcoil(i1))+Sqr(y-sign(i1)*R))))
)}
#declare
contours=function{(2+cos(0.06*pi*(sum(i1,1,2*n,I(i1)/sqrt(Sqr(x-xcoil(i1))+Sqr(y-sign(i1)*R))))))/3}
// magnetic field line contours
plane{<0,0,1>,0
 pigment{function{min(1,max(0,12000*B(x,y,0)*contours(x,y,0)))} color_map{
  [0 rgbt <0,0,1,1>] [0.25 rgbt <0,0,1,0.75>] [0.5 rgbt <1/3,0,1,0.5>] [0.75
rgbt <2/3,0.5,1,0.25>] [1 rgbt <1,1,1,0>]
 }}
 finish{ambient 2.25 reflection 0 diffuse 0 specular 0}
}


First of all the above requires to replace the solenoid function with a sphere,
the magnetic field induction with the Electric Field and to display the contours
in 3D space. Easy said than done (at least for me).

Anyone who is interested to see what I am looking for, just run the
above two examples which are really impressive and they will give you more to
think or inspire you.

I believe that when someone with some experience on POV RAY and having knowledge
of basic Physics, when he run the above two examples, it will become clearer of
what we are up to.

Bill and everybody thank you very much for your time so far!


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.