POV-Ray : Newsgroups : povray.newusers : Crystal made of millions of atoms : Crystal made of millions of atoms Server Time
5 Jul 2024 03:54:42 EDT (-0400)
  Crystal made of millions of atoms  
From: Tomohiro
Date: 8 Jul 2010 02:30:00
Message: <web.4c356f946fc022ce6aeee4e0@news.povray.org>
Hello,

I would like to build an image of a crystal made of a lot of atoms
and chemical bonds. I wrote a following source file, but it is very
heavy and sometimes causes shortage of memory. Also, it is very slow.
Please change the Lattice_Constant value in the source file from 0.5
to 0.01 to check what happens.
(Since my final goal is to build an animation, faster rendering is
better.)

I also tried an isosurface with a function like:
  function{ 0.3 - pow(cos(x/Lattice_Constant*pi),2)
                * pow(cos(y/Lattice_Constant*pi),2)
                * pow(cos(z/Lattice_Constant*pi),2) }
but the result image is something wrong.

I imagine there should be cleverer way to do this. Could someone
give hints?

//---------- source code ----------//

camera{ location <0.2,0.7,-1>  look_at <0,0,0> }
light_source{ <-200,200,-200> rgb<1,1,1> }
global_settings{ ambient_light rgb 3 }

#declare T_Atom = texture{pigment {rgb<.3, .5, .7>} finish{phong 0.3}}
#declare T_Bond = texture{pigment {rgb<.7, .5, .3>} finish{phong 0.3}}
#declare Lattice_Constant=0.05;
#declare Xmax=3;
#declare Ymax=0;
#declare Zmax=5;
#declare Xmin=-4;
#declare Ymin=-2;
#declare Zmin=0;

// Place atoms at lattice points
#declare X=Xmin; #while(X<=Xmax)
  #declare Y=Ymin; #while(Y<=Ymax)
    #declare Z=Zmin; #while(Z<=Zmax)
      sphere{ <X,Y,Z>, Lattice_Constant*0.3 texture{T_Atom} }
    #declare Z=Z+Lattice_Constant; #end
  #declare Y=Y+Lattice_Constant; #end
#declare X=X+Lattice_Constant; #end

// Place chemical bonds
#declare X=Xmin; #while(X<=Xmax)
  #declare Y=Ymin; #while(Y<=Ymax)
    cylinder{ <X,Y,Zmin>, <X,Y,Zmax>, Lattice_Constant*0.1 texture{T_Bond} }
  #declare Y=Y+Lattice_Constant; #end
#declare X=X+Lattice_Constant; #end

#declare X=Xmin; #while(X<=Xmax)
  #declare Z=Zmin; #while(Z<=Zmax)
    cylinder{ <X,Ymin,Z>, <X,Ymax,Z>, Lattice_Constant*0.1 texture{T_Bond} }
  #declare Z=Z+Lattice_Constant; #end
#declare X=X+Lattice_Constant; #end

#declare Z=Zmin; #while(Z<=Zmax)
  #declare Y=Ymin; #while(Y<=Ymax)
    cylinder{ <Xmin,Y,Z>, <Xmax,Y,Z>, Lattice_Constant*0.1 texture{T_Bond} }
  #declare Y=Y+Lattice_Constant; #end
#declare Z=Z+Lattice_Constant; #end


Post a reply to this message

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