Re: Simple Electric motor simulation

Bruce Sherwood <[email protected]> Sat, 29 Nov 2014 19:46:45 -0700
Newsgroups gmane.comp.python.visualpython.user
Message-ID <CAFDG03g8itSe7pqW-pQuAedspG897-sLgVXFkdgK0Lhxqz2OQQ@mail.gmail.com>
--===============6337674628340484269==
Content-Type: multipart/alternative; boundary=047d7bd74ce62f904305090a81d4

--047d7bd74ce62f904305090a81d4
Content-Type: text/plain; charset=UTF-8

See comments added to code.

from __future__ import division, print_function
# should import future print_function, so that print(....) works the same
in Python 2 and Python 3

from visual import* # this imports all of the math library
#from math import e
#import math
scene.title='Simple Electric motor simulation'
scene.width = 1000
scene.height = 500
scene.autoscale = 0
scene.range = (35,35,35)
scene.center = (12,0,0) # not sure what you are trying to achieve; would
make more sense to place the object at (0,0,0)
scene.background = (.5,0.5,2) # I suspect you want this color as a
background, not as a box

# None of these variables are used, so they're commented out for clarity:
#area=box(pos=(12,0,14),length=400,height=400,width=400,material=materials.plastic,color=(.5,0.5,2))
#fcharge=1.6e-19
#pweight=1.67e-11
#count=0
#mfrm=frame(axis=(350,5,10))         #Motor Frame
#rfrm=frame(frame=mfrm)              #Rotor Frame

#Electric motor-Jon's
battery=frame() # not clear why a frame is used here; it plays no role
cylinder(frame=battery,pos=(0,0,10),axis=(0,0,.2),radius=1.5,color=color.blue,material=materials.emissive)
cylinder(frame=battery,pos=(0,0,10.2),axis=(0,0,7.8),radius=1.5,color=(0.5,0.5,0.2))
cylinder(frame=battery,pos=(0,0,12),axis=(0,0,7),radius=.75,color=color.red,material=materials.emissive)

#wire-Mine
wire=curve(pos=[(0,-6.5,20), (0,0,20), (0,0,8.5),(0,-6.5,8.5)], radius=0.25)

#Magnet of motor-Mine
floor1 = box (pos=(0,-1.75,14), length=2, height=0.5, width=6,
color=color.red)
floor2 = box (pos=(0,-2.25,14), length=2, height=0.5, width=6,
color=color.blue)

#Rotor stucture-Mine
# Add Ring and
Rod
# The armature coil (ring)
rotor = frame(pos=(0,-6,14)) # set up a frame for the rotating parts, and
in the loop just rotate the frame
#ring(pos=(0,-6,14),axis=(350,5,10), radius=1.75,
thickness=0.5,color=(1,0.5,0.3),material=materials.blazed)
#rod1=cylinder(pos=(0,-6,8.5),length=11.5,axis=(0,0.5,100),radius=0.45,color=(1,0.5,0.3),
material=materials.blazed)
ring(frame=rotor, radius=1.75,
thickness=0.5,color=(1,0.5,0.3),material=materials.blazed)
rod1=cylinder(frame=rotor, pos=(0,0,-11.5/2), length=11.5, axis=(0,0,1),
radius=0.45,color=(1,0.5,0.3), material=materials.blazed)

#labeling of program-Mine
label1=label(pos=(0,0,10.2), text='Battery', xoffset=17, yoffset=17)
label2=label(pos=(0,-6,10), text='Armature', xoffset=47, yoffset=47)

dtheta = 0.05
while True:
    rate(100)
    rotor.rotate(angle=dtheta, axis=(0,0,1))


print('end of simulation')

--047d7bd74ce62f904305090a81d4
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">See comments added to code.<br><div><br>from __future__ im=
port division, print_function<br># should import future print_function, so =
that print(....) works the same in Python 2 and Python 3<br><br>from visual=
 import* # this imports all of the math library<br>#from math import e <br>=
#import math<br>scene.title=3D&#39;Simple Electric motor simulation&#39;<br=
>scene.width =3D 1000<br>scene.height =3D 500<br>scene.autoscale =3D 0<br>s=
cene.range =3D (35,35,35)<br>scene.center =3D (12,0,0) # not sure what you =
are trying to achieve; would make more sense to place the object at (0,0,0)=
<br>scene.background =3D (.5,0.5,2) # I suspect you want this color as a ba=
ckground, not as a box<br><br># None of these variables are used, so they&#=
39;re commented out for clarity:<br>#area=3Dbox(pos=3D(12,0,14),length=3D40=
0,height=3D400,width=3D400,material=3Dmaterials.plastic,color=3D(.5,0.5,2))=
<br>#fcharge=3D1.6e-19<br>#pweight=3D1.67e-11<br>#count=3D0<br>#mfrm=3Dfram=
e(axis=3D(350,5,10))=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #Motor=
 Frame<br>#rfrm=3Dframe(frame=3Dmfrm)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #Rotor Frame <br><br>#Electric m=
otor-Jon&#39;s<br>battery=3Dframe() # not clear why a frame is used here; i=
t plays no role<br>cylinder(frame=3Dbattery,pos=3D(0,0,10),axis=3D(0,0,.2),=
radius=3D1.5,color=3Dcolor.blue,material=3Dmaterials.emissive)<br>cylinder(=
frame=3Dbattery,pos=3D(0,0,10.2),axis=3D(0,0,7.8),radius=3D1.5,color=3D(0.5=
,0.5,0.2))<br>cylinder(frame=3Dbattery,pos=3D(0,0,12),axis=3D(0,0,7),radius=
=3D.75,color=3Dcolor.red,material=3Dmaterials.emissive)<br><br>#wire-Mine<b=
r>wire=3Dcurve(pos=3D[(0,-6.5,20), (0,0,20), (0,0,8.5),(0,-6.5,8.5)], radiu=
s=3D0.25)<br><br>#Magnet of motor-Mine<br>floor1 =3D box (pos=3D(0,-1.75,14=
), length=3D2, height=3D0.5, width=3D6, color=3Dcolor.red)<br>floor2 =3D bo=
x (pos=3D(0,-2.25,14), length=3D2, height=3D0.5, width=3D6, color=3Dcolor.b=
lue)<br><br>#Rotor stucture-Mine<br># Add Ring and Rod=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=
=A0<br># The armature coil (ring)<br>rotor =3D frame(pos=3D(0,-6,14)) # set=
 up a frame for the rotating parts, and in the loop just rotate the frame<b=
r>#ring(pos=3D(0,-6,14),axis=3D(350,5,10), radius=3D1.75, thickness=3D0.5,c=
olor=3D(1,0.5,0.3),material=3Dmaterials.blazed)<br>#rod1=3Dcylinder(pos=3D(=
0,-6,8.5),length=3D11.5,axis=3D(0,0.5,100),radius=3D0.45,color=3D(1,0.5,0.3=
), material=3Dmaterials.blazed)<br>ring(frame=3Drotor, radius=3D1.75, thick=
ness=3D0.5,color=3D(1,0.5,0.3),material=3Dmaterials.blazed)<br>rod1=3Dcylin=
der(frame=3Drotor, pos=3D(0,0,-11.5/2), length=3D11.5, axis=3D(0,0,1), radi=
us=3D0.45,color=3D(1,0.5,0.3), material=3Dmaterials.blazed)<br><br>#labelin=
g of program-Mine<br>label1=3Dlabel(pos=3D(0,0,10.2), text=3D&#39;Battery&#=
39;, xoffset=3D17, yoffset=3D17)<br>label2=3Dlabel(pos=3D(0,-6,10), text=3D=
&#39;Armature&#39;, xoffset=3D47, yoffset=3D47)<br><br>dtheta =3D 0.05<br>w=
hile True:<br>=C2=A0=C2=A0=C2=A0 rate(100)<br>=C2=A0=C2=A0=C2=A0 rotor.rota=
te(angle=3Ddtheta, axis=3D(0,0,1))<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0<br>print(&#39;end of s=
imulation&#39;)<br></div></div>

--047d7bd74ce62f904305090a81d4--


--===============6337674628340484269==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
--===============6337674628340484269==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Visualpython-users mailing list
Visualpython-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/visualpython-users

--===============6337674628340484269==--