Nano Language - Example

Example

This NanoLanguage script uses the Kohn-Sham method to calculate the total energy of a water molecule as a function of the bending angle.

#Define function for molecule setup def waterConfiguration(angle,bondLength): from math import sin,cos theta = angle.inUnitsOf(radians) positions = [(0.0, 0.0, 0.0)*Angstrom, (1.0, 0.0, 0.0)*bondLength, (cos(theta), sin(theta), 0.0)*bondLength] elements = + *2 return MoleculeConfiguration(elements,positions) #Choose DFT method with default arguments method = KohnShamMethod #Scan different bending angles and calculate the total energy for i in range(30,181,10): theta = i*degrees h2o = waterConfiguration(theta, 0.958*Angstrom) scf = method.apply( h2o ) print 'Angle = ', theta, ' Total Energy = ',calculateTotalEnergy(scf)

Read more about this topic:  Nano Language

Famous quotes containing the word example:

    Our intellect is not the most subtle, the most powerful, the most appropriate, instrument for revealing the truth. It is life that, little by little, example by example, permits us to see that what is most important to our heart, or to our mind, is learned not by reasoning but through other agencies. Then it is that the intellect, observing their superiority, abdicates its control to them upon reasoned grounds and agrees to become their collaborator and lackey.
    Marcel Proust (1871–1922)