What could be wrong with my charge motion model in Python?

  • Thread starter groom_03
  • Start date
  • Tags
    Work
In summary, the conversation is about a person trying to model how a charge will move away from a stationary charge in Python. They are struggling to get the acceleration to be recalculated based on the force between the charges and are asking for help. They also mention not knowing much about computer programming and suggest using print statements to check for errors.
  • #1
groom_03
1
0
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 what's wrong

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
 
Technology news on Phys.org
  • #2
What are some of the error messages that you're getting?
Also, use print statements at each stage to check that the values seem sane.

Also, far as I can tell you don't define f for
Code:
a=f/m
 

1. Why is Vpython not working on my computer?

There could be several reasons why Vpython is not working on your computer. Some common reasons include not having the correct version of Vpython installed, incompatible hardware or operating system, or a conflicting program or software on your computer.

2. How do I install Vpython on my computer?

The easiest way to install Vpython on your computer is to download and install the appropriate version from the official Vpython website. Make sure to follow the installation instructions carefully and check for any system requirements before proceeding.

3. Why is Vpython not displaying any graphics or animations?

If Vpython is not displaying any graphics or animations, it could be due to a coding error or a missing module. Double check your code for any errors or missing modules, and make sure to import the necessary libraries and modules for your program to run correctly.

4. How do I troubleshoot Vpython errors?

The best way to troubleshoot Vpython errors is to first check for any coding mistakes or errors. If your code is error-free, try updating Vpython to the latest version or reinstalling the program. You can also refer to online forums or contact the Vpython support team for further assistance.

5. Can I use Vpython on any operating system?

Vpython is compatible with most operating systems such as Windows, Mac, and Linux. However, certain features may not be available on all operating systems. It is recommended to check the system requirements before installing Vpython to ensure compatibility.

Similar threads

  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
11
Views
9K
  • Introductory Physics Homework Help
Replies
8
Views
1K
  • Programming and Computer Science
Replies
13
Views
6K
  • Programming and Computer Science
Replies
3
Views
2K
Back
Top