0
from visual import *
s=[]
r=0.1
f=open('G:\Dropbox\Programming\Fortran\MolecularDynamics\Source\pos.dat','r')
box(pos=[1,1,1],length=2,width=2,height=2,opacity=0.5)
for line in f:
    rate(1)
    row = line.split()
    x = float(row[0])
    y = float(row[1])
    z = float(row[2])
    s.append(sphere(pos=[x,y,z],rad=r))

In the above code, the radius of the sphere doesn't change when I change the value of r. What am I doing wrong?

Here are the contents of pos.dat

  0.76425066770083916        1.0636929975958958        1.1172529144364949     
   1.5493877083479954        1.8739841784589457       0.32294665232964315     
   1.7226925707051988        1.2935288113975998       0.82842705941539108     
   1.1157571132788351        1.6032073165018330       0.47281352901565676     
  0.85641201180922688       0.43381700408239521       0.87082052348215733     
   1.2295464749283869        1.6343067967959193        1.8621538204952262     
  0.24459026475960810       0.48469706447047489       0.66260850683935280     
   9.7846721099904554E-002   1.0883378789613212        1.0974266698879096     
   1.3217953491654058        1.2185744544458481       0.46992237251202784     
  0.93138446212988923       0.17350531672748493       0.46661784215632274     
   1.0043589622107352        1.9359078801899188        1.9320966852700339     
   1.2058561745199539       0.68518208899112198       0.36442977608095561     
   1.6757663457868546       0.10346775928039831        1.4283142254811065     
   1.5569448852911780        1.7586288480611603        1.9266600727629331     
   1.9325159921796258       0.33110561878449962        1.7581902883579656     
  0.63844388963707432       0.34815817893985024       0.91100666305761346     
   1.9482563908931441        1.5574645513006116        1.9109607990747766     
  0.49479122111175244       0.33686742568910266       0.10389548165695972     
  0.18416224004253112       0.43553604681424996        8.6043504475411980E-002
   7.9873689634088141E-002  0.73068476142567929        8.4607849131498103E-002
Yogesh Yadav
  • 404
  • 5
  • 16

1 Answers1

0

The argument of sphere should be radius, not rad. This is the correct working code.

from visual import *
s=[]
r=0.1
f=open('G:\Dropbox\Programming\Fortran\MolecularDynamics\Source\pos.dat','r')
box(pos=[1,1,1],length=2,width=2,height=2,opacity=0.5)
for line in f:
    rate(1)
    row = line.split()
    x = float(row[0])
    y = float(row[1])
    z = float(row[2])
    s.append(sphere(pos=[x,y,z],radius=r))
Yogesh Yadav
  • 404
  • 5
  • 16