Current location: Hot Scripts Forums » Programming Languages » Other Languages » Cant find the error in this program


Cant find the error in this program

Reply
  #1 (permalink)  
Old 05-09-10, 04:27 AM
groom03 groom03 is offline
New Member
 
Join Date: May 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Cant find the error in this program

Hi, I've got to model how a charge will move away from a stationary charge in python, i need the acceleration to be recalculated based on the force between the charges because the moving charge will decelerate, i've been up all night trying to get this to work but i just cannot figure out whats wrong
Code:
Code:
#Problem 4a
from visual import*

#mass is assumed to be proton rest mass

k=8.987551787362e09 #coulomb constant

#particle data

#Stationary particle
alpha=sphere(pos=(0,0,0), radius=0.01,color=color.blue)
qa=0.02
m=1.67262158e-27

#Moving particle
beta=sphere(pos=(1e-03,0,0), radius=0.01, color=color.red)
#particle seperations have been magnified by 1000
qb=0.02

#particle separation
dist=beta.pos-alpha.pos

a=f/m

#Lets make it move
while beta.pos.x>15e-03: #the moving particle will have moved 15mm
    rate(20000)
    dt=0.1
    f=(k*qa*qb)/dist**2
    beta.velocity=vector(1,0,0)
    #beta.velocity=a*dt
    betadelta_s=beta.velocity
    beta.pos=beta.pos+betadelta_s
    print a
    print f
    print beta.velocity
any help greatly appreciated

p.s i know nothing about computer programming
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Please! where can I find such program? netwow Script Requests 1 05-22-06 07:41 PM
Trying To Find A Program!!!! amindsdesign Script Requests 1 04-21-05 06:24 PM
Need help to find the program i need MCV Perl 2 07-05-04 09:09 PM
Help me find a powerful mailing list program abuzerK Script Requests 3 09-17-03 09:32 AM


All times are GMT -5. The time now is 03:47 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.