POV-Ray : Newsgroups : povray.newusers : Electron Density Maps Server Time
22 Dec 2024 06:43:19 EST (-0500)
  Electron Density Maps (Message 1 to 4 of 4)  
From: Richard
Subject: Electron Density Maps
Date: 17 Mar 2013 22:10:03
Message: <web.514672f1d99a91fd13ac09f20@news.povray.org>
After looking through dozens of programs to get the results I wanted I finally
decided to go with povray because well nothing else would work. I would like the
results to look like Molekel. So far I have the following code:

#include "colors.inc"    // The include files contain
  finish { phong 1 }
 }
}
sphere { //N-H2
  <-0.40424,1.05359,-0.84934>, 0.16
  texture {
  pigment { color LightGray }
  finish { phong 1 }
 }
}
cylinder {
  <-0.00251,0.68964,0.00159>,     // Center of one end
  <-0.54372,1.04180,0.77685>,     // Center of other end
  0.05            // Radius
  open           // Remove end caps
  texture {
  pigment { color Gray30 }
  finish { phong 1 }
 }
}
sphere { //N-H3
  <-0.54372,1.04180,0.77685>, 0.16
  texture {
  pigment { color LightGray }
  finish { phong 1 }
 }
}
cylinder {
  <-0.00251,0.68964,0.00159>,     // Center of one end
  <0.00634,-0.94898,-0.00930>,     // Center of other end
  0.05            // Radius
  open           // Remove end caps
  texture {
  pigment { color Gray30 }
  finish { phong 1 }
 }
}
sphere { //N-B
  <0.00634,-0.94898,-0.00930>, 0.45
  texture {
  pigment { color MediumVioletRed }
  finish { phong 1 }
 }
}
cylinder {
  <0.00634,-0.94898,-0.0093>,     // Center of one end
  <-1.15283,-1.27110,-0.11093>,     // Center of other end
  0.05            // Radius
  open           // Remove end caps
  texture {
  pigment { color Gray30 }
  finish { phong 1 }
 }
}
sphere { //H-B4
  <-1.15283,-1.27110,-0.11093>, 0.16
  texture {
  pigment { color LightGray }
  finish { phong 1 }
 }
}
cylinder {
  <0.00634,-0.94898,-0.0093>,     // Center of one end
  <-1.15283,-1.27110,-0.11093>,     // Center of other end
  0.05            // Radius
  open           // Remove end caps
  texture {
  pigment { color Gray30 }
  finish { phong 1 }
 }
}
sphere { //H-B5
  <0.50248,-1.26981,1.04363>, 0.16
  texture {
  pigment { color LightGray }
  finish { phong 1 }
 }
}
cylinder {
  <0.00634,-0.94898,-0.0093>,     // Center of one end
  <0.50248,-1.26981,1.04363>,     // Center of other end
  0.05            // Radius
  open           // Remove end caps
  texture {
  pigment { color Gray30 }
  finish { phong 1 }
 }
}
sphere { //H-B6
  <0.67456,-1.25559,-0.96700>, 0.16
  texture {
  pigment { color LightGray }
  finish { phong 1 }
 }
}
cylinder {
  <0.00634,-0.94898,-0.0093>,     // Center of one end
  <0.67456,-1.25559,-0.96700>,     // Center of other end
  0.05            // Radius
  open           // Remove end caps
  texture {
  pigment { color Gray30 }
  finish { phong 1 }
 }
}
scale 1.25
}
merge{     //Electron Density Map
  sphere { //N
  <-0.00251,0.68964,0.00159>, 1.20
  texture {
  pigment { color Blue transmit 0.7 }
  finish { phong 1 }
 }
}
sphere { //N-H1
  <0.93441,1.05461,0.08470>, 0.74
  texture {
  pigment { color Blue transmit 0.8 }
  finish { phong 1 }
 }
}
sphere { //N-H2
  <-0.40424,1.05359,-0.84934>, 0.74
  texture {
  pigment { color Blue transmit 0.8 }
  finish { phong 1 }
 }
}
sphere { //N-H3
  <-0.54372,1.04180,0.77685>, 0.74
  texture {
  pigment { color Blue transmit 0.8 }
  finish { phong 1 }
 }
}
sphere { //N-B
  <0.00634,-0.94898,-0.00930>, 1.4
  texture {
  pigment { color Red transmit 0.7 }
  finish { phong 1 }
 }
}
sphere { //H-B4
  <-1.15283,-1.27110,-0.11093>, 0.74
  texture {
  pigment { color Red transmit 0.8 }
  finish { phong 1 }
 }
}
sphere { //H-B5
  <0.50248,-1.26981,1.04363>, 0.74
  texture {
  pigment { color Red transmit 0.8 }
  finish { phong 1 }
 }
}
sphere { //H-B6
  <0.67456,-1.25559,-0.96700>, 0.74
  texture {
  pigment { color Red transmit 0.8 }
  finish { phong 1 }
 }
}
scale 1.25
}


This creates the molecule and a very basic electron density surface. What I am
having trouble with is gradients. I have tried the simple example file in the
documentation which produces repeating bands of color. However I would like to
be able to choose two colors to evenly transition between. For example, this
code:

#include "colors.inc"
 camera {
       location <0,4,6 >
       look_at  <0,0,0 >
}
light_source { <2, 4, 3> color White}
 sphere {
    <0,0,0>, 2
    pigment {
      gradient z       //this is the PATTERN_TYPE
      color_map {
        [-4  color Red]
 [4  color Yellow]
      }
      translate -1
    }
  }

I thought this should have created a smooth transition from Red to Yellow on the
entire sphere oriented about the z axis but it has not. Instead it produces
alternating color bands from yellow to red. Additionally, I tested a gradient in
the above molecule example but when povray traced the code the section with the
gradient was no longer transmitting colors through it. So, the two problem I
need help with are creating a gradient with a smooth transition and making that
gradient transparent to the molecule underneath it. THANKS!


Post a reply to this message

From: Thomas de Groot
Subject: Re: Electron Density Maps
Date: 18 Mar 2013 04:31:28
Message: <5146d0e0$1@news.povray.org>
On 18-3-2013 3:04, Richard wrote:
> ...... What I am
> having trouble with is gradients. I have tried the simple example file in the
> documentation which produces repeating bands of color. However I would like to
> be able to choose two colors to evenly transition between. For example, this
> code:
>
> #include "colors.inc"
>   camera {
>         location <0,4,6 >
>         look_at  <0,0,0 >
> }
> light_source { <2, 4, 3> color White}
>   sphere {
>      <0,0,0>, 2
>      pigment {
>        gradient z       //this is the PATTERN_TYPE
>        color_map {
>          [-4  color Red]
>   [4  color Yellow]
>        }
>        translate -1
>      }
>    }
>
> I thought this should have created a smooth transition from Red to Yellow on the
> entire sphere oriented about the z axis but it has not. Instead it produces
> alternating color bands from yellow to red. Additionally, I tested a gradient in
> the above molecule example but when povray traced the code the section with the
> gradient was no longer transmitting colors through it. So, the two problem I
> need help with are creating a gradient with a smooth transition and making that
> gradient transparent to the molecule underneath it. THANKS!
>
>
To answer the two question, a colour_map goes from 0.0 to 1.0. To adapt 
it to the sphere radius in your example, you have to scale and translate 
it accordingly. I used a gradient x to better show the result. Adding 
the parameter transmit to the color makes it transparant:

  sphere {
     <0,0,0>, 2
     pigment {
       gradient x       //this is the PATTERN_TYPE
       color_map {
         [0  color Red transmit 0.5]
         [1  color Yellow transmit 0.5]
       }
       scale 4
       translate 2*x
     }
   }


Thomas


Post a reply to this message

From: Richard
Subject: Re: Electron Density Maps
Date: 18 Mar 2013 12:00:01
Message: <web.514738cb5403b75cbb6c6e7c0@news.povray.org>
Thomas de Groot <tho### [at] degrootorg> wrote:
> On 18-3-2013 3:04, Richard wrote:
> > ...... What I am
> > having trouble with is gradients. I have tried the simple example file in the
> > documentation which produces repeating bands of color. However I would like to
> > be able to choose two colors to evenly transition between. For example, this
> > code:
> >
> > #include "colors.inc"
> >   camera {
> >         location <0,4,6 >
> >         look_at  <0,0,0 >
> > }
> > light_source { <2, 4, 3> color White}
> >   sphere {
> >      <0,0,0>, 2
> >      pigment {
> >        gradient z       //this is the PATTERN_TYPE
> >        color_map {
> >          [-4  color Red]
> >   [4  color Yellow]
> >        }
> >        translate -1
> >      }
> >    }
> >
> > I thought this should have created a smooth transition from Red to Yellow on the
> > entire sphere oriented about the z axis but it has not. Instead it produces
> > alternating color bands from yellow to red. Additionally, I tested a gradient in
> > the above molecule example but when povray traced the code the section with the
> > gradient was no longer transmitting colors through it. So, the two problem I
> > need help with are creating a gradient with a smooth transition and making that
> > gradient transparent to the molecule underneath it. THANKS!
> >
> >
> To answer the two question, a colour_map goes from 0.0 to 1.0. To adapt
> it to the sphere radius in your example, you have to scale and translate
> it accordingly. I used a gradient x to better show the result. Adding
> the parameter transmit to the color makes it transparant:
>
>   sphere {
>      <0,0,0>, 2
>      pigment {
>        gradient x       //this is the PATTERN_TYPE
>        color_map {
>          [0  color Red transmit 0.5]
>          [1  color Yellow transmit 0.5]
>        }
>        scale 4
>        translate 2*x
>      }
>    }
>
>
> Thomas

That did the trick! Thanks a million!

-Richard


Post a reply to this message

From: Bald Eagle
Subject: Re: Electron Density Maps
Date: 28 Jul 2013 12:55:00
Message: <web.51f54cab5403b75c73fc9ebb0@news.povray.org>
Richard,

A few suggestions that may help you speed up your construction, help you keep
track of it, and reduce confusion:

Define a texture for each of you atom types once, and then reference that.

#declare Nitrogen = texture { pigment { Blue } }

Then, it's easy to change it for ALL nitrogens in the scene.

Also, define the atom locations as variables.

#define Nitrogen_1 = <1, 1, 1>
#define Nitrogen_rad = 0.5

then you can just write
sphere { Nitrogen_1, Nitrogen_rad texture { Nitrogen} }

That will help you keep track of what atoms are what, allow you tweak the radii
of each type of atom, etc.
It might help also to define all of the atoms in your scene as an array.

#declare Atoms = array [4] [4]
{1, Nitrogen_1, Nitrogen_rad, Nitrogen},
{2, Nitrogen_1, Nitrogen_rad, Nitrogen},
{3, Nitrogen_1, Nitrogen_rad, Nitrogen},
{4, Nitrogen_1, Nitrogen_rad, Nitrogen}
}

Keep in mind that arrays start at ZERO and go down rows first and then over
columns.
then you can call then like this:
sphere {Atoms [0][1], Atoms [0][2] texture Nitrogen}
The first number in the array is the atom#, in case you want to label your atoms
in the scene
text { ttf "arial.ttf" concat("N", str(Atoms[0][0],1,1)) .01, 1}

You might also try using blobs for your electron density clouds, as you may get
better color gradients and smoother transitions.  Changing the strength of the
blobs might help you better model the different electron densities by mimicking
the electronegativities.

Nice work so far.
Good luck.


Post a reply to this message

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