USF Libraries
USF Digital Collections

Theory and simulation of metal-organic materials and biomolecules

MISSING IMAGE

Material Information

Title:
Theory and simulation of metal-organic materials and biomolecules
Physical Description:
Book
Language:
English
Creator:
Belof, Jonathan L
Publisher:
University of South Florida
Place of Publication:
Tampa, Fla
Publication Date:

Subjects

Subjects / Keywords:
Nanomaterials
Metal-organic frameworks
Condensed matter
Statistical mechanics
Computer simulation
Monte Carlo
Molecular dynamics
Dissertations, Academic -- Chemistry -- Doctoral -- USF   ( lcsh )
Genre:
non-fiction   ( marcgt )

Notes

Abstract:
ABSTRACT: The emerging field of nanomaterials has raised a number of fascinating scientific questions that remain unanswered. Molecular theory and computer simulation are key tools to unlocking future discoveries in materials science, and various computational techniques and results toward this goal are elucidated here. High-performance computing methods (utilizing the latest supercomputers and codes) have been developed to explore and predict the chemistry and physical properties of systems as diverse as Metal-Organic Frameworks, discrete nanocubes, photoswitch molecules, porphyrins and several interesting enzymes. In addition, highlights of fundamental statistical physics, such as the Feynman-Hibbs effective partition function and generalized ensemble theory, are expounded and upon from the perspective of both research and pedagogy.
Thesis:
Dissertation (Ph.D.)--University of South Florida, 2009.
Bibliography:
Includes bibliographical references.
System Details:
Mode of access: World Wide Web.
System Details:
System requirements: World Wide Web browser and PDF reader.
Statement of Responsibility:
by Jonathan L. Belof.
General Note:
Title from PDF of title page.
General Note:
Document formatted into pages; contains 285 pages.
General Note:
Includes vita.

Record Information

Source Institution:
University of South Florida Library
Holding Location:
University of South Florida
Rights Management:
All applicable rights reserved by the source institution and holding location.
Resource Identifier:
aleph - 002069479
oclc - 608505691
usfldc doi - E14-SFE0003272
usfldc handle - e14.3272
System ID:
SFS0027588:00001


This item is only available as the following downloads:


Full Text

PAGE 1

TheoryandSimulationofMetal-OrganicMaterialsandBiomo lecules by JonathanL.Belof Adissertationsubmittedinpartialfulllment oftherequirementsforthedegreeof DoctorofPhilosophy DepartmentofChemistry CollegeofArtsandSciences UniversityofSouthFlorida MajorProfessor:BrianSpace,Ph.D. RandyLarsen,Ph.D. H.LeeWoodcock,Ph.D. PrestonMoore,Ph.D. DateofApproval: November12,2009 Keywords:nanomaterials,metal-organicframeworks,cond ensedmatter,statistical mechanics,computersimulation,MonteCarlo,moleculardy namics c r Copyright2009,JonathanL.Belof

PAGE 2

Dedication InlovingmemoryofJoanElaineBelof(1939-2002)

PAGE 3

Acknowledgments Ioweeverythingtotheloveofmylife,mydearestwifeMaiky. Withoutyour unwaiveringsupport,noneofthiswouldhavebeenpossible. Yourlove,understanding, encouragementandpatiencearebehindeveryprintedword{I loveyouwithallmy heart. AndalsotomysweetdaughterIsabella,thesparklinggemofm ylife. TomyfatherLewisBelof,whohashelpedmeinsomanywaystosu stainmy graduateworkthroughouttheseyears,I'msothankfulforyo ursupport.Thiswork honorsyou{itisasmuchyoursasitismine. Andtomyfamily:StephenandSuzanneBelof,DawnandFredGan ter,Beth andDanJasko,JoshandElizabethBelof,fortheirloveandsu pport. IamgratefultomyPh.D.committeeofRandyLarsen,LeeWoodc ock,PrestonMoore(USP)andChairVenkatBhethanabotlafortheirgu idanceandinsight throughouttheyears. MyfellowlabmatesandfriendsChrisCioce,TonyGreen,AbeS tern,Katherine ForrestandAshleyMullen{yourcomaraderiewillbegreatly missed. Tomyfellowgraduatestudentandpostdoctoralcollaborato rsAudreyMokdad, WillLoweandNeilMcIntye,andespeciallytoMohamedAlkord iwhomIconsiderto beoneofthemosttalentedchemistsI'veeverknown. AspecialthankstoDavidRabson,fromwhomI'velearnedtoap preciatethe broaderaspectsofphysics,farbeyondmycurrentdisciplin e. I'mgratefultomyundergraduatementorBobPotterforhiski ndnessandencouragement.Thepathtowardgraduateschoolbeganwiththe manysagediscussions wehadinhisoce,whichhavegreatlyinruencedmyperspecti vetowardscience. Lastbutcertainlynotleast,IaminnitelygratefultoBria nSpace,myresearch advisor,mymentorandmyfriend.Youhavealwaysgonetheext ramileforme,both personallyandprofessionally.You'vealwaysbeengenerou sandsupportiveofme, andIwillneverforgetthekindnessthatyou'veshownme.I'v elearnedsomuchfrom youovertheyears,andI'vegreatlyenjoyedourscienticwo rktogether.Icouldnot haveaskedforabettermentor,you'veprovidedmewithdirec tionrootedinwisdom andatthesametimenurturedmydesiretointellectuallywan der.Youareatrue friend,andhavebeenthereformeatthetimesI'vemostneede dyourhelp,inthe darkestofmomentswhenittrulycounts.Iadmireyouandlook uptoyou,andfeel fortunatetohavebeenmentoredbysuchagiftedscientistan dhonorableperson{ thankyou.

PAGE 4

NotetoReader NotetoReader:Theoriginalofthisdocumentcontainscolor thatisnecessary forunderstandingthedata.Theoriginaldissertationison lewiththeUSFlibrary inTampa,Florida.

PAGE 5

TableofContents ListofTables vi ListofFigures vii Abstract x Chapter1Introduction 1 Chapter2OntheMechanismofHydrogenStorageinaMetal-Org anic Framework(MOF)Material 6 2.1Introduction.............................72.2ModelsandMethods........................11 2.2.1MolecularSimulationParameters..............112.2.2PolarizabilityModel.....................162.2.3NVTMonteCarlo......................222.2.4HybridMonteCarlo.....................24 2.3ResultsandDiscussion.......................262.4Conclusions.............................33 i

PAGE 6

Chapter3AnAccurateandTransferableIntermolecularDiat omicHydrogenPotentialforCondensedPhaseSimulation35 3.1Introduction.............................353.2Methods...............................37 3.2.1Born-OppenheimerSurface.................373.2.2Many-bodyPolarization...................393.2.3PotentialEnergyFunction..................41 3.3ModelValidation..........................44 3.3.1SecondVirialCoecient...................443.3.2EquationofState......................46 3.4Conclusions.............................47 Chapter4APredictiveModelofGasSorptionforMetal-Organ icMaterials50 4.1Introduction.............................504.2Methods...............................52 4.2.1HydrogenPotential.....................524.2.2MOF-5Potential.......................534.2.3AnalysisofPotentialParameters..............554.2.4GrandCanonicalMonteCarlo...............57 4.3ResultsandDiscussion.......................60 4.3.1HydrogenIsotherms.....................604.3.2IsostericHeatofAdsorptionofHydrogen.........604.3.3IsothermalCompressibilityofHydrogen..........6 3 4.4Conclusions.............................65 Chapter5PhotophysicalStudiesoftheTranstoCisIsomeriz ationofthe Push-PullMolecule:1-(Pyridin-4-yl)-2-(N-methylpyrro l-2-yo)ethene (mepepy) 67 ii

PAGE 7

5.1Introduction.............................685.2Methods...............................705.3ResultsandDiscussion.......................71 Chapter6InsightintotheAssemblyMechanismofMetal-Orga nicMaterials75 6.1Introduction.............................756.2Methods...............................786.3ResultsandDiscussion.......................79 Chapter7MolecularSquares:ConnedSpacewithSpecicGeo metryfor HydrogenUptake 86 7.1Introduction.............................867.2MethodsandResults........................87 Chapter8RapidlyConvergentIterativeTechniquesTowardt heSolution ofMany-bodyMolecularPolarizationFieldEquations91 8.1Introduction.............................918.2IterativeMethodsforMany-bodyPolarization........ ..96 8.3Results................................99 Chapter9CalculationofRotationalSpectraforSorbedHydr ogeninMetalOrganicMaterials 103 9.1Introduction.............................1039.2MethodsandResults........................105 Chapter10MicrocanonicalEectivePartitionFunction109 10.1Introduction.............................10910.2MicrocanonicalDerivation.....................11 2 10.3AnharmonicOscillatorandNumericalEvaluation..... ...113 iii

PAGE 8

Chapter11AStudent-FriendlyDerivationofthePartitionF unctionforGeneralizedEnsembles 116 11.1Introduction.............................11711.2TheGibbsEntropyandtheMicrocanonicalEnsemble.... ..118 11.3ASimpliedDerivationoftheCanonicalPartitionFunc tion..121 11.4GrandCanonicalPartitionFunction................ 124 11.5Isothermal-IsobaricPartitionFunction........... ...126 11.6ConnectionwithGeneralizedEnsembleTheory........ ..128 11.7Conclusions.............................131 Chapter12VolumeDeterminationofGlobularProteinsbyMol ecularDynamics 133 12.1Introduction.............................13312.2Methods...............................13412.3ResultsandDiscussion.......................135 12.3.1Horse-heartmyoglobin....................13512.3.2Aspartateaminotransferase.................136 12.4Conclusions.............................139 Chapter13MassivelyParallelMonteCarlo(MPMC)140References 142 Appendices 158 AppendixA.VirialEquationforthePressure............. 159 AppendixB.FrenkelVolumeDerivative.................1 60 AppendixC.WidomPotentialDistributionTheorem........ .162 AppendixD.Fugacity..........................164AppendixE.IsostericHeatofAdsorption(Q st )............167 iv

PAGE 9

AppendixF.autocorr.c..........................170AppendixG.get virial coecients.c...................172 AppendixH.virial iso.c.........................174 AppendixI.structure factor.c......................176 AppendixJ.rng.c.............................179AppendixK.Q st RCode.........................184 AppendixL.MPMC...........................186 AbouttheAuthor EndPage v

PAGE 10

ListofTables Table2.1Partialchargesobtainedfor soc -MOFFragmentA.......14 Table2.2Partialchargesobtainedfor soc -MOFFragmentB.......14 Table3.1H 2 polarizabilitytensor via TDHF...............39 Table3.2Polarizablehydrogenpotentialparameters..... ......42 Table3.3Non-polarizablehydrogenpotentialparameters. .......44 Table4.1MOF-5potentialparameters................... 54 Table4.2MOF-5partialchargecomparisonfordierentbasi ssets...56 Table4.3ChargeanalysisforthreeMOF-5fragments....... ...57 Table4.4CompleteMOF-5potentialparameters........... ..57 Table5.1MEPEPYgeometry........................71Table5.2MEPEPYground-stateenergyanddipolemoments... ...72 Table8.1SCFResultsasa2-stepiterationscheme......... ...102 vi

PAGE 11

ListofFigures Figure2.1 soc -MOFhydrogenpopulationisosurface...........9 Figure2.2Moleculargas-phase soc -MOFfragmentsusedtodetermine thepartialcharges........................13 Figure2.3In-hydrogen g ( r ).........................27 Figure2.4Azo-hydrogen g ( r )........................28 Figure2.5Bi-modaldipoledistributionforhydrogenin soc -MOF....29 Figure2.6Induceddipoleisosurfaces.................. ..30 Figure3.1MP4EnergySurfaceforH 2 dimer...............38 Figure3.2Potentialenergysurfaceobtainedthroughsimul atedannealing oftheparameterspace.....................43 Figure3.3Comparisonofisotropichydrogenpotentialvs.S ilvera-Goldman45 Figure3.4Hydrogensecondvirialcoecients............ ...46 Figure3.5Bulkhydrogen77Kisotherm..................4 8 Figure3.6Bulkhydrogen298Kisotherm.................4 8 Figure4.1MOF-5molecularfragmentusedinthecalculation ofpartial charges..............................54 Figure4.2MOF-5Fragment1.......................55Figure4.3MOF-5Fragment2.......................56Figure4.4MOF-5Fragment3.......................56 vii

PAGE 12

Figure4.5MOF-5hydrogen77Klow-pressureisotherm...... ...61 Figure4.6MOF-5hydrogen77Khigh-pressureisotherm(weig htpercent)61 Figure4.7MOF-5hydrogen77Khigh-pressureisotherm(exce ssweight percent)..............................62 Figure4.8ComparisonofMOF-5hydrogenexcessisothermvs. experimentaldata...........................62 Figure4.9IsostericheatofadsorptionforhydrogeninMOF5......64 Figure4.10CompressibilityofhydrogeninMOF-5......... ....65 Figure5.1transisomerofMEPEPY....................71Figure5.2MEPEPYisomergeometries..................72Figure5.3MEPEPYground-stateenergysurface........... ..74 Figure6.1Cobaltnanocube.........................77Figure6.2Ligandusedinnanocubesynthesis............. ..77 Figure6.3Time-seriesNMRspectraofreactionformingnano cube...79 Figure6.4Simulatedpotentialinorganiccomplexes...... ......80 Figure6.5T1relaxationdistancesascomputedusingDFT... ....81 Figure6.6ComparisonofexperimentalandtheoreticalT1re laxationspectra.................................81 Figure6.7Metal-OrganicSquare......................8 2 Figure6.8Depictionofnanocubewithcounterions........ ....83 Figure6.9Proposednanocubeassemblymechanism......... ..84 Figure7.1MolecularSquares:ME193...................8 7 Figure7.2MolecularSquares:Dispersiveenergysurfacean dtheCBSlimit89 Figure8.1Energyconvergenceforvariousiterativesolver s........99 viii

PAGE 13

Figure8.2EnergyconvergenceusingPKcorrectionforvario usiterative solvers..............................100 Figure8.3DipoleRRMSforvariousiterativesolvers...... .....101 Figure9.1Rotationaltunnelsplittingforahinderedrotor ........106 Figure9.2RotationaltunnelsplittingforH 2 inMOF-5..........107 Figure10.1Classicalvs.quantumentropyforaprotoninana nharmonic well................................115 Figure11.1Gibbsconstructionforthecanonicalensemble. ........124 Figure11.2Gibbsconstructionforthegrandcanonicalense mble.....127 Figure11.3Gibbsconstructionfortheisothermal-isobari censemble...129 Figure12.1Horse-heartmyoglobin..................... .134 Figure12.2Volumeofproteinandwatersystemduringequili bration...137 Figure12.3StericsofAspATresidues................... .138 ix

PAGE 14

TheoryandSimulationofMetal-OrganicMaterialsandBiomo lecules JonathanL.Belof ABSTRACT Theemergingeldofnanomaterialshasraisedanumberoffas cinatingscienticquestionsthatremainunanswered.Moleculartheoryan dcomputersimulation arekeytoolstounlockingfuturediscoveriesinmaterialss cience,andvariouscomputationaltechniquesandresultstowardthisgoalareelucidat edhere.High-performance computingmethods(utilizingthelatestsupercomputersan dcodes)havebeendevelopedtoexploreandpredictthechemistryandphysicalpr opertiesofsystemsas diverseasMetal-OrganicFrameworks,discretenanocubes, photoswitchmolecules, porphyrinsandseveralinterestingenzymes.Inaddition,h ighlightsoffundamental statisticalphysics,suchastheFeynman-Hibbseectivepa rtitionfunctionandgeneralizedensembletheory,areexpoundedanduponfromthepers pectiveofbothresearch andpedagogy. x

PAGE 15

Chapter1 Introduction Theemergingeldofnanomaterialshasraisedanumberoffas cinatingscienticquestionsthatremainunanswered.Moleculartheoryandcompute rsimulationarekey toolstounlockingfuturediscoveriesinmaterialsscience ,andvariouscomputational techniquesandresultstowardthisgoalareelucidatedhere .High-performancecomputingmethods(utilizingthelatestsupercomputersandco des)havebeendeveloped toexploreandpredictthechemistryandphysicalpropertie sofsystemsasdiverseas Metal-OrganicFrameworks,discretenanocubes,photoswit chmolecules,porphyrins andseveralinterestingenzymes.Inaddition,highlightso ffundamentalstatistical physics,suchastheFeynman-Hibbseectivepartitionfunc tionandgeneralizedensembletheory,areexpoundedanduponfromtheperspectiveo fbothresearchand pedagogy. OfimportancetowardengineeringnewMetal-OrganicMateri als(MOMs)for hydrogenstorage,Chapter2dealswithcomputersimulation sofhydrogeninanovel, highlychargedMOF.Thesesimulationsrevealed,forthers ttime,theexistenceof adipolarruidinthenanoporeandtheroleofelectrostatici nductioninretaining attractiveinteractionsdeepwithinthepore.Theprincipl esofenhancinghydrogen uptakegleemedfromthisstudywillhopefullyleadtothedes ignofnewmaterials capableofmeetingtheDOEgoals.[1] Chapter3highlightsthedevelopmentofanewhydrogenpoten tialthatisac1

PAGE 16

curate,transferableand(mostimportantly)suitableforc ondensedphasesimulation. Thepotentialwasdevelopedfromrstprinciplesandinclud esanisotropicinteractions aswellasmany-bodypolarization.Thefunctionalformofth epotentialisamenable toextantsimulationcodes,andhasbeendemonstratedtoyie ldaccurateproperties ofhydrogen(secondvirial,equationofstate)wellintothe liquidregime. InChapter4thenewlydevelopedhydrogenpotentialfromCha pter3hasbeen validatedinaninterfacialenvironmentofastronglysorbi ngsurface.Thesystem investigatedisthewellcharacterizedMOF-5[2]andMonteC arlosimulationswere performedyieldingthehydrogenuptakeacrossawiderangeo ftemperatureand pressure,andfoundtobeinquantitativeagreementwithexp eriment.Theisosteric heatofadsorption,athermodynamicmeasureofhowstrongly hydrogenbindstothe MOFsurface,hasalsobeencalculatedandfoundtobeinremar kableagreement. Analysisoftheisothermalcompressibilityofhydrogenrev ealedthatthehydrogenin MOF-5isindeedliquid-like,withtheH 2 takingonit'sbulkliquidcompressibility valuewhentheexcessuptakesaturates.Thispotentialvali dationstudyshowedthat whencarefulattentionispayedtothedevelopmentofpotent ialenergyfunctions,the methodologyisaccurateenoughtobeusedasapredictivetoo lforstudyinghydrogen storage. Thetheoreticalandexperimentalresearchofanon-linearo pticalmaterial (MEPEPY)isdescribedinChapter5.Thismoleculeisofspeci alinterestduetothe factthat,whenfoundinit'scisandtransisomers,itposses sesbothstrongandweak eldligandcharacteristics{forthisreason,MEPEPY(when coordinatedtoahighspinmetalsuchasironorcobalt)mayhaveapplicationsasam olecularphotoswitch. Theground-stateenergysurfaceforbothisomersofMEPEPYw ascalculatedusing DensityFunctionalTheory,anditwasfoundthatthereisasu bstantialbarrierto groundstateinterconversionbetweentwodistincttransst ates.Inaddition,theenergy dierencebetweentheisomericformsrevealedthatthereis thelossofahydrogen 2

PAGE 17

bondinsolution.Finally,electrostaticanalysisreveale dthatthedierenceindipole betweenthetwoisomerswasnegligible,andthuselectrores trictionwouldbeminimal forPACexperiments. Chapter6describesaninterestingcollaborativetheoreti cal/experimentalstudy onthestabilityandassemblyofanovelMetal-OrganicCube( MOC).Electronicstucturescalculationswereundertakentoanswerthequestiono fwhetherananocubewas presentinsolution.Theoreticalcalculations,whencombi nedwithNMRandMALDITOFexperiments,areshowntobeapowerfultoolforundersta ndingnon-crystalline discreteMetal-OrganicPolyhedra. Ithasbeenreportedthatanymaterialcapableofmeetingthe DOE2012criteriaforhydrogenstoragemustreversiblysorbH 2 withabindingenthalpyofatleast 20kJ/mol.[3]InChapter7theoreticalcalculationshavebe enperformedtoaddress thefollowingquestion:\whatisthemaximumbindingenthal pyattainablethrough purelyorganicmoietiessuchasbenzenerings?".Furthermo re,theoptimalsizeof thenanosquaregivingrisetothismaximalvalueof14kJ/mol hasbeendetermined andanewMetal-OrganicFramework,ME193,hasbeensynthesi zedtohaveahigh isostericheatofadsorptionbaseduponthiswork. Themany-bodypolarizationmethodsusedintheaforementio nedcalculations resultinanadditionalorderofmagnitudecomputationalco stbeyondtheclassical MonteCarlosimulations.[4]Whilethiscostifnotashighas performing abinitio MD,theadditionaldemandrequiresHPCresourcesthataresu bstantial.InChapter 8,newmethodsofsolvingtheself-consistenteldequation sarepresentedandshown todecreasethiscostgreatly.Iterativetechniquesusinga novelrankingschemeas appliedtoGauss-Seideliterations,alongwithaprecondit ioningtransformation,are showntoyieldaccuratepolarizationenergies(suitablefo rMonteCarlo)evenasa 2-stepiterationscheme.Itisexpectedthatthistechnique willreplacethemore conventialSimultaneousOver-Relaxationmethod(i.e.lin earmixing)andbecome 3

PAGE 18

thedominantmeansofincludingelectrostaticpolarizatio ninbothmaterialsand biologicalsimulation. InChapter9,amethodologyandcodebaseispresentedthatal lowstherotationalenergylevelsofhydrogentobecalculatedinthevi cinityofasurface.The rotationalenergylevelsarefoundthroughdirectdiagonal izationofthehamiltonian inasphericalharmonicbasis,foreachH 2 subjecttothepotentialenergysurface ofthematerial.Tunnelsplittingeectsaredemonstrated, aswellallowingforthe inclusionof ortho/para nuclearspinstatestobeincludedinGCMCsorptionstudies. ThiscodehasbeenimplementedintoMPMCandmaybeusedtocal culaterotational RamanorInelasticNeutronScattering(INS)spectra. AsseeninChapters3and4,inclusionofquantumnucleardisp ersioniscritical toattainingquantitativeaccuracywithexperimentunderc onditionsof77K.[2,5] Whileacommonmethodofincludingtheseeectsisthroughpa thintegralMonte Carlo,yetanotherstraight-forwardapproachisthroughth eFeynman-Hibbseective potentialformalism.[6]However,bothPIMCandtheFHeect iveapproachhaveonly beenderivedforthecanonicalensemble.InChapter10,wede riveaneectivepartitionfunctionforthemicrocanonicalensemble,suitablefo rusewithMicrocanonical MonteCarlo[7,8]orMolecularDynamicsmethods. Chapter11dealswiththedevelopmentofanalternativeappr oachtoderiving thepartitionfunctionofstatisticalmechanics.Thisappr oachisuniqueinthatit makesdirectconnectionwiththefundamentalnotionsofent ropyandthermodynamics,andoerstheappealthatthepartitionfunctionforany ensemblemaybederived easilyandinformulaicfashion.Inaddition,connectionsa remadetogeneralized ensembletheoryandit'suseinbothpedagogyandresearchis discussed. Moleculardynamicsstudiesofmyoglobinandaspartateamin otransferaseare describedinChapter12andshowntobeaneectiveandaccura tetoolfordetermining themolarvolumeofproteinsinsolution. 4

PAGE 19

Finally,theMassivelyParallelMonteCarlocodebase(MPMC ),developedby theauthorinordertoperformmanyofthecalculationsinthi swork,isdescribedin Chapter13. 5

PAGE 20

Chapter2 OntheMechanismofHydrogenStorageinaMetal-OrganicFram ework (MOF)Material MonteCarlosimulationswereperformedmodelinghydrogens orptioninarecently synthesizedmetal-organicframeworkmaterial(MOF)thate xhibitslargemolecular hydrogenuptakecapacity.TheMOFisremarkablebecauseat7 8Kand1.0atmosphereitsorbshydrogenatadensitynearthatofliquidhydr ogen(at20Kand1.0 atmosphere)whenconsideringH 2 densityinthepores.UnlikemostotherMOF's thathavebeeninvestigatedforhydrogenstorage,ithasahi ghlyionicframework andmanyrelativelysmallchannels.Thesimulationsdemons tratethatitisbothof thesephysicalcharacteristicsthatleadtorelativelystr onghydrogeninteractionsin theMOFandultimatelylargehydrogenuptake.Microscopica lly,hydrogeninteracts withtheMOF via threeprincipleattractivepotentialenergycontribution s:Vander Waals,charge-quadrupoleandinduction.Previoussimulat ionsofhydrogenstorage inMOF'sandothermaterialshavenotfocusedontheroleofpo larizationeects,but theyaredemonstratedheretobethedominantcontributiont ohydrogenphysisorption.Indeed,polarizationinteractionsintheMOFleadtot wodistinctpopulations ofdipolarhydrogenthatareidentiedfromthesimulations thatshouldbeexperimentallydiscernibleusing, e.g. Ramanspectroscopy.Sincepolarizationinteractions aresignicantlyenhancedbythepresenceofachargedframe workwithnarrowpores, 6

PAGE 21

MOF'sareexcellenthydrogenstoragecandidates.2.1IntroductionAmajorobstacleinachievingahydrogen-basedfueleconomy istheabilitytostore andtransportmolecularhydrogensafely-atreasonabletem peraturesandpressures. Forexample,atoneatmosphere,hydrogendoesnotliquefyun til20K[9]becauseof itsrelativelyweakintermolecularinteractions,makingt hetransportofneathydrogendicult.Thus,ndingmaterialscapableofstoringlarg eamountsofdiatomic hydrogenisapromisingavenue.Thechallengeisthathydrog entypicallyinteracts weaklywithitsenvironment.However,hydrogenmoleculesc aninteractstronglywith somematerials,byundergoingchemisorptionordissociati on,butsuchmaterialsare typicallyinadequateforhydrogenstoragebecauseitisdi culttoreleasethestored gaswhenitisneeded.[10,11]Ontheotherhand,materialsth atphysisorbmolecular hydrogenoerthepromiseofstoringitundermoderatecondi tionsandtheability toreleasethehydrogenfacilely.Suchamaterialwouldrequ ireoptimizingtheattractiveintermolecularinteractionsbetweenthehydroge nandthecondensedphase environmentand,atthesametime,enhancingH 2 -H 2 interactions,thusleadingtoa favorablesorptionenthalpy.Theexperimental[12{15]and theoretical[16{18]study ofthisuniqueproblemhasbecomeanareaofintenseresearch inrecentyears,witha diverserangeofprospectivecandidatematerialsbeingstu died. Metal-organicframeworkmaterials(MOF's)areaclassofma terialsthathave alreadyshownpromiseforhydrogenstorage.[19,20]MOF'sr epresentanovelclass ofsolidcrystallinematerialsthatarebuiltwithrigidorg anicligandslinkedtometalcontainingclusters(alsoknownassecondarybuildingunit sorSBUs)[21]Theycan beconstructedtohavelargesurfaceareas,arerelativelyl ightweightandcanbeassembledfrommolecularbuildingblockswithdesiredchemic alfunctionality.Recently, aMOFwasreported[19](referredtohereas soc -MOF)thatwassynthesizedusing 7

PAGE 22

anovelindiumtrimerbuildingblockthatresultedinananop orousmaterialwithan ionicframework,narrowchannels(around1nmindiameter)a ndnanometerscale carcerandcapsules.TheMOFhasarare soc topology[22]( e.g. notfoundinzeolites) characterizedbyit'ssquare-octahedralconnectivitynet .[23]Themolecularformula, [In 3 O(C 16 N 2 O 8 H 6 ) 1 : 5 ](NO 3 ),includesionically-boundnitrateanionsproximaltothe indiumtrimer.ThecationicindiumoftheSBUpossessesanop en-coordinationsite which,alongwiththeboundnitrateanion,contributestowa rdgivingtheframeworkahighlyioniccharacter.Theunit-cellhasbeenvisual izedwiththecarcerand capsuleslocatedinthecenter,whereeachcapsulecontains tetrahedrally-positioned nitrateanions.TheMOFpossessesanestimated57%extra-fr ameworkvolume,a largeLangmuirsurfaceareaof1417m 2 and0.50cm 3 g 1 porevolume.[19] Figure2.1showssnapshotsof soc -MOFaloneandwithahydrogendensity isosurfacecalculatedfromsimulation(describedbelow). Thehydrogenisresident intheextra-frameworkvolumeandFigure2.1servestovisua llyhighlightthepore topologywithin soc -MOF.Hydrogenuptakestudieson soc -MOFshowalargestorage capacitywithreversiblesorption.Forexample,at78Kand1 .0atmosphere,the densityofH 2 intheporesisapproximately0.05gcm 3 whileliquidhydrogenat itsboilingpointof20Khasadensityof0.07gcm 3 .[19]Theexperimentsare conductedatliquidnitrogentemperatureasasteptowardn dingsuperiorhydrogen storagematerialsthatwillultimatelyoperateatroomtemp erature.[1]Thispore densityofH 2 representsacompressionfactor,comparedtotheidealgasv olume underthesameconditions,ofapproximately100.Hydrogens orptionisothermswere measuredat78Kon soc -MOFandshowedthattheporeswerelledatrelatively lowerpressure.[19]TheMOFapproachedsaturationat1.0at mosphere,indicativeof thenearliquiddensityofthesorbedhydrogen. Thus,toinvestigatethephysicalbasisofthelargehydroge nuptake,canonical MonteCarlosimulationswereperformedonhydrogenin soc -MOF(attheexperimen8

PAGE 23

(a) soc -MOFempty (b) soc -MOFpopulated Figure2.1:Thisillustrationshowsthe soc -MOFbothemptyandpopulated via simulationof113H 2 withapolarizablemodel.Thehydrogendensityisrepresent ed bya90%populatedisosurface(generatedbyacustommodulew rittenforDataExplorer[24{26])andhasbeenrenderedwithaclippingplanef orclarity.Itshouldbe notedthattheindium(yellow)trimersarenotdepictedasbe ingbonded,strictlyin ordertoenhancethevisibilityofthestructure. 9

PAGE 24

tallyobservedhydrogendensityat78Kand1.0atmosphere). Since soc -MOFhasa highlychargedlatticewithnarrowpores,simulationswere performedwithandwithoutexplicitmany-bodypolarization[27{30]contribution s,incontrasttomostextant molecularsimulations.Molecularhydrogen'sattractivei nteractionsinaheterogeneouscondensedphasematrix( e.g. MOF's,carbonnanostructuresandzeolites)are dominatedbythreeintermolecularcontributions:VanderW aals,charge-quadrupole, andinduction.Asanestimateoftherelativeimportanceofq uadrupole(thataretypicallyaccountedfor)andpolarization(usuallyneglected) terms,considerapolarizable sitewithapointquadrupole,bothofthemagnitudeappropri ateformolecularhydrogenplaced0.30nmdistantfromadouble-chargedcation(rep resenting, e.g. indiumin achargestatesimilartothatin soc -MOF).Giventhemostfavorablegeometryforthe quadrupolarinteractions,thepolarizationenergyisafac torof4largerandisalways attractive.Clearly,polarizationisnotnegligibleandne edstobeincludedinsome fashion.Below,wedemonstratethatincludingmany-bodypo larizationexplicitlyhas adramaticeectonthephysisorptionofhydrogento soc -MOF,evencomparedto explicitlyincludinginductionasaone-bodyinteraction. Further,theseobservationssuggestthatpolarizationnee dstobeincluded inmodelinghydrogensorptioninavarietyofmaterials,ess entiallybecausethe quadrupoleinteractionsarerelativelyweak.Note, abinitio moleculardynamics(MD) simulationsofmolecularhydrogeninanotherMOF(MOF-5)ha vebeenpreviously performed[31]andimplicitlyincludeareasonablyaccurat erepresentationofpolarizationinteractions.Unfortunately,thehighcostofperform ing abinitio MDsimulations limitssuchnitetemperatureinvestigationstoveryshort times,althoughtheyare quiteeectiveatndingminimumenergycongurations. 10

PAGE 25

2.2ModelsandMethods2.2.1MolecularSimulationParametersAvarietyoftheoreticalmethodologieshavebeenusedtostu dyhydrogensorptionin nanostructuredmaterials.[32{35]Recentstudiesinclude MD,grand-canonicalMonte Carlosimulationstopermitcalculationofsorptionisothe rms,electronicstructure studiestoinvestigatebindingmechanisms/anitiesandse mi-classicalsimulations thatdierentiatetheinteractionof ortho and para hydrogenwithamaterial(relevantatverylowtemperatureswhereneutrondiractionstu diesareperformedto characterizeunderlyinghydrogeninteractionsites).[16 ,31{33,35{57] Here,classicalMonteCarlosimulationmethodswerechosen tostudy soc MOFinordertoperformequilibriumnitetemperaturesimul ationsandtobeable toexplicitlystudytheroleofinductioninhydrogensorpti on.Note,arecentstudy modelinghydrogensorptioninMOFmaterials[16]hasshownt hat,undertherelativelylowtemperatureconditionsstudiedhere,aquantum statisticalmechanical descriptionofthehydrogenstructureisrequiredtoobtain quantitativeaccuracy. Theearlierworkincludednuclearquantumdispersioneect s via thecomputationallyintensivepathintegralMonteCarlosimulations(PIMC ),butdidnotinclude electronicinduction.Theresultsshowedadecreasedsorpt ionof10-15%relativeto thepurelyclassicalsimulations.However,thatstudyalso showedthattheuncertaintiesintheBorn-Oppenheimerpotentialsurfacewerethedom inantsourceoferrorin thesimulations.Giventhatitiscomputationallyprohibit ivetoperformPIMCsimulationsincludingpolarization,thepresentstudywillfo cusontheroleofelectronic polarizationwithinaclassicalmodel.Giventhepriorwork ,ourestimatesofhydrogensorptionstrengthmaybeaslightoverestimateandthepr esentworkwillfocus onthecriticalrolethatpolarizationplaysinshapingtheB orn-Oppenheimersurface. Includingquantumdispersioneectswillthesubjectoffut ureinvestigations. 11

PAGE 26

Criticaltoanyclassicalsimulationbasedonempiricalpot entialsisthecareful selectionofforceeldparameters.Aminimal,yeteective ,forceeldneedstoincludeelectrostatic,repulsiveandvanderWaals-typeinte ractions;[58,59]accurately describingthetotalpotentialenergysurfaceisessential andtherelevantparametersarenotespeciallywell-characterizedforMOF's.Thus ,strivingforsimplicityin thisinitialstudy,theneedforframeworkintramoleculari nteractionswasavoidedby holdingthescaoldrigidduringsimulation.Phononsareno tthoughttoplayan importantroleinhydrogensorption,especiallynotatthet emperaturesconsidered here.[34]Lennard-Jonesparameters,representingrepuls iveandvanderWaalsinteractionsbetweenhydrogenatomsandframeworkweretakenfro mtheUniversalForce Field;[60]thissetofparameterswasusedinearlierMOFstu dies.[16,35,44,57]The UFFinteractionsareparameterizedforenergeticsbetween likeatomsandallother interactionsareaccountedforinastandardwayusing(thea pproximate)LorentzBerthelotmixingrules.[58,60] Whenneglectingpolarizability,electrostaticinteracti onsinatomisticsimulationsstemfrompoint(partial)chargesassignedtothecoor dinatecorrespondingto thenuclearcenterofeachatom.Sincethetrueelectrostati cpotentialenergysurfaceof soc -MOFisunknownand abinitio calculationsonthe soc -MOFunitcellare computationallyprohibitive,pointchargesweredetermin edfromelectronicstructure calculationsonseveralmodelcompoundsthatmimicthechem icalenvironmentofthe MOFatoms.[35]TheGAMESS abinitio simulationpackagewasusedtoperform theHartree-Fockquantummechanicalcalculations.[61] Thestructureof soc -MOFischaracterizedbycorner-sharingoctahedralindiumtrimersjoinedbybent1,3-benzenedicarboxylateorga niclinkers.ThreerepresentativefragmentsareshowninFigure2.2.Theyallproduc edsimilarpartialcharges towithin10%onaverage,andtheelectrostaticparametersu sedwerederivedfrom thelargestofthecandidates-theresultsarepresentedinT able2.1. 12

PAGE 27

(a)fragmentA (b)fragmentB (c)fragmentC Figure2.2:Illustrationsdepictingthefragmentsusedint he abinitio calculationof thepartialcharges.StructureAisanSBUwithsixboundlink ers,essentiallyone completecornerofapore.StructureB,twoSBUscoupledbyon elinker,canbe regardedastheedgeofapore.StructureCisessentiallythe bareSBUusedin thedesignof soc -MOF.Notethatforclarity,thenitrateanionsarenotdepic tedin fragmentsBandCofthegure(buttheywereincludedinallca lculations). 13

PAGE 28

Atom Label Charge(e ) In 1 2.0697 O 2 -0.7588 C 3 0.9108 C 4 -0.1086 C 5 -0.2252 H 6 0.1366 C 7 0.3785 N 8 -0.2243 C 9 -0.1327 H 10 0.2167 O 11 -1.3978 N(nitrate) 12 0.6934 O(nitrate) 13 -0.4652 Table2.1:Partialchargestakenfromthefragment2.2(a)us edinsimulationof soc MOF Atom Label Charge(e ) In 1 2.228 O 2 -0.8216 C 3 0.9652 C 4 -0.1286 C 5 -0.2622 H 6 0.1443 C 7 0.4631 N 8 -0.2111 C 9 -0.2150 H 10 0.1854 O 11 -1.5424 N(nitrate) 12 1.029 O(nitrate) 13 -0.6424 Table2.2:PartialchargesforthefragmentinFigure2.2(b) forcomparison 14

PAGE 29

StudyofthelatticeshowninFigure2.1revealstherepetiti onofcertainstructuresinavarietyofgeometrieswithintheunitcell(forade taileddiscussionofthe structureseetheliterature).[19]The448atomunitcellma ybeproducedfrom crystallographicsymmetryoperationsfromonlytwentyato ms.[19,22]Althoughthis typeofsymmetrycannotbetakenadvantageofbyquantumsimu lationpackages, thisrepetitionwasusedasabasisfordecidingonrepresent ativechemicalfragments. Thelargestfragmentswerechosentoincludeatleastonecom pletemetalcenterand anazobenzenelinker;thesmallestistheloneSBU.Addinghy drogenatomswhere appropriatewasrequiredforchemicalterminationofthefr agmentboundaries.Measurementsfromthecrystalstructureindicatethattheenvi ronmentsoftheazobenzene linkersareessentiallychemicallyequivalentinthatthei rinterfacewiththemetalcentersdiersveryslightly.Deningtheazobenzenelinkersa sallchemicallyequivalent allowstheentireunitcelltobedenedintermsofonlythirt eenchemicallydierentatoms.Usingtheelectrostaticpotentialsurfacefromt he abinitio calculations, atomicpointchargesweretusingastandardalgorithm.[61 ,62] Since soc -MOFandourmodelfragmentscontainmany-electronmetalat oms (indium),theinnerelectronsrequiretreatment via relativisticmethods.Herewe usesemi-relativisticpseudopotentials,andtwowerecomp ared,namelySBKJCand LANL2[63{65]thatincludeadierentnumberofexplicitele ctronsforindium(36 and12,respectively)butgavesimilarresults.Thelightat omsweretreatedatthe 6-31G levelthatproducesover-polarizedchargesappropriatefo rcondensedphase simulations(toaccount,inaneectiveway,fortheeectof self-inductionofthe unpopulatedlattice).[66]Asafurthertestofthe abinitio calculations,relativistic electronicstructurecalculationswereperformedonthesm allestfragment(without needforpseudopotentials)usingathird-orderDouglas-Kr olltransformationandthe correspondingDK3basisset.[67]Theresultingchargesagr eedwithin7.0%ofthose usedinthisstudy;thechargesusedhereinaretabulatedinT able2.1.Note,the 15

PAGE 30

condensedphasepolarizationoftheneatMOFisincludedimp licitly,whilethepolarizationinteractionsinoursimulationsbetweenthehyd rogenandtheMOFwillbe treatedexplicitly. Partialchargesforhydrogenwerechosentoreproducethequ adrupolemoment ofthemolecule.[40]Thehydrogenisalsotreatedasrigidan ditshighfrequency vibrationisnotexpectedtocontributetosorption.[40]Th eelectrostaticmodelisa three-pointmodelwithachargelocatedatthecenterofmass .Thehydrogenatoms areseparatedby0.741 Aandinteract(betweendistinctmolecules) via apolarizable many-bodypotential,alongwiththeCoulombicandUFF-den edLennard-Jones intermolecularpairpotentials.2.2.2PolarizabilityModelMolecularpolarizationwasexplicitlyincludedintheMont eCarlosimulationsby useoftheThole-Applequistmodel.[27{29]Thismodeltreat sthesysteminterms ofsite(atomic)pointdipolesthatinteract via many-bodypolarizationequations. Onceatomicpointpolarizabilitiesarettoatrainingseto fmoleculesthemodel hasbeenshowntoaccuratelyreproducemolecular/systemdi polesinatransferable ( i.e. system-independent)manner.[27,29]Thismodelofexplici tpolarizationhas beensuccessfullyappliedinnumerousareaswhereinclusio nofpolarizableeectsis paramount,suchasvibrationalspectroscopy,[30,68,69]l iquiddynamics,[70{73]and biomolecules.[74,75] Considerastaticelectriceldappliedtoamolecule.Thein duceddipoleon thismoleculewillbeequalto ~ mol = mol ~ E stat (2.1) where mol isthe3 3molecularpolarizabilitytensoruniquetothatmolecule. We 16

PAGE 31

nowconsiderthemoleculardipoleasbeingasumofatomicpoi ntdipoles,onefor eachatomofthemolecule.Ifwelabeleachatomicpointdipol evector ~ i thenwe have ~ i = i ~ E stat i (2.2) ~ mol = N X i ~ i where i isthe3 3sitepolarizabilitytensorand ~ E stat i istheelectrostaticeldat thesite.IntheThole-Applequistmodelthesystemistreate dasacollectionof N dipolesalongwithadipoleeldtensor T ij whichcontainsthecompletesetofinduced dipole-dipoleinteractions.Thisdipoleeldtensor,when contractedwiththesystem dipoles,yieldsthe(many-body)induced-dipolecontribut iontotheelectriceld-this contributionisdenotedhereas ~ E ind .Sincethedipoleeldtensor(byconstruction) containstheentireinductioncontribution,wecanassigna scalar pointpolarizability, i ,toeachsiteratherthanapolarizabilitytensor: i ~ E stat i = i ~ E stat i + ~ E ind i (2.3) = i ~ E stat i T ij ~ j (2.4) Thisequivalencecanbedemonstratedbyreproducingthesit epolarizabilitytensors via A~ = ~ E stat (2.5) ~ = B ~ E stat (2.6) 17

PAGE 32

where ~ and ~ E stat aresupervectorsformedbystackingthesystemdipole/eld vectors: ~ = 0BBBBBBBB@ ~ 1 ~ 2 ~ 3 ~ N 1CCCCCCCCA ~ E stat = 0BBBBBBBBB@ ~ E stat 1 ~ E stat 2 ~ E stat 3 ~ E stat N 1CCCCCCCCCA andthematrices A and B aredenedby A = h ( ) 1 + T ij i (2.7) B = A 1 Justas A isasupermatrixcomposedof3 3blockelements T ij B canbe decomposedas[29] B = 0BB@ B 11 B 12 B 1 N B 21 B 22 B N 1 B NN 1CCA whereeachblockelement B ij isa3 3matrix.Theseblockelements B ij arethesite polarizabilitytensorsandthuscharacterizethesite'sre sponsetoanelectriceld.For example,thematrix B formedbysummingthe th rowof B B =( B 1 + B 2 + ::: + B N ) 18

PAGE 33

determinesthedipoleresponsetoaeldforsite asafunctionofall N sitessince (makinguseofEquation2.6) ~ = B 1 ~ E stat 1 + B 2 ~ E stat 2 + ::: + B N ~ E stat N = ~ (1)+ ~ (2)+ ::: + ~ ( N ) wherebyeach termrepresentsacontributiontoward 'sdipole.Therefore,summing allofthe ij blocksoverthetensorcomponents foranappropriatesetofsitesyields themolecularpolarizabilitytensor:[29] mol = X i;j ( B ij ) (2.8) TheApplequistdipoleeldtensor[27]canbederivedfromr stprinciplesas T ij = r r 1 r ij = r 3 ij 3 x x r 5 ij (2.9) Themostdirectwaytocalculatethesystemdipolesisthroug hEquation2.6. However,sinceinversionofthe3 N 3 N matrix A iscomputationallyecientfor onlythesmallestsystemsthedipolesmustbesolvedforbyan iterativemethod.The iterativemethodemployedheremakesaninitialguessof ~ i = i ~ E stat i andthen iterativelysolvesEquation2.4untilconvergenceisachie ved. TheTholemodelintroducestheadditionalconsiderationof treatingeach dipoleasinteractingwithawell-behavedchargedistribut ion ( u )(incontrastto theApplequistmodelwherethedipoleeldtensorisderived byconsideringadipole interactingwithapointcharge,givingrisetoEquation2.9 ),whichresultsinamod19

PAGE 34

iedformofthedipoleeldtensor.Thenetresultofthismod icationisthatthe chargewhichinduceseachdipoleis\smeared"atshortrange ,anditisthisadditionalstructurethatTholeaddedtothemodelwhichimparts transferability.One suchexponentialdistribution[28]foundtoaccuratelyand transferably[29]reproduce moleculardipolesforanassociatedseriesofdependentpol arizabilitiesis ( u ij )= 3 8 e u ij (2.10) u ij = x ij i j 1 6 wherethefreeparameter hastheeectofdampingthedipoleinteractionsnear theregionsofdiscontinuitythatwouldotherwiseexistint heApplequistmodel.The coordinatescalingof x ij u ij isdoneforconvenienceinordertoallowsimplefunctionalformssuchasEquation2.10tobeusedfordamping.Tak ingtheexponential chargedistributionintoaccount,themodieddipoleeldt ensorbecomes[29] ^ T ij = r 3 ij 1 2 r 2 ij 2 + r ij +1 e r ij 3 x x r 5 ij 1 3 r 3 ij 6 + 2 r 2 ij 2 + r ij +1 e r ij (2.11) Themany-bodypotentialenergyduetotheinteractionofthe induceddipoles (referredtoasthepolarizationenergy)isdescribedby[28 ] U pol = X i 1 2 ~ i A~ i ~ i ~ E stat i = X i 1 2 ~ i ~ E stat i ~ i ~ E stat i = 1 2 X i ~ i ~ E stat i (2.12) 20

PAGE 35

whereitshouldbepointedoutthat ~ E stat i isnotthetotalelectriceld,butrather onlythestaticelectriceldduetothepresenceoftheparti alchargespresentinthe system. Calculatingthepolarizationenergyforthesystemamounts toself-consistently solvingthedipoleeldequationforeachatomicdipolevect or ~ i throughaniterative processuntilasucientdegreeofprecisionisachieved.Th us,tomakethecalculations practical,ecientmethodsofsolvingtheeldequationswe rerequired.Typically,a simultaneousover-relaxationscheme( i.e. linearsolutionmixing)isusedtoimprove theconvergenceratefortheiterativemethodofsolution.[ 71]However,recentlya numberofmultigridtechniques[76]havebeenappliedtothe Tholemodelforaonedimensionalsystem[77]andasimilarGauss-Seidelsmoothi ngtechniquewasapplied hereandfoundtoreducethenumberofiterationsrequiredfo rconvergencebytwofoldoverlinearmixing.TheappliedGauss-Seidelnumerica literationmethodfora slowlyconvergingprocessconsistsofupdatingthecurrent dipolevectorsetforthe k th iterationstepasthenewdipolevectorsbecomeavailable: ~ ki = i ~ E stat i ^ T ij ~ k 1+ j (2.13) = 0 ; if ij Dipoleswerecalculatedtoaprecisionof10 -4 Debye,andweresubjecttoa11.2 A(halftheunitcelllength)sphericalcuto.Sincetheatom icpointchargesofthe MOFwerecalculatedby abinitio toimplicitlyincludepolarization,MOF-MOFselfpolarizationwasdisallowedbyexcludingMOF-MOFelectric eldinteractionsand onlytheinducedeldinteractionsbetweentheH 2 andMOFatomswerecalculated. Allsystemdipoleswereallowedtointeractthroughtheexpo nentiallydampeddipole eldtensor(givenbyEquation2.11)subjecttotheconstrai ntofthesphericalcuto. Thepolarizabilitytensorofdiatomichydrogenwithanequi libriumbonddis21

PAGE 36

tanceof0.741 AwascalculatedbytherestrictedHartree-Fockmethodwith acorrelationconsistentdouble-zetabasisset[78](augcc-pVDZ)usingG AMESS.[61]Theatomic Tholepolarizabilitiesformolecularhydrogenwerethende terminedbytting mol to theHFpolarizabilitytensorformwhileatthesametimeyiel dingone-thirdofthe traceequaltotheexperimentallymeasured[79]H 2 polarizabilityof0.787 A 3 ;the valuesthatbestsatisedbothcriteriawerefoundtobe0.26 58 A 3 forHand0.5865 A 3 forthecenterofmasssite. TheSBUof soc -MOFcontainsindiumwhich,incomplex,hasapartialcharge ofaboutIn 2+ asttothecalculatedelectrostaticpotentialsurfaceoft hegas-phase fragment(seeTable2.1).Whilethepolarizabilityofclose dshellindiumisknown,[80] thepolarizabilityofindiuminthe2+statehasnotbeenpara meterizedpreviously fortheTholemodel,norhasitbeenexperimentallyelucidat ed.Inordertoascertain thepolarizability, abinitio simulationswereperformedusingnite-eldcalculations onIn 0 ,In 1+ ,In 2+ andIn 3+ .Toassurethattheresultsobtainedfromthenite-eld calculationswerereasonablethedatawascomparedtopolar izabilitiescalculatedwith ananalyticHessianfortheIn 1+ andIn 3+ states.Thusanestimateof2.0 A 3 forIn 2+ wasdeterminedfortheseresults;futureresearchwillbedi rectedatapplyingfullyrelativisticeldequationstotheSBUandttingthisparam eterwithintheThole model.TheremainderoftheMOFatomsweregiventheexponent ialpolarizabilities andassociateddampingparameterascalculatedbyDuijnene tal.[29] 2.2.3NVTMonteCarloMonteCarlo[81]simulationswereperformedontheH 2 -MOFsystemat78Kandwith theexperimentallydeterminedhydrogendensityof113mole culesperunitcell,[19] withperiodicboundaryconditionsapplied.Thetotalpoten tialforthesystemis describedby: 22

PAGE 37

U = U elect + U pol + U LJ (2.14) where U elect istheelectrostaticpotentialenergycalculatedfromtheE waldeld, U pol isthepolarizationenergycalculatedfromEquation2.12an d U LJ istheLennard-Jones potential. MonteCarlomovesweremadebyselectinganH 2 moleculeatrandom,and performingarandomrigid-bodytranslationandrotationof themolecule.TheMC movewasthenacceptedorrejectedaccordingtotheMetropol isfunction: min 1 ;e U (2.15) UsingsimpleMonteCarlomovesisnotespeciallydesirableg iventheneedtoentirely reevalulatethemany-bodypolarizationenergyaftereachs mallmove.Inanattempt tomakeglobalmovesthatwouldmoreecientlyexplorephase space,severalhybrid MonteCarloschemes[82,83]wereimplementedwithforcesth atwerecomputedfrom thenon-polarizablepotential.Unfortunately,thepotent ialenergysurfacesaresucientlydissimilarandtheapproachfailed;thisresult,ho wever,wasalsoanindication oftheessentialroleofpolarizationinteractionsinthiss ystem. TheMonteCarloalgorithmandmany-bodypolarizationcodew ereimplementedwithinapackageoriginallydevelopedbytheKleingr oupattheCenterfor MolecularModelingattheUniversityofPennsylvania.[84{ 87]Acellularautomatabased(rule30)pseudo-randomnumbergeneratorwasimpleme ntedforit'ssuperior randomnumberquality.[88,89]ThemagnitudeoftheMCmoves wereadjustedto yielda25%acceptancerateinordertominimizethecorrelat iontime.Autocorrelationofthepolarizationenergygaveacorrelationtimeof =25 ; 000MonteCarlo 23

PAGE 38

steps.Afterasystemequilibrationtimeof500,000steps,a tomiccongurationsand systemdipoleswerethensampledatintervalsof2 forthecollectionofuncorrelated statesofH 2 intheMOF.Atotalof17.5millionMCstepswerecalculatedon the massivelyparallelsupercomputerLoneStar(Teragrid/Uni versityofTexasatAustin) tosample350uncorrelatedcongurationsfromthecanonica lensemble. Non-polarizableMCruns,calculatingonlytheelectrostat icandLJtermsin Equation2.14,werealsoenactedforcomparison.Themagnit udeoftrialmovementwasabletobegreatlyincreasedandthepotentialenerg ycorrelationtimewas =2 ; 500MCsteps-anorderofmagnitudelessthanthatofthepolar izedsystem. Clearly,inclusionofthemany-bodypolarizablepotential greatlydecreasestheeciencyoftheMCtechnique(whenmakingsimpleone-bodytria lmoves) inaddition to thecomputationaloverheadintroducedbytheTholemodel;t hecalculationofthe systemdipolesconsumesapproximately95%ofthetotalCPUt ime.However,the computationalcostisstillfarbelowthatofperforming abinitio dynamics. Theradialdistributionfunction g ( r )wascalculatedbetweenthehydrogenand varioussitesontheMOFanderroranalysiswasperformedtoe nsuretheirconvergence.Isosurfaceanalysiswasperformedoverboththehydr ogenpopulationdensity andthehydrogendipolemagnitude.2.2.4HybridMonteCarloWhileMDsimulationswithmany-bodypolarizableforcescan yieldinsightintothe behaviorofcomplexsystems,theyarealsoreputedfortheir instabilityandcomplexityofimplementation;developmentofstableandecientpo larizabledynamicsis currentlyanactiveareaofresearchincomputationalchemi stryandphysics.[70{73] Thepolarizableforcesaretroublesomeandexpensivetocal culate;thepolarization potentialenergyis(relatively)lessproblematicandisea siertocompute via thedipole eldequations. 24

PAGE 39

OurinitialapproachwastoperformahybridMonteCarlo[82] (HMC)calculationwherebythepotentialenergy,especiallyincluding thepolarizationenergy,was usedintheMetropolisacceptancefunctionbutthesystemco ngurationwasglobally propagatedbyMDusing anon-polarizableforceeld .Inthisway,wewouldcircumventtheneedtocomputepolarizableforcesandyetproperly sampletheconguration spacethatwouldrerectpolarizationeects-allthewhile, gettingthebenetofshort correlationtimesandecientsamplingofphasespacedueto theglobalmovesbeingmade(asopposedtothelongcorrelationtimesthatarety picalofmany-body potentialsinthestandardMonteCarloscheme). Unfortunately,theaboveHMCapproachprovedunworkablefo ranumberof reasons.WhiletheHMCmethodhasbeendemonstratedtoworkw ellforLennardJonesruids[83]andfermionicparticles,[82]inasystemwi thmanydegreesoffreedom wefoundadicultyinthestandardmomentumresamplingsche methatisnot,to ourknowledge,specicallyaddressedintheliterature.It wasourexperiencethat completelyresamplingthemomentahinderedthemolecularr otationsofthesystem, eveninthenon-polarizablescenario,andthestructurefor bulkmolecularruidsthat wetested(suchashydrogenandwater)didnotaccuratelycor respondtotheknown structure,aswasevidentbythecomparisonofradialdistri butionfunctionsfrom MDandMonteCarlo.However,foraLennard-Jonessystem( i.e. possessingonly translationaldegreesoffreedom)thecompletemomentares amplingschemeyields thecorrectstructure.Ithasbeenclariedthatacompleter esamplingofmomenta fromaBoltzmanndistributionisnotrequired,[90]andinfa ctweimplementedan alternativemomentumupdaterecentlygivenintheliteratu re[91]wherebythemomentumvectorscanbelessdrasticallyperturbedandthenaM etropolisevaluation 25

PAGE 40

ofthekineticenergyisperformed: ~ p 0 = f ~p g + f ~ g min 1 ; exp p 0 2 2 m p 2 2 m where f ~p g isthesetofmomentumvectorsinthesystem, f ~ g isasetofvectors randomlysampledfromaBoltzmanndistributionand isafreeparameterused totunetheacceptanceratio.Thisupdateschemerestoredth ecorrectrotational dynamicsandstructureforthebulksystemsstudiedwithHMC .Whiletheprime motivationfortheinitialdevelopmentofalternativemome ntumresamplingschemes hasbeentodispensablyimprovetheeciency,itisourviewt hatlessdrasticmomentumresamplingisrequisiteinsimulatingsystemswithrota tionaldegreesoffreedom. However,asecond(unfortunatelyinsurmountable)dicult ywithutilizingHMCto study soc -MOFwasinusingapolarizableMCpotentialwithnon-polari zabledynamics:insituationswherethepolarizationeectsaresig nicant(e.g. soc -MOFat lowtemperature),thepolarizableandnon-polarizablepot entialenergysurfacesare simplydiscrepantenoughtopreventtheadequatesamplingo fphasespace(thisagain stressestheimportanceofpolarizationinteractionsforH 2 in soc -MOF).Thus,the computationallydemandingstandardMonteCarloschemewas implemented. 2.3ResultsandDiscussionTodemonstratetheeectofpolarizationonsorptionin soc -MOF,Figure2.3shows theradialdistributionfunctionbetweenthesorbedhydrog enandindiumionsboth wheninductionisincludedandneglected.Thepolarization interactionsstronglyinruencethestructureofthesorbedhydrogenintheregionoft hemetalions.The gurealsoshowsthedistributionfunctionwhenbothcharge -quadrupoleandinductioneectsareneglected-inthiscasehydrogenisinteract ingasaLennard-Jones 26

PAGE 41

specieswiththeMOFframework.Thus,thecharge-quadrupol einteractionsarealso makinganimportantcontributiontothesorptionstructure .Whiletheeectisless dramatic,theradialdistributionfunctionshowninFigure 2.4betweenthehydrogen andazobenzenenitrogenshowsthatthepolarizationeecto ftheazobenzeneisalso signicant. Figure2.3:Radialdistributionfunctionsbetweenthecent erofmassforthehydrogentotheindiumunderexperimentalconditionsforthre edierentpotentials: Thole-Applequistmany-bodypolarizablepotential(blue) ,non-polarizablepotential (orange)andLennard-Jonesonly(red). FurtherinsightisgainedbyexaminingthedistributionofH 2 induceddipoles thatareproducedbytheeldfromthechargesontheMOF(prev ioussimulationsin thisstudyshowthatthecontributiontowardMOFpolarizati onfromthequadrupolarhydrogen-hydrogeninteractionsarenegligible-yet,f orcompleteness,theywere alsoincludedhere).Figure2.5plotsthedistributionofin duceddipolesthatisapproximatelyabi-modalGaussiandistributionwithadomina ntlowdipolar(78%of thepopulationwithameandipole0.18Debye)andhighdipola rspecies(22%ofthe populationwithameandipole0.33Debye).Analysisofmolec ulardipolemagnitude isosurfacesrevealsthatthelowdipolarpopulationcorres pondstospatialregionslo27

PAGE 42

Figure2.4:Radialdistributionfunctionsbetweenthecent erofmassforthehydrogentotheazonitrogenunderexperimentalconditionsforth reedierentpotentials: Thole-Applequistmany-bodypolarizablepotential(blue) ,non-polarizablepotential (orange)andLennard-Jonesonly(red).calizedinthevicinityoftheopencoordinationsitesofthe SBU's(showninFigure 2.6),whilethehighdipolarpopulationislocalizedinthem iddleofthewindowformed bytheazobenzenelinkers.Thereasonforthehighdipoledis tributionbeingassociatedwiththeazobenzenelinkersseemstobeduetothefactth atthelocationofthe windowisgeometricallyproximaltoallofthedominantlych argedstructures,namely theindiumcomplex,nitrateanionandazolinkage.Enhancem entoftherstneighborpeakoftheradialdistributionfunctiontothenitrogen oftheazobenzene,shown inFigure2.4,wouldseemtosupportthis.Thelowdipolarpop ulationisassociated withtheelectriceldofthepositivelychargedandhighlyp olarizableindiumionsof theSBU.Theopencoordinationsiteoftheindiumalsopermit shydrogentostrongly associatewiththemetalionsasshowninFigure2.1. Toputthemagnitudeofthedipolesincontext,ifweconsider thehydrogen intheMOFapolardiatomicliquidwithadipolecharacterist icofthedominant speciesof0.18Debye,thismagnitudeiscomparabletothepe rmanentdipolesofNO 28

PAGE 43

Figure2.5:Bi-modalH 2 moleculardipolemagnitudedistributionfor soc -MOFat78 Kundertheexperimentaldensity.Thegurepresentsatoft hedipoledistributions totwodecomposedGaussiandistributions.(0.16Debye)orCO(0.11Debye)thathaveambientboilingpoi ntsof121Kand82 Krespectively.Thus,whileneathydrogenat78Khasaneglig ibleinduceddipole (andisessentiallyanidealgaswithPV/NkT=1.00),[9]theh ydrogenintheMOF experiencesmutual,many-body,dipolarattractions.Thus ,itisreasonablethatit isnearlycondensedintheMOFporesattheconditionsconsid eredhereandinthe experimentat78K. ToassesstheimportanceofpolarizationeectsinaMOFwith alesspolar framework,weusedthesameforceeldparametersandcharge ttingprotocolstodevelopapotentialenergysurfaceforthemuchstudiedIRMOF1(a.k.a.MOF-5).[20] Simulationsincludingmany-bodypolarizationforIRMOF-1 [20]revealnosignicant changeinradialdistributionfunctionsforthehydrogento themetal-centeredSBU whencomparedtosimulationsneglectinginduction.MOF-5, whichsorbssubstantiallylesshydrogenthanthenewmaterialstudiedhereunde rlikeconditions,also doesnotpossessanopencoordinationsiteonit'szincSBUan dthusproducesamore weaklypolarizingeldincomparisonwith soc -MOF.Mostimportantly,MOF-5does 29

PAGE 44

(a)0.18Disosurface (b)0.33Disosurface Figure2.6:Isosurfacesshowingthelow-dipolarandhigh-d ipolarhydrogenspecies correspondingtotherespectivepeaksofthebi-modalhydro gendipoledistribution. Notethelocationoftheindiumopencoordinationsites(red )andthenitrateanions (lowercornersoftheboxmostvisible)withrespecttothehi gh-dipolarisosurface. 30

PAGE 45

notpossessnarrowchannelsorahighlypolarframework,but ratherhasanopen topologywithlargervoidspaces.Thiscomparisonstrongly suggeststhatMOF's, likeMOF-5,withlargeporesarenotthebesttargetmaterial sforsuperhydrogen storage. Thekeyresultofthisstudyisthathydrogenneedstointerac tsuciently stronglywithaMOFtoproduceadipolarruidwithacharacter isticallyhighercondensationtemperature. Recently,hydrogenstorageinaMn-containingMOFwasstudi ed[92]inwhich asimilarsorptionisothermasthatof soc -MOFwasmeasured;thisMOFalsopossesses relativelynarrowchannelsandapolarframework.Thiscubi ctopologyMOFcontains anMn 2+ opencoordinationsiteontheSBU;itisnotunreasonablethe ntoassume thatthehighsorptioncapacityofhydrogeninboththatmate rialand soc -MOFare correlatedwiththestructuralmotifoftheSBU.Thedipolei sosurfacesgenerated bythisworkwouldsuggestthattheopencoordinationsitess ervetopolarizethe hydrogenundertheexperimentalconditions. Usingthepolarizablepotential,theintegralenthalpyofa dsorptionforthe hydrogenin soc -MOFwascalculatedby: H a = E ( MOF + H 2 ) [ E ( MOF )+ E ( H 2 )] NotethatthePVtermsarenegligibleinthiscase.Tobeclear ,theenergyfor theMOFwith N hydrogenmoleculespresentiscalculatedandthensubtract edfrom thecombinedenergyfortheMOFaloneandtheneatgasof N hydrogenmolecules;the energyisthendividedbythenumberofmolescorrespondingt othe N molecules.The integralenthalpywascalculatedatboththesaturatedstat e(113hydrogenmolecules perunitcell)andthezero-loadinglimit(asinglehydrogen moleculeperunitcell). Itisimportanttonotethatthisdiersfromtheexperimenta llymeasured 31

PAGE 46

isostericheatofadsorption, q st inthatwearecalculatingtheintegratedenergyper moleofadsorbent.Thenumbersareexpectedtobeverysimila r,however,forthe followingreasons:theisostericheatisgivenby q st = kT 2 @ ln P @T whilethedierentialenthalpyisequalto h a = kT 2 @ ln f @T where f = P isthefugacityand isthefugacitycoecient.[16,93,94]Thecondition forthesequantitiestobeequalisthatthetemperaturedepe ndenceofthefugacity coecientissmall,namely: 1 @ @T 1 P @P @T ,arequirementthatisclearlymetunderthe sorptionsconditionsconsideredherewherethehydrogenst ructureisnotchanging dramaticallywithtemperature(notethatevenforanidealg as,the @ ln P @T termhasa strong 1 T dependence).Tocompletetheargument,note(considering soc -MOF)there isaweakdependenceonloadingintheisostericheatmeasure ments;[19]andinthe limitthat q st h a isconstantitisequaltothetheintegraladsorptionheat,m aking acomparisonreasonable.[93,94] H a sat wasfoundtobe-10.645 0.188kJmol 1 whiletheunsaturatedstate yielded H a unsat of-14.354 1.685kJmol 1 ;therelativelyconstant H a valuesindicatetheretentionofstrongattractiveinteractionseve nathigherloadings,whichis alsosupportedbytheexperimentallymeasuredisosteriche ats.[19]Polarizationcontributed23%ofthetotalpotentialenergyatsaturationand 27%whenunsaturated. Theseenthalpiesappearlargecomparedtotheexperimental measurementsthatgive 32

PAGE 47

arelativelyconstantisostericheatofsorptionofabout6. 5kJmol 1 .[19]Thus,as acontrol,theintegralheatsofsorptioninIRMOF-1atthelo wdensitylimitwere calculatedtocomparewithexistingexperimental[20]andt heoretical[16]values.The resultwas H a unsat =-5.998 0.298kJmol 1 ,ingoodagreementwithextantvalues. Includingpolarizationgaveavalueof H a unsat =-6.343 0.277kJmol 1 ,consistent withtheresultthatincludingpolarizationinsimulatings aturatedIRMOF-1didnot signicantlychangethehydrogenstructurewithintheMOF. Aswaspointedoutin apreviouswork[16]itisoftendiculttosaywhythereisadi screpancybetweenthe experimentandtheoryinonecase vs. another[16]butalloftheevidencedoesclearly supportthatpolarizationisancriticalfactorinruencing sorptionin soc -MOF. 2.4ConclusionsTheresultsofthisstudysuggestdesirableMOFdesignchara cteristicsforhydrogen,andgasstorageingeneral-MOF'sarepromisingcandida tesforgasstorage/sequestration.Forexample,onewouldexpectCO 2 sorptioninsoc-MOFto bequitestronggiventhesignicantlyhighermolecularqua drupoleandpolarizabilty. ThisstudysuggeststhatMOF'sshouldhaverelativelysmall poresandinterconnectedporeswithhighsurfaceareatocreatestrongMOF-H 2 interactionsand,thus, indirectlyH 2 -H 2 attractions.Topromotetheseinteractions,theMOFalsone edsto belocallypolarwithlargechargeseparationsonitssurfac esucientlyfarapartto allowhydrogenmoleculestobesensitivetothedipolarinte rface.Further,whilethe surfaceareaneedstobelarge,theopenspatialnetworkshou ldnotbesoexpansive thathydrogenmoleculesfarthestfromtheMOFsurfacedonot possesssignicantinduceddipolesandcharge-quadrupoleforces.Forexample,i faMOFweretopossess alargesurfaceareaduetosizablepores,hydrogentowardth ecenterofthevoidwill besimilartoneathydrogenwithcharacteristicallyweakin termolecularinteractions andacorrespondinglylowercondensationtemperature.The reis,however,atrade-o 33

PAGE 48

betweenhavinglargervoidvolumesthatproducealowermole cularweightmaterial (butdonotpromotestrongsorptiveforces)versushavingah ighlynanostructedpore system(withcorrespondinglymorematerialperunitvolume ,butstrongscaold-H 2 interactions). Theseinitialstudieshaveprovidedsignicantinsightsin tothenatureofhydrogeninteractionsinnanporous,polarMOFmaterials.The resultspresentedalso suggestseveralfutureavenuesofinquiry.Foremost,wewil lproceedtocalculatesorptionisothermsforourmodelusingaWidominsertionmethod[ 95{97]thatcanbe comparedwithexperiment.Thiswillalsoservetofurtherca libratethepotentialenergysurfaceofourmolecularmechanicsmodelby,forexampl e,givingusthesystem pressureattheexperimentallyobservedhydrogenloading. Wecanthenproceedto mutatetheMOFinanexperimentallyplausiblefashioninana ttempttoincreaseits hydrogenstoragecapacity.Lastly,thisstudysuggeststha tincludingpolarizationin modelingotherextantandfutureMOF'scangivereliablephy sicalinsightintothe mechanismofgasstorage. 34

PAGE 49

Chapter3 AnAccurateandTransferableIntermolecularDiatomicHydr ogen PotentialforCondensedPhaseSimulation Ananisotropicmany-bodyH 2 potentialenergyfunctionhasbeendevelopedforuse inheterogeneoussystems.Theintermolecularpotentialha sbeenderivedfromrst principlesandexpressedinaformthatisreadilytransferr edtoexogenoussystems, e.g. inmodelingH 2 sorptioninsolid-statematerials.Explicitmany-bodypol arizationeects,knowntobeimportantinsimulatinghydroge nathighdensity,are incorporated.Theanalyticformofthepotentialenergyfun ctionissuitableformethodsofstatisticalphysics,suchasMonteCarloorMolecular Dynamicssimulation. Themodelhasbeenvalidatedondensesupercriticalhydroge nanddemonstratedto reproducetheexperimentaldatawithhighaccuracy.3.1IntroductionThedevelopmentofintermolecularH 2 potentialenergyfunctionshasalonghistory.[98]Thetopichasgeneratedrenewedinterestinrecen tyearsduetotheincreasedtheoreticalstudyofhydrogenstoragematerials.[ 1]Inthiswork,wepresent ourownrevisitationoftheissuetoincludetransferabilit y,necessaryforthepractical simulationofhydrogeninheterogeneousmaterials,aswell asanisotropicmany-body eectswhichhavebeenshowntobeimportantinmodelinghydr ogenathighdensity. 35

PAGE 50

Forexample,inmodelinghydrogensorptioninMetal-Organi cFrameworkmaterials(MOFs),atransferablepotentialisrequiredthatinclu destheabilitytocapture anisotropicmany-bodyeectsinaconsistent,eectiveman ner.[99,100] Todate,mosthydrogensorptionstudiesofmaterialshavefo cusedonisotropic H 2 potentials[101{104]inparticularthatofBuchsinceitise asilytransferableand accuratelyreproducesthebulkthermodynamicpropertieso fhydrogen;inaddition, ithasbeenshowntocalculatethecorrectuptakeofhydrogen inweakly-interacting materials.However,inheterogeneousenvironmentswheree lectrostaticquadrupole andinduceddipoleeectsarenon-negligiblesuchanapproa chcannotreproducethe correctbehavior:theisotropicpotentialincludesthesee ectsinamean-eldfashion, appropriateonlyforsystemsinwhichdispersioninteracti onsdominate. Previousanisotropicpotentials[105{111]havefocusedon neatH 2 ,withthe mostnotablebeingthehighlyaccuratepotentialofDiepand Johnson;however,itis notclearhowsuchspecializedformscanbesystematicallym ixedwithchemicallydifferentenvironmentswithoutextensivereparameterizatio n.[112]Whiletheanisotropic potentialofDarkrimandLevesqueisbothtransferableandi ncludesthequadrupole term,ithasbeenshowntooverestimatetheattractiveparto fthepotentialand neglectsinducedmany-bodyeects.[99] Hereinweapplyhigh-levelelectronicstructurecalculati onstotheH 2 -H 2 dimer andthentananisotropicfunctionalformtothe abinitio surface;electroncorrelationmethodshavebeenutilizedastheyhavebeenshowntobec rucialinaccurately describingtherelativelyweakH 2 -H 2 interaction.[105,106]Thisfunctionalformcontainsquadrupoleaswellaselectronicrepulsion/dispersi ontermsthataretransferable usingtheLorentz-Berthelotmixingrules. Severalexistingpotentials[104,109,113]includenon-ad ditivethree-bodydipole terms via Axilrod-Teller-Muto[114]dispersion,whichareknowntoi nruencethe structureofhydrogenathighdensity.Inthisworkweapplya many-bodypolar36

PAGE 51

izationtermtohydrogenanddemonstrateimprovementinthe equationofstateat highdensity.Further,explicitmany-bodypolarizationin teractionshavebeendemonstratedtobeessentialinmodelingH 2 sorptioninpolarMOFs[115]andthepresent polarizationmodelisalsotransferabletosuchsystems.3.2Methods3.2.1Born-OppenheimerSurfaceConstructionoftheBorn-OppenheimersurfacefortheH 2 dimerproceedsfromoptimizingtheRHF[116{120]wavefunctionparametricallyas afunctionofthenuclearcoordinates.Thehydrogenmoleculewasapproximated asarigidrotorwith abondlengthof0.742 A,correspondingtothevaluedeterminedbyrotationalspec tra.[121,122]Thesurfacewastakenoverthedomainofcente r-of-massseparationfor therotorsfrom2.0to10.0 Ain0.1 Aincrements.Asubspaceofthecompletesurface wastakenalongfouruniquerelativeorientations;theorie ntationswerechosenasbeingenergeticallyandgeometricallydistinct(shownpicto riallyinFigure3.1)andthe fourcomputedsurfacesproduceanaverageinagreementwith experiment.[104]All electronicstructurecalculationswereperformedusingth equantumchemistrycode PC-GAMESS.[61,123] SincetheH 2 -H 2 dimerinteractionisdominatedbyelectroncorrelation,[1 05, 106]theRHFenergycalculationsincludedMller-Plessetp erturbationterms[124, 125]tofourth-order,[126]includingtripletstates;[127 ]priorworkinthisareahas sucientlydemonstratedthat,forthehydrogendimer,MP4e nergiesareinagreement withtheCCSD(T)leveloftheory.[105]Thesetofbasisfunct ionsemployedinthe solutionofthewavefunctionwerethoseofDunning[128](au g-cc-pVTZ/QZ)with theenergyeigenvaluesthenextrapolatedtothecompleteba sissetlimit.[129]The eectofbasissetsuperpositionerrorwascorrectedbythec ounterpoisemethod.[130] 37

PAGE 52

ThecomputedenergysurfacesaredepictedinFigure3.1alon gwiththeisotropically averagedsurface. Figure3.1: Abinitio energycurvesoffourdistinctrelativeH 2 orientations(asa functionoftherotorcenter-of-massseparation)alongthe Born-Oppenheimersurface. Theorientationschosenwereend-on-end(EOE),parallel(P AR),T-conguration(T) andX-conguration(X). TheelectricquadrupolevalueforH 2 wascalculatedfromtheelectronicwavefunction(MP4-SDTQ/aug-cc-pVQZ)andfoundtobe0.664D A,avaluecomparable tootherinvestigations.[121,131]Themolecular(static) polarizabilitytensorofthe monomerwasdetermined via TDHF[132]sinceithasbeenshowntoaccuratelyreproducenon-linearopticalpropertiesatfrequenciesawayfro mresonance;theresultant componentsarelistedinTable3.1.ThecomponentsoftheTDH Fpolarizabilitytensorwerethenrescaledsuchthattheisotropicpolarizabili tymatchedtheexperimental value[133]of0.787 A 3 subjecttotheconstraintthattheratioofthe XX to ZZ TDHF componentsremaininvariant.Priorworkhasshownthat,for H 2 ,thenon-adiabatic contributionstoboththequadrupoleandpolarizabilityar enegligible.[131,134] 38

PAGE 53

component TDHF/ A 3 rescaled/ A 3 XX 0.6831 0.6945 YY 0.6831 0.6945 ZZ 0.9561 0.9720 isotropic 0.7741 0.7870 Table3.1:H 2 molecularpolarizabilitytensor(molecularbondaxisalig nedalongthe Zaxis)calculated via time-dependentHartree-Fockalongwithit'srescaledcomp onents.Thecomponentswererescaledsuchthattheisotropic polarizability, 1 3 Tr f g matchedexperimentsubjecttotheconstraintthattheratio ofTDHFvalues, XX=ZZ bepreserved.3.2.2Many-bodyPolarizationHerewebrieryreviewtheThole-Applequistpolarizationmo del-detailscanbefound elsewhere.[135{137]Briery,theatomicpointdipole, ~ ,ofthe i th atomis: ~ i = i ~ E stat i (3.1) where i isanatomicsitepolarizabilitytensorand ~ E stat i istheelectrostaticeld vector.Wecandecomposethedipoleintoseparate static and induced contributions asfollows: ~ i = i ~ E stat i + ~ E ind i = i ~ E stat i T ij ~ j (3.2) where i isa scalar pointpolarizabilityand T ij isthedipoleeldtensorwhich, whencontractedwiththedipole ~ j ,representstheelectrostaticcontributionofthe j th dipoletowardinducingthe i th dipole. 39

PAGE 54

Thedipoleeldtensorisconstructedbaseduponthepositio nsandscalar pointpolarizabilitiesofthesystem,andcanbederivedfro mclassicalelectrostatic principlesas: T ij = r 3 ij 3 x x r 5 ij withanadditionalaspectofthemodelbeingthatthesecondd ipolemaybetaken tobeamodeldistribution,withtheintentthatthedisconti nuityatshortrangewill beavoided;hereweemploythecommonexponentialchargedis tribution[137]and associateddampingparameterof2.1304. Equation3.2isaself-consistenteldequationwithrespec ttothedipoles,and hencemustbesolvediteratively.However,itispossibleto recasttheeldequations inmatrixformas: A~ = ~ E stat (3.3) wherethematrix A isconstructedfromblockmatricesaccordingto: A = ( ) 1 + T ij (3.4) TheadvantagetoEquation3.4isthatthesolutionisthenexa ct(tonumerical precision),withouttheadditionalcomplicationofiterat ionandconvergence.Upon inversionofthe A matrix,themolecularpolarizabilitytensorcanthenbeeas ily determinedby: mol = X i;j A 1 ij (3.5) 40

PAGE 55

Thepolarizableaspectofthehydrogenmodelwasdevelopeda sfollows.With themoleculealignedalongtheZaxis,thepolarizabilityte nsorwascalculatedwiththe Tholemodel(i.e.Equation3.5)andcomparedwiththe abinitio TDHFtensor;the scalarpointpolarizabilitiesbeingvarieduntilthetwote nsorsagree.Thescalarpolarizabilities, ,wereassignedatthesamenuclearcoordinatesasthepartia lcharges, Q ,usedinproducingthequadrupole.ThematrixinEquation3. 4wasconstructed, invertedandthensummedaccordingtoEquation3.5yielding atrialpolarizability tensor.Theresultingtrialtensorwasthencomparedtother escaledtensorinTable 3.1andthe 'sadjusteduntilthedierencewasminimized.Thesitepola rizabilities werecompletelyconverged( i.e. themolecularpolarizabilitytensordetermined via Equation3.5matchedtherescaledtensorinTable3.1towith inallsignicantdigits) andarelistedinTable3.2.3.2.3PotentialEnergyFunctionTheinterestofthisworkisthedevelopmentofapotentialen ergyfunctionforusein MonteCarloorMolecularDynamicssimulationofhydrogenin teractingwithheterogeneoussystems.Inthiscontext,thefollowingfunctional formwaschosenforthe potentialenergyfunction: U = U rd + U es + U pol (3.6) where U rd istheenergyofelectronicrepulsion/dispersion, U es istheelectrostatic energyand U pol isthemany-bodypolarizationenergygivenby: U pol = 1 2 N X i ~ i ~ E stat i (3.7) 41

PAGE 56

wherethesitedipolesarefoundbyeithermatrixinversiono fequation3.3oriterative solutionofthedipoleeldequationsgivenbyexpression3. 2.Forthepurposeoftting thepotentialenergyfunction,weemployedthematrixinver sionmethodformaximal accuracyinthemany-bodypotentialsincethecomputations arefastforatwo-rotor system(however,inapplicationtowardcondensed-phasesy stemstheiterativemethod isusedalmostexclusively). Allofthefreeparametersofthesefunctionshavewell-esta blishedwaysof being\mixed",therebyimpartingtransferability.Itisth emaincontributionofthis workthatthesefunctionshavebeenttotherstprinciples datapresented. Theelectrostaticenergyfollowsfromthequadrupole-quad rupoleinteractions betweenthehydrogenmonomers.Giventhequadrupolevalueo f0.664D Acalculated fromrstprinciplesandabondlengthof0.742 A,thiscorrespondstopartialcharges ofQ=+0 : 3732 e andtheatomicsitesand 2Qatthecenter-of-mass. site R/ A Q/e / A 3 /K / A H2GP 0.000 -0.7464 0.69380 12.76532 3.15528 H2NP 0.363 0.0000 0.00000 2.16726 2.37031 H2EP 0.371 0.3732 0.00044 0.00000 0.00000 Table3.2:Parametertsfortheintermolecularhydrogenpo tential,includingmanybodypolarizationterms.H2GPcorrespondstothecenter-of -masssite,H2EPcoincideswiththetrueatomiclocations(which,whencombinedw ithH2GP,providesthe quadrupole)whileH2NPcontainstheadditionalLennard-Jo nessites. Theshort-rangeelectronicrepulsionandlong-rangedispe rsionenergiesareincludedin U rd byuseoftheLennard-Jones12-6potentialfunction.Sincet heLennardJones r 6 partincludesamean-eldlong-rangepolarization,itwasn ecessarythat U rd bedetermined.With U es and U pol functionallyheldxed, U rd wasvaried via simulatedannealingsuchthat( U U BO ) 2 wasminimized(where U BO istheBornOppenheimerenergysurface).Theresultsofthepotentiale nergyfunctionttingare showninFigure3.2.GiventheanisotropicnatureoftheBorn -Oppenheimerpotential 42

PAGE 57

demonstratedinFigure3.1,Figure3.2demonstratesthatou rrelativelysimpleand transferablepotentialcancapturetheessentialanisotro py.Interestingly,whiletheT orientationshowsthelargestdeviationfromthe abinitio surface,evendramatically increasingthenumberofLennard-Jonesparametersdidnots ignicantlyimprovethe t.Note,giventhelargevariationinthepotentialitiscri ticalinmodelinghydrogeninhighlyanisotropicenvironmentsthatthepotentialc apturethesestructural characteristics. Figure3.2:Potentialenergycurvesfoundbyttingtoequat ion3.6(dashed)versus the abinitio curvesfromFigure3.1(solid).Thealternativenon-polarf orm( U pol =0) thatwasalsottothe abinitio dataisnotshownforclaritysince,withaslight exceptiontotheTconguration,thecurvesarevisuallyind istinguishable. Inthecourseoftheparameter-spacesearch,theLennard-Jo nessitesonthehydrogenmoleculewereallowedtomoveotheirnuclearcenter s.Inaddition,searches weremadethatconstrainedthesitestobebothonandothebo ndaxis,withas 43

PAGE 58

fewastwoandasmanyasninesimultaneoussitesinanattempt toimprovethet; itwasfound,however,thatthreesitesconstrainedtothebo ndaxiswereoptimalin termsofhavingtheminimizederror(withonlymarginalimpr ovementinthetupon increasingthenumberofsitesfurther).Attheendofthett ingprocess,theparametersthatminimizedtheerrorwerefoundandarepresentedi nTable3.2.Inorder toalsodevelopanon-polarizablepotential,theprocesswa srepeatedwith U pol =0. Inphysicalsystemswherethemagnitudeofelectrostaticpo larizationisnegligible, thenon-polarizableparameterspresentedinTable3.3ared esirableforthereduced computationalcost. site R/ A Q/e /K / A H2G 0.000 -0.7464 8.8516 3.2293 H2N 0.329 0.0000 4.0659 2.3406 H2E 0.371 0.3732 0.0000 0.0000 Table3.3:Potentialparametersforthepairwisemodel(neg lectingpolarization terms).3.3ModelValidation3.3.1SecondVirialCoecientQuantummechanicalcorrectionstothesecondvirialcoeci entofagascanbesystematicallyderivedusingtheWigner-Kirkwooddistributi onfunction.[138]Toorder h 4 ,wehavethesemiclassicalseries: 44

PAGE 59

B 2 ( T )=2 Z 1 0 drr 2 1 e + h 2 24 3 Z 1 0 drr 2 e @ @r 2 + h 4 960 3 4 Z 1 0 drr 2 e ( @ 2 @r 2 2 + 2 r 2 @ @r 2 + 10 9 r @ @r 3 5 2 36 @ @r 4 ) (3.8) where ( r )isanisotropicpotentialasafunctionoftheseparation.T heintermolecular many-bodypotentialdevelopedherehasbeensphericallyav eragedtoproducean isotropicpairpotential, ( r ),whichisplottedinFigure3.3alongwiththewellknownisotropicpotentialsofSilvera-Goldman[104]andBu ch[103],bothofwhich areknowntocloselymatchexperiment. Thesecondvirialcoecient, B 2 ( T ),wasthencalculated via equation3.8. Numericalintegrationwasperformedfor r =0 : 001 25 Aacrossatemperaturerange spanningfrom50to500K,in10Kincrements.Theresultsarec omparedwith experiment[133](andtheSGpotential)inFigure3.4. Figure3.3:Theisotropicprojection ( r )ofthemany-bodypotential U isshown alongwiththeSGandBuchpotentials. 45

PAGE 60

Figure3.4: B 2 ( T )from50-500Kforthepolarizableandnon-polarizablepote ntials includingWigner-Kirkwoodquantumcorrectionstoorder h 4 3.3.2EquationofStateTheequationofstatewasascertainedbycalculatingtheave ragenumberofhydrogen molecules, N ,viasamplingofthegrandcanonicalensembleforacorrespo ndingrange ofchemicalpotential.Thefollowingstatisticalmechanic alexpressionwasnumerically estimatedbyGrandCanonicalMonteCarlo:[139,140] N = 1 1 X N =0 e N ( 3 N Y i =1 Z 1 1 dx i ) Ne U ( x 1 ;:::;x 3 N ) wherethechemicalpotentialofthegasreservoir, ,wasdeterminedthroughempirical fugacityfunctions[141,142]forhydrogenatbothhighandl owtemperature(thehighpressuredensitieshavealsobeenveried via NPTmoleculardynamics).Isothermal Pcurvesweregeneratedattemperaturesof77K(pressurerang eof0-200atm) and298.15K(pressurerangeof0-2000atm)andtheresultsar ecomparedwith experimentaldata[143,144]inFigures3.5and3.6.Forthes imulationsat77K, 46

PAGE 61

Feynman-Hibbsquantumcorrections[6]wereappliedtothee nergeticallydominant electronicrepulsion/dispersionpartofthepotentialtoo rder ~ 4 via : U FH rd = U rd + ~ 2 24 U 00 rd + 2 r U 0 rd + 2 ~ 4 1152 2 15 r 3 U 0 rd + 4 r U 000 rd + U 0000 rd (3.9) where U 0 rd ;U 00 rd ;::: arethederivativesoftheelectronicrepulsion/dispersio ntermof Equation3.6withrespecttothedisplacement r .Thesecorrectionswerenotapplied inthegenerationofthe298.15Kdatasincetheseeectsaren egligibleatroom temperature.Toreducethecomputationalcost,thesequant umcorrectionswere onlyappliedtotherepulsion/dispersionenergybecauseat 77K,underthepressure conditionsdemonstratedhere,therepulsion/dispersione nergyisgreaterthan85% ofthetotalenergy. Itshouldbepointedoutthatthemolecularhydrogenisinasu percriticalphase undertheconditionsreported.Notetheliquidhydrogenden sityatboiling(20K) is0.07gcm 3 ;thusthestatepointsconsideredincludethoserepresenta tiveofrelativelystrongintermolecularinteractionsforH 2 .Inbothinstances,weseeimproved agreementwithexperimentathigh-densitywhenmany-bodye ectsareexplicitlyconsideredbyinclusionof U pol .Itisknownthatmany-bodypolarizationeectsareof evengreaterimportancewhenconsideringhigh-densityhyd rogeninteractingstrongly with,forexample,apolaradsorbingmaterial.[100]3.4ConclusionsAnanisotropic,many-bodyhydrogenpotentialhasbeenderi vedfromrstprinciples andexpressedinafunctionalformsuitableformixingwithh eterogeneoussystems 47

PAGE 62

Figure3.5:Pplotofhydrogenat77Kusingtherstprinciples-derivedpo tential energyfunction.ThedensitieswerecalculatedusingGCMCo verthecorrespondingpressurerange,includingempiricalfugacitycorrecti ons.Theelectronicrepulsion/dispersionenergytermincludedFeynman-Hibbsquant umeectstoorder ~ 4 ; thedatageneratedwithoutthiscorrectionwassystematica llyhigherbyabout10%. Alldatapointshaveamaximumvarianceof 0.001gcm 3 Figure3.6:Pplotofhydrogenat298.15Kusingtherstprinciples-deriv edpotential energyfunction.Alldatapointshaveamaximumvarianceof 0.0008gcm 3 48

PAGE 63

consistingofpartialcharges,Lennard-Jonessitesandato micpointpolarizabilities. Ithasbeenshowntoreproducethepropertiesofbulkhydroge nunderconditions ofcurrentinterestinmaterialsresearch.Electrostaticq uadrupolarandmany-body polarizationinteractionsareincludedanisotropically, thusmakingthismodeluseful forhigh-densitystudieswhereorientation-dependenceis ofinterest. Next,itisplannedtousethepotentialinmodelingH 2 sorptioninhighlypolar MOFsthathavebeenshowntosorbhydrogenatnearliquiddens itiesat77K.[100,115] Thepotentialshouldalsobeusefulinmodelinghydrogenina nycondensedphase systemwheretheessentialphysicsofthecompositesystemi scapturedbytherexible potentialenergyfunctionpresented. 49

PAGE 64

Chapter4 APredictiveModelofGasSorptionforMetal-OrganicMateri als NewlydevelopedhydrogenandMOM(Metal-OrganicMaterials )potentialenergy functionsformolecularsimulationarepresented.Theyare designedtobehighly transferablewhilestilldescribingsorbate-MOMinteract ionswithpredictiveaccuracy.Specically,theyareshowntoquantitativelydescri behydrogensorption,includingisostericheats,inMOF-5overthebroadtemperatur eandpressureranges thathavebeenexaminedexperimentally.Theapproachthati sadoptedisgeneral anddemonstratesthathighlyaccurateandpredictivemodel sofmolecularinteraction withMOMsarequitefeasible.Molecularinteractionsgivin grisetotheisostericheat havebeencharacterizedandvalidatedagainsttheexperime ntallyrelevantdata.Finally,inspectionoftheisothermalcompressibilityofhyd rogeninMOF-5revealsthat undersaturatinghigh-pressureconditions(evenattemper atureswellabovetheneat boilingpoint)thestateofhydrogenischaracteristicofal iquid, i.e. withacompressibilitysimilartobulkhydrogen.Thisresultisofparticul arrelevanceindeveloping MOMsforhydrogen-storageapplications.4.1IntroductionMetal-OrganicMaterials(MOMs)areamongthemostwidelyst udiedstructuresfor gasstorage,andyetveryfewtheoreticalstudieshaveinves tigatedtheaccuracyof 50

PAGE 65

theintermolecularpotentialenergyfunctionsforMOMsint eractingwithhydrogen. Whilerstgenerationinvestigationshaverevealedreason ablygoodagreementwith experimentusing adhoc parameterizations,othershaveraisedquestionsastothe accuracyofthepotentialparameters.[16,105]Ineitherca se,thepotentialsshould bevalidatedunderhigh-pressureconditions(ratherthant hemoretypicalstandard pressurestatepoint)andoverawidetemperaturerangewher ediscrepancieswould beevidentifthepotentialswereinaccurate.Thatis,inord ertoproduceapredictive/transferablemodelofMOM-guestinteractionsfor molecularsimulations,the potentialmustincludeallsalientintermolecularinterac tions. Hereinweexplorethevalidityofanewlydevelopedhydrogen potential[5] interactingwiththeprototypicalMOF-5(a.k.a.IRMOF-1)u nderallextantexperimentallyexaminedconditions,includinghigh-pressures thataremorerelevantto theDOEsrequiredstorageconditions.[1]Theexcellentagr eementwithexperimental dataoverthewiderangeoftemperaturesandpressuresillus tratesthepointthat quantitativelypredictivemodelsforgassorptioninMOMsa requitefeasiblewhen carefulattentionispayedtotheintermolecularpotential s. Inadditiontothethermodynamichydrogenuptake,wehavein vestigatedthe isostericheatofadsorption,[93] Q st .Thetypicalexperimentalapproximationemployedistoderive Q st fromisothermsperformedatdierenttemperatures. Q st is determinedfromtheClausius-Clapeyronequation via anumericalderivativeusing twoisotherms.Incomputersimulation,themoleculardetai lsofadsorptionareaccessibleforfurtheranalysisandadirectstatisticalmechani calexpressionfortheisosteric heatisavailablefromthethermodynamicructuationsinsor batenumber.Here,good agreementisfoundforthefrequentlyexamined77Klow-pres surerange.Athigher pressures,ourdataareconsistentwiththelimitedexperim entaldata;unfortunately theexperimental Q st dataathigherpressureshaveinherentlylargeerrorsdueto the rangeoftemperaturesoverwhichthenumericalderivatives areperformed. 51

PAGE 66

Finally,wehavedeterminedtheisothermalcompressibilit yofhydrogenin MOF-5asafunctionofpressure.Interestingly,thehydroge napproachesastate resemblingthatofthebulkliquidastheexcesssorptionwei ghtplateaus.Thisis evidencedbytheisothermalcompressibilityfallingrapid lyoveranarrowpressure rangetoavaluecharacteristicofbulkhydrogen.Thispreli minaryresultisofparticularimportancebecausetheDOErequirementsforhydrogens torageareinexcessof liquiddensity,andhenceanyinteractionsthatmayserveto stabilizetheliquidstate areofpracticalimportanceinelucidatingMOMdesignprinc iples. 4.2Methods4.2.1HydrogenPotentialRecently,anaccurateandtransferablehydrogenpotential energyfunctionhasbeen developed[5]whichincludesquadrupolarelectrostaticte rmsaswellasmany-body polarization,bothofwhichhavebeenshowntobeimportanti nmodelingdensehydrogeninteractingwithachargedsurface.[4]Thisnewhydr ogenpotentialhasbeen showntoyieldanaccurateequationofstateforhydrogenund erhigh-pressuresand low-temperatures.Moreimportantly,thefunctionalformo fthepotentialiseasily transferableinthesensethatitcandescribehydrogeninte ractingwithmaterialsthat aredescribablebyLennard-Jones6-12parameters,partial chargesandpointpolarizabilities(aformfrequentlyusedformolecularpotentia ls).Incontrast,theextant hydrogenpotentialsthatcandescribebulkhydrogenaccura tely(Silvera-Goldman, Buch,etc.)arenotreadilysuitabletocomplexandheteroge neouscondensedphase simulationand/ortoawiderangeofstatepoints.Wehaveuti lizedtheaforementioned potentialinthisworktovalidateit'saccuracyonmodeling variousthermodynamic observablesofhydrogeninMOF-5. Theeectsofmany-bodypolarizationhavebeenshowntobeim portantfor 52

PAGE 67

theaccuratesimulationofhydrogenuptakeincertainpolar MOFs,[4]andforbulk hydrogenathighpressures.[5]However,MOF-5doesnotposs esstherelativelylarge chargeseparationontheframeworkcharacteristicofsomeo therMOFs.[19,92,145{ 147]Therefore,inductioneectsinmodelinghydrogeninMO F-5arenegligibleand,in fact,numericalanalysisofthepolarizationinMOF-5conr msthis.Whenincluded, thepolarizationenergyislessthan5%ofthetotalenergyat 77Kanddoesnot signicantlyaltertheisothermsandassociatedisosteric heats.Therefore,thenonpolarparametersforthehydrogenpotentialreferredtoabo vehavebeenusedandthe Thole-Applequistmany-bodypolarizationcalculationwas onlyperformedinthiswork atselectedstatepointsasacontrol,verifyingthenegligi bilityofinduction.While inclusionofinductionisdesirable,itsmany-bodiednatur emakesthesimulations ordersofmagnitudemorecomputationallyexpensive.4.2.2MOF-5PotentialPermanentelectrostaticinteractionsinatomisticsimula tionsstemfrompointpartial chargesassignedtothecoordinatecorrespondingtothenuc learcenterofeachatom. Pointchargesweredeterminedfromelectronicstructureca lculationsonseveralmodel compoundsthatmimicthechemicalenvironmentofMOF-5.[35 ]TheGAMESS ab initio simulationpackagewasusedtoperformtheHartree-Fockqua ntummechanical calculations.[61] ThestructureofMOF-5ischaracterizedbybenzene-dicarbo xylate(BDC) linkedzinctetramersinacubicoctahedralnet.The424atom unitcellmaybe producedfromcrystallographicsymmetryoperationsappli edtoonly7atoms.[20] Thissymmetry-uniqueformwasusedasthebasisfordeciding onrepresentative chemicalfragments.Forthepurposesofchargetting,frag mentsoftheinnitenet wereselectedinavarietyofwaystoassesstheeectsofstru cturaltruncationonthe tcharges.Theadditionofhydrogenatoms,whereappropria te,wasrequiredfor 53

PAGE 68

Atom Label / A /K q/ e Zn 1 2.4616 62.3993 1.8529 O 2 3.118 30.19 -2.2568 O 3 3.118 30.19 -1.0069 C 4 3.431 52.84 1.0982 C 5 3.431 52.84 -0.1378 C 6 3.431 52.84 -0.0518 H 7 2.571 22.14 0.1489 Table4.1:TheMOF-5potentialparametersthatwereusedint hisstudy.Theatomic labelsrefertotheindicesdepictedinFigure4.1.chemicalterminationofthefragmentboundaries.Severald ierentbasissetswere chosenandresultscomparedfavorably,withtheresultingc hargesbeingwithin0.1 e ofeachotheronaverage(thecompletecomparisonbetweench emicalfragments andbasissetsisgiveninsupplementaryinformation). Figure4.1:MolecularfragmentoftheMOF-5frameworkforwh ichpotentialparametershavebeendeterminedaslistedinTable4.1. Theneedforintramolecularframeworkinteractions[148]w asavoidedbyholdingthescaoldrigidduringsimulation.Phononsarenottho ughttoplayanim54

PAGE 69

portantroleinhydrogensorption,especiallynotatthetem peraturesconsidered here.[34]Lennard-Jonesparameters,representingrepuls iveandvanderWaalsinteractionsbetweenhydrogenatomsandframeworkweretaken fromtheUniversal ForceField;[60]thissetofLennard-Jonesparameterswasu sedinearlierMOFstudiesaswell.[16,35,44,57]Thecompletesetofpotentialpar ametersusedinthisstudy iscontainedinTable4.1andthemolecularfragmenttowhich theyreferisdepicted inFigure4.1.4.2.3AnalysisofPotentialParameters Figure4.2:Fragment1,usedtocomputeatomicpointcharges .Thisfragment, extractedfromtheX-raydiractiondataofthecrystal,con tains1completezinc tetramerwith6coordinatedBDClinkers.Theterminalcarbo xylatesofeachBDC linkerweretruncatedandchemicallyterminatedwithHatom s. Table4.2representstheresultingchargescalculatedfrom attotheelectrostaticpotentialsurfacegeneratedviaHartree-Fockquant ummechanicalsimluation. Thegasphasefragment,thatthe abinitio calculationswereperformedon,wastaken fromthecrystalstructureandalteredonlybycappingthete rminalbenzenerings withhydrogen. 55

PAGE 70

Figure4.3:Fragment2,usedtocomputeatomicpointcharges .Thisfragmentcontains1SBUwith6completelinkersincludingtheterminalca rboxylatefunctional groups. Figure4.4:Fragment3usedtocomputeatomicpointcharges. Thisfragmentcontains 2SBUsconnectedby1benzenedicarboxylatelinker.TheSBUi scappedwithwhat isessentiallyformicacid. Atom Label LANL2 SBKJC 6-31G* DK3 Zn 1 1.6025 1.8529 1.8833 1.8025 O 2 -1.8432 -2.2568 -2.2684 -2.4547 O 3 -0.9036 -1.0069 -1.0144 -0.8852 C 4 1.0937 1.0982 1.1457 0.95203 C 5 -0.2668 -0.1378 -0.1787 -0.0988 C 6 -0.0388 -0.0518 -0.0659 -0.1061 H 7 0.1677 0.1489 0.1729 0.1771 Table4.2:Partialcharges(in e )calculatedusing4dierentbasissetsfromfragment 1. 56

PAGE 71

Atom Label Fragment1 Fragment2 Fragment3 Zn 1 1.8529 1.868 1.851 O 2 -2.2568 -2.263 -2.420 O 3 -1.0069 -1.011 -0.914 C 4 1.0982 1.138 0.958 C 5 -0.1378 -0.170 0.005 C 6 -0.0518 -0.085 -0.182 H 7 0.1489 0.146 0.201 Table4.3:Partialcharges(in e )calculatedusingthe3dierentfragments. Atom Label / A /K q/ e Zn 1 2.4616 62.3993 1.8529 O 2 3.118 30.19 -2.2568 O 3 3.118 30.19 -1.0069 C 4 3.431 52.84 1.0982 C 5 3.431 52.84 -0.1378 C 6 3.431 52.84 -0.0518 H 7 2.571 22.14 0.1489 Table4.4:ThecompleteMOF-5potentialparametersthatwer eusedinthisstudy. 4.2.4GrandCanonicalMonteCarloWithrespecttohydrogenuptake,theprimeobservableofint erestistheaverage numberofhydrogenmoleculessorbed, h N i via samplingofthegrandcanonical ensembleoverarangeofchemicalpotentialscorresponding totheequilibriumpressure ofthereservoir.Thefollowingstatisticalmechanicalexp ressionwasnumerically estimatedbyGrandCanonicalMonteCarlo[139,140]usingac odedevelopedbyour group: h N i = 1 1 X N =0 e N ( 3 N Y i =1 Z 1 1 dx i ) Ne U FH ( x 1 ;:::;x 3 N ) wherethechemicalpotentialofthegasreservoir, ,wasdeterminedforabroadrange oftemperatures(60-300K)throughtheBACKequationofstat e.[149,150]Quantum 57

PAGE 72

mechanicaldispersioneectshavebeenincludedsemiclass icallythroughuseofthe Feynman-Hibbseectivepotential[6]toorder ~ 4 via theexpression: U FH = U + ~ 2 24 U 00 + 2 r U 0 + 2 ~ 4 1152 2 15 r 3 U 0 + 4 r U 000 + U 0000 (4.1) andthepotentialenergyfunctionusedamountsto: U = U es + U rd (4.2) where U es istheEwald-summedelectrostaticpotentialand U rd accountsfortheelectronicrepulsion/dispersionenergythroughuseoftheLenn ard-Jones6-12function. TheMOF-H 2 LJinteractionparametersweredeterminedusingtheLorent z-Berthelot mixingrules;pairwise 'saredeterminedthroughanarithmeticmeanand 'sare formedfromthegeometricmean. Afterobtaining h N i weproceededtocalculateboththeabsoluteandexcess weightpercentofhydrogensorbed;theexcessweightcalcul ationutilizedthefree volumeof11595.4 A 3 determinedpreviouslyforMOF-5.[20] Experimentally,theisostericheatofadsorptionisdeterm inedbynumerical analysisoftwohydrogenisothermsperformedatdierentte mperatures(typically77 and87K).Theisothermdataisthenprocessed(either via curve-ttingorinterpolation)andtheisostericheatofadsorption, Q st ,isdeterminedoverarangeofdensities throughanite-dierenceapproximationtotheClausius-C lapeyronequation: 58

PAGE 73

Q st = kT 2 @ ln P @T (4.3) WhilethemacroscopicClausius-Clapeyronequationcanbeu sedwithGCMC isothermdatatoarriveatvaluesfor Q st ,amoredirectstatisticalmechanicalmethod [151]istorelatetheisostericheattoructuationsofaquan tityinvolvingthenumber ofsorbedmolecules, N ,andthepotentialenergy U : Q st = h NU ih N ih U i h N 2 ih N i 2 + kT (4.4) Anotheraccessible,ructuation-derivedquantityistheis othermalcompressibility: T = 1 V @V @P (4.5) whichmaybecalculated via ructuationsofthenumberofmoleculessorbed, h N i ,in thegrandcanonicalensemblethroughuseofthestatistical mechanicalrelation: T = V kT h N 2 ih N i 2 h N i 2 (4.6) BothEquation4.4and4.6havebeenimplementedintotheMont eCarlocode usedforthisstudyandthesequantitieshavebeenassessedf orH 2 inMOF-5. 59

PAGE 74

4.3ResultsandDiscussion4.3.1HydrogenIsothermsExperimentalvalidationofagivenMOM'shydrogenstoragec apabilitytypicallytakes placeattheliquidnitrogenboilingpoint(77K).WhiletheD OEmilestonesrequire room-temperatureoperation,evaluationofthesurfaceint eractionsismoreeasilydeterminedatlowertemperaturewheremeaningfulmeasuremen tscanbemadewith respecttohydrogenuptakeforevenmarginallysorbingmate rials.Inaddition,the isostericheatofadsorptionismeasuredacrosstherelativ elysmalltemperaturevariationof77-87K.Thus,hydrogenuptakeinMOF-5,assimulate dwiththenewly developedpotentials,isreportedinFigure4.5. Furthermore,theabsoluteandexcesssorptionisothermsfo rhydrogeninMOF5havebeenmeasuredoverawiderangeoftemperatureandpres sure,makingthis wellcharacterizedsystemidealforcomparisonwiththepre senttheoreticalmodel. TheresultsarecomparedwithexperimentinFigure4.6andFi gure4.7. Forcomparison,wenotethatinFigure4.8oursimulationres ultsat77Klie withintherangeofavailableexperimentaldata.Thiscompa rison,whilenotavailable atawiderangeofstatepoints,suggeststhattheresultsinF igures4.6and4.7are accuratetowithintheextantexperimentaluncertainties( including, e.g. ,standard measurementerrorsandvariationinmaterialspreparation protocol).Note,thetwo setsofexperimentaldatapresentedarerepresentativeofs omeofthemostcareful measurementsofhydrogensorptioninMOF-5todate.4.3.2IsostericHeatofAdsorptionofHydrogenTheisostericheatofadsorptionofhydrogeninMOF-5wascal culatedfromtheructuationexpression(Equation4.4)overthestatisticalmec hanicalstatesandisshown inFigure4.9.Thelowpressureresultsinthegurearefound tobeingoodagreement 60

PAGE 75

Figure4.5:GCMCcalculatedlow-pressurehydrogenisother m(absoluteweightpercent)ofMOF-5at77K vs. experiment.[152,153] Figure4.6:GCMCcalculated(starreddata)high-pressurei sotherm(absoluteweight percent)ofMOF-5overawidetemperatureandpressurerange vs. experimental data[154](solidlines).Maximumcalculatederroris 0.07wt% 61

PAGE 76

Figure4.7:GCMCcalculated(starreddata)high-pressurei sotherm(excessweight percent)ofMOF-5overawidetemperatureandpressurerange vs. experimental data[154](solidlines).Maximumcalculatederroris 0.07excesswt% Figure4.8:GCMCcalculatedhigh-pressureisotherm(exces sweightpercent)ofMOF5at77K vs. experimentaldata[153,154](solidlines).Maximumcalcul atederroris 0.068excesswt% 62

PAGE 77

withexperiment(especiallyconsideringthattheexperime ntaldataforMOF-5iscorrespondinglysimilarbasedupondieringpreparationtech niques,etc.)Theisosteric heatofMOF-5ischaracteristicofphysisorption( 5kJ/mol)andremainsfairly constantoveranextendedrangeofdensities.Thecalculate d Q st valuesfortheother temperaturesoverbroaderpressurerangesarealsofairlyc onstantinarangefrom about4-5kJ/molatlowpressure,and3.5-5kJ/molatthehigh erpressuresconsidered.Theexperimentaldataathigherpressuresanddiverse temperatures[154]are similarbutdiculttocomparequantitativelybecausethe nitedierenceapproximationto Q st via theClausius-Clapeyronequationgivesarangeofvaluesdep ending uponthetwosetsoftemperaturedatathatarechosen;itisal sofoundthatthetheoreticalisotherm-derived Q st valuestakeonasimilarrangeofvalues.Itwouldbe usefulifcalorimetryexperimentshadmappedoursorptione nthalpiesoverarangeof thermodynamicconditions.[93,94]Nonetheless,innocase arethetheoreticalvalues inconsistentwiththeapproximateexperimentalvalues. Further,thedataalsosupportamodelwhereMOF-5(withit's largesurface areaandporevolume)isknowntoretainit'sinteractionswi thhydrogenat77Kacross thepressurerangeupuntilsurfacesaturation-oncethesur faceiscoveredthenthe bulk(characteristicallyweak)H 2 -H 2 interactionscontributeagreaterportiontoward thestatisticalaverageof Q st 4.3.3IsothermalCompressibilityofHydrogenTheisothermalcompressibilityofhydrogeninMOF-5at77Kw asfoundtoreach aminimumwhentheexcesssorptionisothermsaturated.Furt hermore,asshownin Figure4.10,thevalueofthecompressibilitywasfoundtore semblethatoftheliquid (orsupercriticalstatewithadensitysimilartothenormal liquid)state.Thisbulk compressibilityvalueisitselfrelativelyinsensitiveto theparticularcondensedphase statepoint.Itisnotsurprisingthattheporedensityofhyd rogenunderhigh-pressure 63

PAGE 78

Figure4.9:Comparisonofthecalculated( via themicroscopicructuationequation) isostericheatofadsorption, Q st ,forhydrogeninMOF-5at77K vs. experimental [20,155]data.inMOF-5ischaracteristicofthebulkphasesgiventheclose packingofH 2 inthat case.However,thecompressibilityhasseveraluniqueprop ertieswhichareofinterest. Forexample,thecompressibilitywillbeafunctionofboths urfaceinteractionand bulk-like( i.e. porelocalizedhydrogen)contributions,therelativeeec tsofwhichwill varyasacomplexfunctionoftheequilibriumstatepoint.Th erefore,giventhatthe MOF-5connedH 2 compressibilityiscomparabletobulkphasessuggestsarel atively minorperturbationtothestructureintheweaklyinteracti ngMOM.Theresults demonstratethattheisothermalcompressibility,directl yobtainablefromGCMC calculations,isanimportantparameterworthmonitoringt oassessthenatureofthe connedruidandtheabilitytofurtherimprovesorptioncap acitywithincreased pressure. 64

PAGE 79

Figure4.10:Calculatedisothermalcompressibilityofhyd rogeninMOF-5at77K vs. experimentalvaluesofhighdensity T =0.0015atm 1 (200K/200atm)[156{158] and T =0.0020(20K/1atm).[159]Theexcessweight%ofhydrogenin MOF-5at 77Kisalsodepictedontheoppositey-axisforcomparison.4.4ConclusionsAftercarefuldevelopmentofbothhydrogenandMOMpotentia lenergyfunctions, quantitativelyaccuratehigh-pressureresultshavebeeno btained(morespecically, thesorptionuptakeandisostericheats).Theanalogousdev elopmentofpotential surfacesforotherMOMsandpossiblesorbentsislikelytole adtosimilarlyaccurate modelsoftheseimportantsystems.Suchpredictiveaccurac ywillaidgreatlyinthe rational,iterativedesigncyclebetweenexperimentaland theoreticalgroupsthatare attemptingtodesignMOMsforavarietyofpurposes,includi ngH 2 sorptionandCO 2 sequestration. Here,anaccurateandtransferable,anisotropichydrogenp otentialhasbeen employedinstudyingMOMs,anditisexpectedthatthemany-b odypolarizableform oftheH 2 potentialwillshedfurtherlightoninteractionsinMOMspo ssessingopencoordinationsitesandcharged[92,147,160]and/orpolar[ 19]frameworksthatpolar65

PAGE 80

izehydrogenmolecules(thecontinuingsubjectoffuturewo rk).Suchcharged/polar MOMshavegreatpotentialformultipleapplicationsduetot henecessarilystronger interactionsthattheyhavewithguestmolecules via thepolarizationinducedbythe MOMframework.Finally,thebenetofliquidstateanalysis appliedtohydrogenin theuniquetopologicalandchemicalenvironmentpresented byaMOMmayyieldnew insightsintothedesignpropertiesnecessaryforenhanced gasstorage,ofwhichanalysisoftheisothermalcompressibility(thiswork)andradi aldistributionfunctions[4] haveplayedarolethusfar.Lastly,thesuccessofthepresen tMOM-guestinteractionmodelsuggeststhatmolecularsimulationmethods,wit hcarefullyconstructed potentialenergysurfaces,arethemethodofchoiceinmodel ingandpredictingthe propertiesofsuchsystems-theyarereasonableincomputat ionalcostwhileretaining highaccuracy. 66

PAGE 81

Chapter5 PhotophysicalStudiesoftheTranstoCisIsomerizationoft hePush-Pull Molecule:1-(Pyridin-4-yl)-2-(N-methylpyrrol-2-yo)et hene(mepepy) Organicmoleculespossessingintra-molecularchargetran sferproperties(D-Atype molecules)areofkeyinterestparticularlyinthedevelopm entofnewoptoelectronic materialsaswellasphotoinducedmagnetism.Onesuchclass ofD-Amolecules thatisofparticularinterestcontainsphoto-switchablei ntra-molecularchargetransferstatesviaphoto-isomerizable -systemlinkingthedonorandacceptorgroups. Thischapterdescribesacollaborativeeortbetweenbotht heoricalandexperimental groups,withtheexperimentshavingbeenperformedbyDr.Au dreyMokdadandDr. RandyLarsen(USFChemistry/SMMARTT). Thestructural,energeticandelectrostaticdierencesbe tweentheaqueous cis -and trans -isomersof1-(pyridin-4-yl)-2-(N-methylpyrrol-2-yl)ethene(MEPEPY) wereexaminedusingDensityFunctionalTheory(DFT).Theeq uilibriumgeometries ofthevariousMEPEPYstatesweretheoreticallycalculated byenergyminimization. Thedierenceinpotentialenergyanddipolemoment,includ ingmeansolvationeffects,betweentheisomerswaselucidated.Uniquecharacte risticsofthepotential energysurfaceswereexplored,mostnoteablytheexistence ofgroundstate trans isomersthatdonotthermallyinterconvertatroomtemperat ure. 67

PAGE 82

5.1IntroductionTheimportanceofnon-linearopticalmaterialsinhighspee dopticalmodulators,opticalstoragemedia,fast/ultrafastopticalswitches,etc.h asstimulatedresearcheorts intothedevelopmentandcharacterizationofnovelclasses ofmoleculeswhichcanexhibitdiversepolarizationpropertiesbothinthegroundan dexcitedstates.[161{165] Oneclassofmoleculeswhichhavedemonstratednon-linearo ptical(NLO)properties andareofcurrentresearchinterestareknownas\push-pull "typemolecules.The non-linearopticaleectsassociatedwiththesemolecules areduetothepresenceofan electronacceptinggroupononesideofaconjugatedmoietya ndanelectrondonatinggroupontheoppositeside.Thisenhancesthepolarizabi lityofthedoublebond regionallowingforadditionalpolarizationtobeinducedi nthepresenceofanelectric eld.Typically,amino,dialkylamino,etheroroxide(O-)f unctionalgroupsformthe electron-donatingsubstituentwhilenitro,carbonylandc yanogroupsareemployed asthecorrespondingacceptorgroup.[166,167]Toachievet hedesiredpolarizability, thesegroupsareseparatedviaaconjugatedlinkergroup. Inadditiontotheirnon-linearopticalproperties,push-p ullmoleculeshave alsobeenutilizedasligandsforvarioustransitionmetalc omplexesinordertophotolyticallyalterthespinstateofthecomplex.[168{172]I nthiscasethepush-pull ligandmustpossesafunctionalgroupcapableofcoordinati ngtothetransitionmetal complexandthatexhibitsashiftinthebasicityuponphotoexcitation.Metalcomplexesofthistypecanexhibit,forexample,alowspinelect roncongurationwhen thepush-pullligandisinthemorebasicconformationandsw itchtoahighspin congurationuponphotoconversionoftheligandtotheless basicconformation.A numberofsuchcomplexeshavenowbeensynthesizedandtheir opticalandmagnetic propertiesexamined.TheseincludecomplexesoftheFe(II) (L 4 )(X 2 )typeinwhichL isthephoto-isomerizablepush-pullligandandoftheFe(II I)(L 4 )(L 0 )(X)typeinwhich L 0 isthepush-pullligand.Earlystudiesutilized4-sterylpy ridine(Stpy)(1-phenyl-268

PAGE 83

(4-pyridyl)ethane)aswellasseveralphenylderivativeso fthisligandtophoto-induce thespincrossover.[170{172]Inoneoftherstexamplesofl iganddrivenlightinduced spinstatechanges,theFe(II)(transStpy) 4 (NCS) 2 complexwasfoundtoundergoa thermallyinducedhigh-spintolowspintransitioncentere dnear190K.[170]Photoexcitationofthiscomplexembeddedwithinacelluloseac etatesubstrateat140K resultsintranstocisisomerizationoftheStpywhichalsoi nducesthehigh-spinto lowspintransition. Thesuccessofthesecomplexeshasledtothesynthesisofnew compounds whichexhibitliganddrivenlightinducedspinstatechange sathighertemperatures. Onesuchcomplex,[Fe(III)(salten)(mepepy)]BPh 4 (salten=4-azaheptamethylene1,7-bis(salicylideneiminate;mepepy=1-(pyridin-4-yl) -2-(N-methylpyrrol-2-yl)-ethene; BPh 4 =tetraphenylborate)hasbeenshowntoexhibitahighspinto lowspin transitionatroomtemperatureundervisibleirradiation. [170,171,173]Unlikethe Fe(II)(L 4 )(X 2 )typecomplexesdiscussedabovewhichhavefourphoto-isom erizable ligands,theFe(III)(L 4 )(L 0 )(X)typecomplexes(e.g.,Fe(III)(salten)(mepepy))have onlyasingleisomerizableligandwhichisusedtomodulatet heligandeldstrength. Inthecaseofthemepepycomplexthespinstatetransitionis triggeredviathelight inducedtranstocisisomerizationoftheligandwhichresul tsinshiftinelectron densityfromtheN-methylpyrrolmoitytothepyridineunit. Althoughthetrans/cisphotoisomerationofmepepyhasbeen showntobeeffectiveinmodulatingtheligandeldstrengthofthechromo phoremuchlessisknown abouttheelectronpropertiesandenergeticsofthisproces s.Theopticalspectrum ofthetransconformationofmepepyinacetonitrileexhibit sabsorptionmaximaat 353nm( =22,800M 1 cm 1 )and241nm( =7,800M 1 cm 1 )whichhave beententativelyassignedas to *transitions.[170,171]Uponphotoisomerization, theabsorptionbandat353nmexhibitsaslighthypsochromic shiftanddecreases inextinctionbynearly50%whilethe241nmbandshowsonlymo destchangesin 69

PAGE 84

extinction.Inthepresentwork,theenergeticsassociated withthetranstocisphotoisomerizationaswellasthepotentialenergysurfacesof themepepyligandhave beeninvestigatedusingcomputationalmethodsinaneortt obettercharacterizethe physicalpropertiesofthisimportantligand.5.2MethodsAllcalculationsof1-(pyridin-4-yl)-2-(N-methylpyrrol -2-yl)-ethene(MEPEPY)[171] wereperformedusingthequantumchemistryprogramGAMESS. [174]Molecular propertieswereevaluatedusingDensityFunctionalTheory becausethishasbeen showntoyieldaccurateresultsforisomerizationstudieso fazobenzene[175{177], amoleculethatisstructurallysimilartoMEPEPY.TheB3LYP hybridexchangecorrelationfunctional[178{180]wasemployedforallcalc ulationsalongwiththeaugmentedcorrelation-consistentdouble-zetabasisset[78] (aug-cc-pVDZ).Solvationeffectsweretakenintoaccountthroughtheuseofapolarizabl econtinuummodel[181] inwhichtheMEPEPYmoleculeisembeddedinanisotropicdiel ectriceldparameterizedtomimicktheaqueousenvironment.Thedielectric constantwas78.39and thesolventradiuswas1.385 A. Geometryoptimizationsforboththe cis and trans isomerswereperformed inthesolvationeldinordertoascertaintheminimumenerg ygeometries.The molecularelectricdipolemomentsfortheoptimizedstruct uresweredeterminedfrom thechargedistributions. Inordertodiscoveranyadditionallocalenergyminima,the groundstate cis and trans potentialenergysurfacesweregeneratedasafunctionofth eanglesforthe pyridineandpyrroleringsfromaplanarconguration.Each anglewasscannedby rotatingtheringsalongthe and r vectors,from0 to180 in10 increments, whileconstrainingtheremainingdegreesoffreedom. 70

PAGE 85

Figure5.1: trans isomerofMEPEPY isomer \ r ( ) \ r ( ) d ( A) d r ( A) d r ( A) ( ) cis 126.647 129.507 1.487 1.348 1.450 90.0 trans 126.490 127.365 1.462 1.353 1.439 0.0 Table5.1:Geometriccongurationsoftheglobalenergy-mi nimized cis and trans MEPEPY.Thebondanglesanddistancesarewithrespecttothe labelsinFigure 5.1. istheanglebetweenthepyridineandpyrroleplanes.Render ingsofthese geometriesarepicturedinFigure5.2.5.3ResultsandDiscussionThestructuresoftheenergyminimalocatedalongthepotent ialenergysurfacewere found(forwhichthegeometricdetailsaretabulatedinTabl e5.1),andarealsovisually depictedintherenderedrepresentationofFigure5.2. Theenergydierencebetweentheglobal trans minimumandthatofthe cis formwasfoundtobe8.237kcal/mol,whiletheenergydieren cebetweenthelocal trans minimumandthe cis isomerwasdeterminedtobe7.167kcal/mol.After evaluatingtheelectrostaticmoments,thedierenceinthe dipolemomentbetween theglobal trans stateandthe cis statewas0.424Debyeandthelocalminimum dierencewas0.0398Debye.Whiletherelativepopulations oftheisomersaftera photoisomerizationeventareunknown,thesedetermineddi erentialvaluesplacean upperandlowerboundtothetrueequilibriumdierences. 71

PAGE 86

isomer energy(kcalmol 1 ) moleculardipolemoment(Debye) cis -335,330.347905 4.117 global trans -335,338.585359 3.693 local trans -335,337.514896 4.077 Table5.2:Calculatedenergyanddipolemomentofglobalmin ima cis and trans MEPEPYisomers,alongwiththealternatelocalminimumalon gthe trans potential energysurface. (a)cisgeometry (b)translocalgeometry (c)transglobalgeometry Figure5.2:Visualrenderingsoftheglobalenergyminimize dstructuresfor trans and cis isomerswiththevaluesspeciedinTable5.1. 72

PAGE 87

The cis potentialenergysurfaceisashallowbasinwithasinglemin imum, whereitcanbeexpectedthattheequilibriumstructurewill ructuateoutofplane inthesolvatedgroundstate.However,uniquecharacterist icsofthe trans potential energysurfacewerefound,mostnoteablytheexistenceoftw ogroundstateminimaseperatedbyanenergybarrier.Completedetermination oftheisomerization mechanismforMEPEPY(whichisnotdeterminedinthiswork)i srequiredtoknow whetherthetransitionsfromtheexcitedstatetotheground statefavoroneisomeric trans formovertheother.Theminimumenergybarrierbetweenthec ongeneric trans statesis9.115kcalmol 1 whereasthethermalenergykTat300Kisonly0.596kcal mol 1 Insummarytheresultspresentedheredemonstrateseveralk eyfeaturesofthe transtocisconversioninmepepy.First,themepepyligande xhibitstwoconformationalminimaforthetransstatethatareseparatedby9kcal /molsuggestingthat thephoto-inducedspinstatetransitionsassociatedwithm etalcomplexescontainingthemepepyligandmaybeenergetically\tuned"basedupo nthenatureofthe transconformer.Second,theresultsofthecomputationals tudiesrevealverylittle changeindipolemomentbetweenthetransandcisconformers ofmepepyindicating moresubtlechangesintheelectronicstructureofmepepyre lativetootherpush-pull moleculesandtheazobenzenes. 73

PAGE 88

(a) trans energysurface (b) cis energysurface Figure5.3: trans and cis groundstateenergysurfacesasafunctionofthepyridine andpyrroleringanglesasdenedbydeviationfromplanarco nguration. 74

PAGE 89

Chapter6 InsightintotheAssemblyMechanismofMetal-OrganicMater ials Acollaborativetheoretical/experimentalstudywithMoha medAlkordiofUSFChemistry/SMMARTTontheself-assemblyofcobalt-containingm etal-organicnanocubes ispresented.Thissolution-basedstudyrepresentsthefru itfuloutcomeofcombined experimentandtheory,anddemonstratestheimportanceofd etermininghowdiscrete metal-organicsystemscan,ultimately,formstablestruct ures.Itishopedthatthis approachwillmotivatefurtherworkonMOMassembly.6.1IntroductionMetal-OrganicMaterials(MOMs)representafamilyoffunct ionalsolidstatematerialswithgreatpotentialtoansweranumberofcurrentlyde mandingapplications suchasgasseparationandstorage,drugdelivery,catalysi s,smallmoleculessensing, ionexchange,andCO 2 sequestration.Suchattributesarepertinenttotheintrin sic characteristicsofMOMsincludingcrystallinity,rigidit y,and,inmanycases,porosity. ThecrystallinenatureofMOMsfacilitatesunambiguousstr ucturalcharacterization, permittingbetterunderstandingofunderlyingstructurefunctionrelationshipand subsequentlyenhancedcontrolovertargetedproperties.I tisthroughidentication oftheunderlyingfundamentalstructuralentitiesinMOMs, widelyknownasthe molecularbuildingblocks(MBBs),thatrationaldesignstr ategiesforconstructionof 75

PAGE 90

functionalMOMswereconceived,andfurthersuccessfullyi mplemented.TheMBB approachforconstructionofMOMsencompassesthe insitu preparationofrigid anddirectionalMBBsthroughself-assemblyofjudiciously designedmolecularprecursorsencodedwithappropriateinformation,compliment arymolecularrecognition sitesheldatspecicspatialorientation,underwelldene dreactionconditions.Dueto relativelymildreactionconditionsemployedinsolvother malsynthesesofMOMs,the built-inrigidity,functionality,anddirectionalityofM BBsaremaintainedthroughout thereactionpathway,facilitatingreliablepredictionof theunderlyingtopologiesin targetedconstructs.Hence,geometricaldesignprinciple sforconstructionofMOMs basedontheMBBapproachwereidentiedandfurthersuccess fullyimplementedinto rationaldesignstrategiestowardsconstructionofsevera lfunctionalMOMs.However, despitethewideinterestindevelopingnewstrategiestoco nstructMOMswithspecictopologiesand/orfunctionalitiesutilizingawideva rietyofchemically-accessible MBBs,systematicinvestigationsaimingtoprobethevariou seectsassociatedwith thewiderangeofreactionvariablesonthenatureofisolate dproduct(s)arestill lacking.Valuableinformationobtainedthroughsuchsyste maticinvestigationscould provideusefulinsightintothecrucialrolesassociatedwi thvariousreactionvariables facilitatingboththe insitu preparationoftargetedMBBsand,subsequently,their self-assemblyintotargetedstructures.Accordingly,bet terunderstandingofthecomplexityinvolvedinsolvothermalreactionsystemscouldbe utilizedtoenhanceour designstrategiesforconstructionoffunctionalMOMs. Metal-OrganicPolyhedra(MOPs),asubsetofMOMs,arenite supermolecularassemblieswithvariousfunctionalities,tailorable voids,andfairlypredictable geometries.Pertinenttotheirabilitytoencloseaconned space,MOPshavebeen utilizedas\nano-reactorsfacilitatingspecicchemical transformationsofencapsulatedguestmolecules.Inaddition,MOPswithperipheralfu nctionalitiescanfurther beemployedassupermolecularbuildingblocks(SBBs)withb uilt-instructuralin76

PAGE 91

Figure6.1:CobaltMetal-OrganicNanocube,ME506 formation,decoratingandexpandingtheverticesoftarget ed3Dnets,towardsconstructionofmetal-organicframeworks(MOFs).Amongthere adilyaccessibleMOPs istheimidazolate-basedmetal-organiccube(MOC).TheMOC ,constructedthrough single-metal-ionMBBapproach,representsarelativelysi mplesystemsuitedforthe intendedsystematicstudyandthusisthefocusofourinvest igationsherein. Theligandthathasbeusedinthisstudyhasseveralcharacte risticsofnote. First,whencoordinatedthechemicalenvironmentoftherin gprotonsisuniqueand Figure6.2:Ligandwhich,incomplexwithCo,reactstoformt henanocube 77

PAGE 92

doesnotpossessaC2axisofrotation;thislackofsymmetryg ivesrisetoclearly denedprotonNMRpeaksthathavebeenusefulinthiswork.Se cond,thereisabasic sitewhereby(uponcoordination)protonationtakesplacethisagainyieldsadistinct NMRsignaturewheredeuteriumisexchangedwiththesolvent andthustheamount offreeligandpresentinthesamplemaybeaccuratelymonito red.Finally,thereis auniqueintra-molecularhydrogen-bondpresent,asdeterm inedbybothexperiment andsimulation. Uponmixingofcobaltandtheligandinwater,itwasevidentf romtheexperimentsthatsomeformofinorganiccomplexwaspresentin solution,theexact natureofwhichwasnotyetelucidated.AnalysisofthetimedependentprotonNMR spectra,monitoredasafunctionofthereactionprogress,s howednonewpeaksbut onlyminoralterationsintheintensityofpeaksassociated withtheligand. Evidencepointedtotheformationofananocube,basedupont hefollowing observations.First,theligand-to-metalratiosthatresu ltedinnofreeligandinsolution(asdeterminedfromNMR)wereconsistentwithacubic assembly.Second, MALDI-TOFmassspectrumfragmentationpatternswereconsi stentwithadiscrete nanocube.DiusionNMRexperimentsrevealedahydrodynami cradiusof 9.5 A alsoconsistentwiththecubichypothesis.Finally,single crystalshavebeenpreviously obtainedwiththisligandusingnickel,andsoitseemedplau siblethatananocube wasalsobeingformedwithcobaltbutsimplycouldnotbeeasi lycrystallizedforsome unknownreason.6.2MethodsInordertodenativelyprovetheexistenceofametal-organ icnanocubeinsolution, theoreticalcalculationswereperformedonanumberofposs ibleinorganiccomplexes whichareshowninFigure6.4.Thesefragmentswerechosensi ncetheyrepresent all(reasonable)possiblecoordinationcomplexeswithint hemasslimitspreviously 78

PAGE 93

Figure6.3:Time-seriesNMRspectraofreactionformingthe nanocube.Notethat onlytheintensitiesofthechemicallyuniqueprotonshifts arealtered,withoutadditionalpeaksbeingincludedorlost.determinedfromMALDI-TOFexperiments. Thefragmentsweregeometryoptimizedusingthequantumche mistrycode Gaussian03.TheminimizedenergywascalculatedviaDensit yFunctionalTheory (DFT)usingtheB3LYPhybridexchange-correlationfunctio nal.Theunrestricted calculationemployedtheLANL2DZbasissetwithanECPappli edtothecobalt atoms.[182]6.3ResultsandDiscussionT1relaxationexperimentswereperformedbyMohamedAlkord itofurtherdetermine thegeometryoftheinorganiccomplexinsolution.Inthisex periment,theNMRrelaxationtimesareproportional(tothesixthpower)tothed istancesfromtheprotons (givingrisetothesignal)andahigh-spinmetal,suchascob alt.Thedistancesdeterminedinthisexperimentwerecomparedwiththedistancesfr omDFTcalculations ofthepossiblecandidatestructuresandisshowninFigure6 .6.Mostimportantly,a 79

PAGE 94

(a)FragmentM2 (b)FragmentML (c)FragmentML2 (d)FragmentML3 Figure6.4:Possibleinorganiccomplexesthathavebeengeo metryoptimizedusing DFT. 80

PAGE 95

Figure6.5:IdenticationoftheT1relaxationdistancesfr omthehigh-spincobaltto thechemicallyuniqueprotonsoftheligandforthematching DFTgeometry-optimized complex. Figure6.6:ComparisonofexperimentalandtheoreticalT1r elaxationdistancesfor thecobaltnanocubeandforthetheoreticalinorganiccompl exthatwasoptimized usingDFT.Noneoftheotherpossiblecomplexesresulteding eometriesgivenquantitativeagreementwiththeT1experiment. 81

PAGE 96

Figure6.7:Nanosquareintermediatealongtheassemblyrou tetowardthenanocube. quantitativematchwasfoundonlyforthestructureshownin Figure6.5,thusproving theexistenceofastablenanocubeinsolution. Inaddition,basedupontheaforementionedanalysis,itwas proposedthatthe reasonforthelackofcrystalformationofCo-containingcu beswasduetothefact thatthediscoveredfragment(andhencethecube)wouldposs essanetchargeand thatthecounterionsinsolutionweredisruptingtheinterm olecularforcesnecessary tomakeastablecrystal.Sincetheinter-cubeinteractions arerelativelyweak,itis observedthatalterationstothehydrogenbondnetworkcoul dresultinvaryingtypes ofpacking. Therefore,itwaspostulatedthatasolventwiththeproperc haracteristicsof highboilingpoint,hydrophobicityandgoodhydrogenbonda cceptorfunctionality couldbeconducivetotheformationofsinglecrystal.N,N 0 -diethylformamide(DEF) isasolventwithsuchcharacteristicsandexperimentaltre atmentofthenanocubecontainingsolutionindeedresultedinpure,redsinglecry stals.X-raydiraction, indeed,conrmedthepresenceofCo-containingnanocubes, ashadbeendetermined previouslybybothsolutionphaseexperimentandquantumme chanicalcalculations. 82

PAGE 97

Figure6.8:Anioniccounterionsdepictedwiththenanocube .Disruptiontothehydrogenbondnetworknecessaryfororderlypackingofthenan ocubeswasdetermined tobethereasonforlackofacrystallinematerial{adjustme ntsmadetothesolvent conditionsresultedinpure,singlecrystals. 83

PAGE 98

Figure6.9:ProposedassemblymechanismoftheConanocube. 84

PAGE 99

Baseduponthechemistrythathasbeenlearnedregardingnan ocubes(through boththeoryandexperiment)andpreviouskineticstudieson theformationofmetalorganicnanoballs,[183]itishypothesizedthattheassemb lymechanismoftheMOC proceedsasshowninFigure6.9.Thismechanismremainstobe proven,andwill likelyresultinfuturetheoreticalandexperimentalstudi es. 85

PAGE 100

Chapter7 MolecularSquares:ConnedSpacewithSpecicGeometryfor HydrogenUptake 7.1IntroductionMetal-OrganicFrameworks(MOFs),asfunctionalsolid-sta tematerials,continueto receivewidescienticinterestduetotheirpotentialappl icationsinhydrogenstorage, gasseparation,carbondioxidesequestration,enhancedca talysis,anddrugdelivery. Suchapplicationsarepertinenttothefundamentalattribu tesofMOFsincludingdual composition,highcrystallinity,andopenstructures.Inp articular,porousMOFshave beenwidelyinvestigatedforhydrogenstorage,demonstrat ingreversiblephysisorption interactions,withinavailablevoidspace,amenabletoahi ghdegreeoftuneability associatedwiththehighlymodularnatureofMOFs. Hydrogeninteractionswithmetalcomplexes,clusters,ori ons,astheinorganic partoftheframework,aremostlyelectrostaticinnaturean dcouldplaymajorroles indeterminingtheH 2 uptakecharacteristicsofaparticularMOFduetotheirrela tivelysignicantcontributiontotheoverallH 2 bindinganitiesandhencearethe subjectofconsiderabletheoreticalandexperimentalinve stigations.Althoughweaker, favorablevanderWaalsinteractionsbetweenH 2 andtheorganiclinkersinMOFs, bestrepresentedbybenzeneringderivatives,havebeenthe oreticallyinvestigatedand experimentallydocumentedthroughinelasticneutronscat teringexperiments.Recent 86

PAGE 101

Figure7.1:MolecularSquares:ME193 studiesdemonstratethatsuchinteractionscould,inprinc iple,beenhancedthrough chemicalmodicationstotheorganiclinkers,providingap otentialstrategyfora materialdesignertoenhanceH 2 sorptioncharacteristicsofMOFs.Nevertheless,no studiesexist,tothebestofourknowledge,addressingthep ossibilityofimprovingH 2 bindinganitytothewallsofMOFsthroughsimultaneousfav orabledispersiveinteractions,actingadditively,betweenH 2 moleculesandmultiplearomaticringsplaced atoptimalinteractiondistance(s)andwithinaspecicgeo metry. 7.2MethodsandResultsTherefore,weopttoexplorethisapproachwhichcouldpoten tiallyproveusefulasa viabletargettoconsider,amongothers,inrationaldesign strategiesforfuturehydrogenstoragematerials.ComputationalstudiesbyHead-G ordonetal,Goddardet al,andothers,fortheH 2 bindinganitiestobenzeneandvariousaromaticrings revealedmoderatebindinganities,mostlyduetofavorabl edispersiveinteractions intherangeof3.4-4.0kJ/molforaH 2 moleculeinteractingwithbenzeneringin 87

PAGE 102

terephthalicacid.Althoughbelowtheestimatedtargetof2 0-40kJ/mol,forecient H 2 storagematerialsatambientconditions,itisnotyetclear ifsuchinteractions couldbeadditiveandhencecanleadtoenhancedfavorablein teractionsbetweena H 2 moleculeandmultiplearomaticringsintailoredframework s.Asatestmodel,we envisionamolecularsquareconstructedoffourbenzenerin gsinteractingsimultaneouslywithasingleH 2 molecule,residesinthecenterofthesquare,asapotential modelforamaterialwithenhancedH 2 bindinganity.Inthismodel,theH 2 molecule islocatedatuniformdistance, R ,betweenitscenterofmassandthecentroidsofsurroundingbenzenerings.Itisobviousthat,duetohighdepen denceofdispersive interactionson R ,decreasesas R 1 = 6 ,anyexpectedenhancementinH 2 bindinganityduetosimultaneousdispersiveinteractionswithinthe optimizedmolecularsquare geometrywillbeextremelysensitivetogeometricdeformat ions.Althoughthisplaces achallengeonexperimentallyattainablestructures,with suchstrictcongurations, itprovidesmotivationforfurthertheoreticalandexperim entalinvestigationswhich couldeventuallyresultinporouscrystallinematerialswi thdesirableH 2 uptakecharacteristics. Long-rangedispersiveinteractionsarenotcapturedwellb yconventionaldensityfunctionalmethodsorbyground-stateHartree-Fockca lculations.[184]Toaccountexplicitlyforelectroncorrelation,secondorderM ller-Plessetperturbation theory(MP2)orresolution-of-the-identityMller-Pless et[185](RI-MP2)isusedin allthecalculationsconductedherein.Thebasissetsselec tedarethoseofDunning[78] whichpresentasystematicseriesofbasisfunctionsthatal lowonetoestimatethe energyofasysteminthelimitofaninnitelylargebasisset {theso-calledcomplete basisset(CBS)limit.[129]Althoughithasbeenobservedth atCBSextrapolations includingthedouble-zetabasissetarenotoptimal,quadru ple-zetacalculationswere tootimeconsumingandconsideredunnecessaryforanestima tionusingamodelsystem.Atwo-pointextrapolationwasperformedusingthedoub le-zeta(cc-pVDZ)and 88

PAGE 103

Figure7.2:MP2/6-31G*optimizedmodelmolecularsquaresh owingthemostfavorableorientationofanH 2 moleculeinteractingsimultaneouslywiththefourbenzene ringsandthebindingenergydependenceonH 2 -benzeneringseparationdistance, R triple-zeta(cc-pVTZ)basissets.Double-zeta,triple-ze taandCBSenergiesareshown inFigure7.2. Asimplemodelsystemwasconstructedutilizingbenzenerin gsasbuilding blocks.Initially,anindividualbenzeneringwasgeometri cally-optimizedatthe MP2/6-31G*leveloftheorytoattainareferencegeometryfr omwhichthemodel systemwasconstructed.Fourbenzeneringswerearrangedin asquaregeometry, suchthatthecongurationroughlymimicsachanneloraboxi namicroporousmaterialoccupiedbyaH 2 moleculewithitscenter-of-masscoincideswiththatforth e square.Forsimplicity,thesquaregeometrywasmaintained whilethedimensions werevariedfrom3.0 Ato4.5 Ainincrementsof0.05 A,measuredfromcenter-ofmassofthesquaretocenter-of-massofabenzenering.Forea chstep,onehydrogen moleculewaspositionedinthecenter-of-massofthesquare andoptimizedatthe MP2/6-31G*levelwhilethesquarewasheldxed.Usingthiso ptimizedgeometry, 89

PAGE 104

bindingenergieswerecomputedusingresolution-of-the-i dentityMP2withDunning's cc-pVDZandcc-pVTZbasissetswiththeircorrespondingRIttingbasissets.[186] Allbindingenergieswerecounter-poisecorrectedandextr apolatedtothecomplete basissetlimit.AllcomputationswereperformedwithNWChe m.[187,188] Thecalculationsrevealeddispersiveinteractionsbetwee nthearomaticwalls ofthemodelboxandtheH 2 moleculereachingamaximumbindingenergyof13.8 kJ/molat R =3.05 A.Consideringthecongurationofthehydrogenmoleculere lativetothefourbenzenerings,thecalculatedenergysugge stsanadditivebehavior ofaromaticring-H 2 interactionsascomparedtoH 2 moleculeinteractingwithone aromaticring. 90

PAGE 105

Chapter8 RapidlyConvergentIterativeTechniquesTowardtheSoluti onof Many-bodyMolecularPolarizationFieldEquations 8.1IntroductionMolecularpolarizationwasexplicitlyincludedintheMont eCarlosimulationsby useoftheThole-Applequistmodel.[27{29]Thismodeltreat sthesysteminterms ofsite(atomic)pointdipolesthatinteract via many-bodypolarizationequations. Onceatomicpointpolarizabilitiesarettoatrainingseto fmoleculesthemodel hasbeenshowntoaccuratelyreproducemolecular/systemdi polesinatransferable ( i.e. system-independent)manner.[27,29]Thismodelofexplici tpolarizationhas beensuccessfullyappliedinnumerousareaswhereinclusio nofpolarizableeectsis paramount,suchasvibrationalspectroscopy,[30,68,69]l iquiddynamics,[70{73]and biomolecules.[74,75] Considerastaticelectriceldappliedtoamolecule.Thein duceddipoleon thismoleculewillbeequalto ~ mol = mol ~ E stat (8.1) where mol isthe3 3molecularpolarizabilitytensoruniquetothatmolecule. We nowconsiderthemoleculardipoleasbeingasumofatomicpoi ntdipoles,onefor 91

PAGE 106

eachatomofthemolecule.Ifwelabeleachatomicpointdipol evector ~ i thenwe have ~ i = i ~ E stat i (8.2) ~ mol = N X i ~ i where i isthe3 3sitepolarizabilitytensorand ~ E stat i istheelectrostaticeldat thesite.IntheThole-Applequistmodelthesystemistreate dasacollectionof N dipolesalongwithadipoleeldtensor T ij whichcontainsthecompletesetofinduced dipole-dipoleinteractions.Thisdipoleeldtensor,when contractedwiththesystem dipoles,yieldsthe(many-body)induced-dipolecontribut iontotheelectriceld-this contributionisdenotedhereas ~ E ind .Sincethedipoleeldtensor(byconstruction) containstheentireinductioncontribution,wecanassigna scalar pointpolarizability, i ,toeachsiteratherthanapolarizabilitytensor: i ~ E stat i = i ~ E stat i + ~ E ind i (8.3) = i ~ E stat i T ij ~ j (8.4) Thisequivalencecanbedemonstratedbyreproducingthesit epolarizabilitytensors via A~ = ~ E stat (8.5) ~ = B ~ E stat (8.6) 92

PAGE 107

where ~ and ~ E stat aresupervectorsformedbystackingthesystemdipole/eld vectors: ~ = 0BBBBBBBB@ ~ 1 ~ 2 ~ 3 ~ N 1CCCCCCCCA ~ E stat = 0BBBBBBBBB@ ~ E stat 1 ~ E stat 2 ~ E stat 3 ~ E stat N 1CCCCCCCCCA andthematrices A and B aredenedby A = h ( ) 1 + T ij i (8.7) B = A 1 Justas A isasupermatrixcomposedof3 3blockelements T ij B canbe decomposedas[29] B = 0BB@ B 11 B 12 B 1 N B 21 B 22 B N 1 B NN 1CCA whereeachblockelement B ij isa3 3matrix.Theseblockelements B ij arethesite polarizabilitytensorsandthuscharacterizethesite'sre sponsetoanelectriceld.For example,thematrix B formedbysummingthe th rowof B B =( B 1 + B 2 + ::: + B N ) 93

PAGE 108

determinesthedipoleresponsetoaeldforsite asafunctionofall N sitessince (makinguseofEquation8.6) ~ = B 1 ~ E stat 1 + B 2 ~ E stat 2 + ::: + B N ~ E stat N = ~ (1)+ ~ (2)+ ::: + ~ ( N ) wherebyeach termrepresentsacontributiontoward 'sdipole.Therefore,summing allofthe ij blocksoverthetensorcomponents foranappropriatesetofsitesyields themolecularpolarizabilitytensor:[29] mol = X i;j ( B ij ) (8.8) TheApplequistdipoleeldtensor[27]canbederivedfromr stprinciplesas T ij = r r 1 r ij = r 3 ij 3 x x r 5 ij (8.9) Themostdirectwaytocalculatethesystemdipolesisthroug hEquation8.6. However,sinceinversionofthe3 N 3 N matrix A iscomputationallyecientfor onlythesmallestsystemsthedipolesmustbesolvedforbyan iterativemethod.The iterativemethodemployedheremakesaninitialguessof ~ i = i ~ E stat i andthen iterativelysolvesEquation8.4untilconvergenceisachie ved. TheTholemodelintroducestheadditionalconsiderationof treatingeach dipoleasinteractingwithawell-behavedchargedistribut ion ( u )(incontrastto theApplequistmodelwherethedipoleeldtensorisderived byconsideringadipole interactingwithapointcharge,givingrisetoEquation8.9 ),whichresultsinamod94

PAGE 109

iedformofthedipoleeldtensor.Thenetresultofthismod icationisthatthe chargewhichinduceseachdipoleis\smeared"atshortrange ,anditisthisadditionalstructurethatTholeaddedtothemodelwhichimparts transferability.One suchexponentialdistribution[28]foundtoaccuratelyand transferably[29]reproduce moleculardipolesforanassociatedseriesofdependentpol arizabilitiesis ( u ij )= 3 8 e u ij (8.10) u ij = x ij i j 1 6 wherethefreeparameter hastheeectofdampingthedipoleinteractionsnear theregionsofdiscontinuitythatwouldotherwiseexistint heApplequistmodel.The coordinatescalingof x ij u ij isdoneforconvenienceinordertoallowsimplefunctionalformssuchasEquation8.10tobeusedfordamping.Tak ingtheexponential chargedistributionintoaccount,themodieddipoleeldt ensorbecomes[29] ^ T ij = r 3 ij 1 2 r 2 ij 2 + r ij +1 e r ij 3 x x r 5 ij 1 3 r 3 ij 6 + 2 r 2 ij 2 + r ij +1 e r ij (8.11) Themany-bodypotentialenergyduetotheinteractionofthe induceddipoles (referredtoasthepolarizationenergy)isdescribedby[28 ] U pol = X i 1 2 ~ i A~ i ~ i ~ E stat i = X i 1 2 ~ i ~ E stat i ~ i ~ E stat i = 1 2 X i ~ i ~ E stat i (8.12) 95

PAGE 110

whereitshouldbepointedoutthat ~ E stat i isnotthetotalelectriceld,butrather onlythestaticelectriceldduetothepresenceoftheparti alchargespresentinthe system.8.2IterativeMethodsforMany-bodyPolarizationCalculatingthepolarizationenergyforthesystemamounts toself-consistentlysolving thedipoleeldequationforeachatomicdipolevector ~ i throughaniterativeprocess untilasucientdegreeofprecisionisachieved.Thus,toma kethecalculations practical,ecientmethodsofsolvingtheeldequationswe rerequired.Typically,a simultaneousover-relaxationscheme( i.e. linearsolutionmixing), k +1 i = r ki +(1 r ) k 1 i (8.13) isusedtoimprovetheconvergenceratefortheiterativemet hodofsolution.[71] However,recentlyanumberofmultigridtechniques[76]hav ebeenappliedtothe Tholemodelforaone-dimensionalsystem[77]andasimilarG auss-Seidelsmoothing techniquewasappliedhereandfoundtoreducethenumberofi terationsrequired forconvergencebytwo-foldoverlinearmixing.Theapplied Gauss-Seidelnumerical iterationmethodforaslowlyconvergingprocessconsistso fupdatingthecurrent dipolevectorsetforthe k th iterationstepasthenewdipolevectorsbecomeavailable: ~ ki = i ~ E stat i ^ T ij ~ k 1+ j (8.14) = 0 ; if ij WhiletheGauss-Seideliterativemethodhasbeenusedinnum erousareasof scienceandmathematicsfordecades,anovelapproachwasta kenheretofurther 96

PAGE 111

improvetheiterativeconvergenceofthepolarizationmode lemployed.[4]Itmay benoticedthatthe order inwhichtheGauss-Seidelupdatesaremadeavailable iscompletelyunspecied,sincetherearenouniqueorderin gofindicesimpliedin Equation8.14.Inthiswork,analgorithmicapproachhasbee ntakenwhetherthe dipolesthatstandtovarythemostbetweeniterationsareup datedrst. Thealgorithmsproceedbyassigningametrictoeachdipolei nordertoapproximatelypredictit'svariancethroughouttheiterativesub space.Onesuchalgorithm is:fori,j ifr(ij)
PAGE 112

Furthermore,ithasbeenrepeatedlyobservedthatthetende ncyisforthe dipolestogrowinmagnitudeasafunctionofiterativeprogr ess.Therefore,apreconditiontransformationofthefollowingformhasbeenapplie dtothedipolevectors: 0 = P ( E stat )(8.15) P = rI (8.16) (8.17) where r istypicallybetween1.0-1.4.Thisisthemostsimpleprecon ditioningstepone cantake,andit'seects(asshowninthenextsection)arefa irlydramatic.There aremoresophisticatedpreconditioners,onecanimagine,t hatwouldimprovethe convergencepropertiesevenfurther(e.g.apreconditioni ngmatrix P asadiagonal formofthedipoleeldtensor,etc.). Ithasbeenreportedintheliteraturethatifaperturbative correctiontothe polarizationenergyismade,thattheenergywillconvergem uchmorerapidlythan thedipoles.[189,190]Wewillrefertothismethod,duetoPa lmoandKrimm,as the\PK"methodanditresultsinthefollowingenergyexpres sionasdistinctfrom Equation8.12: U k pol = 1 2 X i ki E stat i 1 2 X i ki E k +1 i (8.18)(8.19) Inprocedure,thismeansthattheenergyisdependentuponth edipolesonthe k -thiterationstepwiththeinducedeldfromthe k +1-thstep.Sincethepolarization energyisofprimeimportancetotheMonteCarlomethodswide lyusedhere,thisPK techniquehasbeenimplementedandfurtherenhancedwithth eGauss-Seidelscheme 98

PAGE 113

Figure8.1:Theiteratedenergyvs.theexactmatrixinversi onenergyasafunction ofiterativeconvergenceforvariousSCFmethods.describedabove.8.3ResultsAsatestcase,stateshavebeengeneratedfor64SPCFwatermo leculesxedtothe liquiddensityat298KusingNVTMonteCarlo.Waterisanexce llenttestcase forinvestigatingelectrostaticinductionsincethedipol emagnitudeofthecondensed phaseisdramaticallydierentfromthegasphase( 2.8Dvs.1.5D). ShowninFigure8.1isacomparisonoftheSCFenergyvs.theex actmatrix inversionenergyforanumberofiterativeschemepreviousl ydescribed.Itshould notedthatthebestperformingSCFtechniqueisGauss-Seide literationswiththe metricrankingschemeandpreconditioning.Itisalsofound thatwhenappliedtothe 99

PAGE 114

Figure8.2:TheiteratedPKenergyvs.theexactmatrixinver sionenergyasafunction ofiterativeconvergenceforvariousSCFmethods. 100

PAGE 115

Figure8.3:Relativerootmean-squaredeviationofthedipo lesasafunctionofiterativeprogressforvariousSCFmethods.PKenergycorrectionmethod,theenergyisdramaticallybet terconverged,asshown inFigure8.2. Furthermore,asifevidentinFigure8.3,notonlyisthepola rizationenergy moreconvergentbuttherelativerootmeansquareofthedipo lesisgreatlyreduced. Thisexampleillustratesthatwithverylittleextracomput ationworkboththeenergy anddipolesaremoreaccuratelyconvergedwiththenovelite rationschemeusedhere. Table8.1showsthatasa2-stepiterationscheme,theiterat ivetechniques employedhaveresultinconvergenceoftheenergytowithin0 .02%,ascomparedto thePKmethod(whichwaspreviouslyconsideredthemosteec tivetechnique)which islessthan4%.Inaddition,theRRMSofthedipolesislessth an6%,withfurther reductioninRRMSproceedingwithincreasediterations.Th ecomputationalsavings thathavebeenresultedfromthesetechniqueshavebeenenor mous,asthenumber 101

PAGE 116

Itertype PKE mat /E scf %Error RRMS% SCF 3.84 11.7 SOR 7.14 11.8 GS 0.049 7.4 GSPre 0.024 6.3 GSRank 0.045 7.5 GSPreRank 0.016 5.9 Table8.1:ComparisonoferrorforthevariousSCFmethodsas a2-stepiteration schemeofiterationsnecessarytogetwell-convergedenergiesfor hydrogeninpolarMOFsis typically10{but,ashasbeenshownhere,thesamelevelofac curacycanbehad witha2-stepiterationscheme. 102

PAGE 117

Chapter9 CalculationofRotationalSpectraforSorbedHydrogeninMe tal-Organic Materials Thischapterdescribedcollaborativeworkthatisongoingw ithZlatkoBacic(NYU), IvanaMatanovic(NYU)andJuergenEckert(UCSB/LANL)toex plorethequantum mechanicalaspectsofhydrogenrotationnearsurfaces.Usi ngnewlydevelopedpotentialsthatdescribedthehydrogen-MOMinterface,wesolvet heSchrodingerequation foreachH 2 andthusobtaintherotationalenergylevels.Themethodolo gyandcodebasedevelopedallowfortheinclusionof ortho/para nuclearspineectsinMonte Carlosimulationandcomparisonwithexperimentalrotatio nalspectra. 9.1IntroductionThequantummechanicalaspectsoftherotationofahydrogen moleculearefascinatingandpresentaninterestinghistoricalperspectiveinto thegreatsuccessofquantum statisticalmechanicsatresolvingtheobservedheatcapac ityofhydrogen. ConsiderprotiumH 2 ,whosenucleiarefermionsandthustheoverallsymmetry ofthehydrogenwavefunctionmustobeythePauliprincipleb ychangingsignupon nuclearinversion.Writingthetotalwavefunctionasaprod uct: 103

PAGE 118

H 2 = nuc elec trans vib rot (9.1) whereweareconsideringthevariouscontributionstotheha miltonianasbeingseperable.Wenotethat,intheelectronicgroundstate, elec issymmetricunderinversion. Translational/vibrationsymmetryanalysisresultsinthe sameconclusion. However,thenuclearspineigenfunctionsconsistof3symme tricsolutions( , + )and1antisymmetricsolution( ).Since H 2 mustremain antisymmetricoverall,thisrequiresthat therotationaleigenfunctionsmayonlybe symmetricorantisymmetric,dependinguponthenuclearspi nstate Forarigidrotor,therotationaleigenfunctionsarethefam iliarsphericalharmonics,whosesymmetryalternatesfromg/ualongtheenergy spectrum.Therefore, ifthenuclearspinshappentobeparallelthenthemoleculew illbeinarotational statecorrespondingto J =even,and J =oddforantiparallelnuclearspins.These distincthydrogenmoleculesarecalled para or ortho hydrogen,respectively,andfor highlyexcitedhydrogenwilloccurinthe1:3ratiocorrespo ndingtothenuclearspin degeneracies.[191]Followingthesameconsiderationsfor deuterium,tritiumorcombinationsthereof,producedierentpopulationratios. Nearlyallsubstancesexistinthesolidstateattemperatur eslowenoughto observeselectiveoccupationofrotationalenergylevelsd uetothesenuclearspin eects.However,hydrogeninuniqueinthatitisstillagasw heretheseeectsare dominant!(Thecharacteristicrotationaltemperatureofh ydrogenis85K). Offurtherinterestisthefactthatthebarrierto ortho/para interconversionis extremelyhigh,andthusitispossibletocoolhydrogenfrom agastoaliquidandstill have1:3ratioofpopulations,despitethefactthatallofth ehydrogenshouldbethe J =0( para )state.Thisnon-equilibriumcoexistencewilloccurtypic allyforweeks 104

PAGE 119

beforemagneticinteractionswiththeenvironmentdrivein terconversiontotheground state.Thisposesanenormousengineeringchallengeforcry ogenichydrogenstorage applications,sincetheheatreleaseduponinterconversio nlargerthantheenthalpy ofvaporizationandsothereareconstantLH 2 boil-oissues.Typically,metaloxide catalystsareemployedtohelptheinterconversionprocess alongasthehydrogenis condensed. Selectiveadsorptionand/orinterconversionofhydrogenn uclearspinisomersin Metal-OrganicFrameworkshasnotbeenpreviouslyexplored theoretically(although suchstudieshavebeenundertakenforhydrogeninzeolites[ 18,36]).Herein,adescriptionofthemethodologyandsourcecodeforallowingsuchcal culationsisexplained alongwithresultsofthisappliedsystem.9.2MethodsandResultsForeachH 2 inthesystem,thegoalistodiagonalizetherotorhamiltoni anina sphericalharmonicbasis.Eachmatrixelement, h Y lm j V ( ; ) j Y lm i isconstructedby Gauss-Legendrequadrature(16pointintegration)usingam oderatelysizedbasisset consistingofboth+m,-mfunctions.Thepurelykineticener gy(i.e.rigidrotorpart) l ( l +1)isaddedtothediagonalelements.Thehermitianmatrixi sthendiagonalized usingtheLAPACKlinearalgebrapackage,yieldingtherotat ionalenergyeigenvalues andtheeigenvectorcoecients. Forexample,theenergylevelsofthehinderedrotorpotenti alofCurletal,[192] V ( ; )= V 0 sin 2 (9.2) havebeenfoundusingtheMPMCcode(describedinAppendixL) andthelevels areshowninFigure9.1.InthisFigure,weobservethewell-k nownrotationaltunnel splittingeectwherebyinthepresenceofarotationalbarr iertherotorationalenergy 105

PAGE 120

Figure9.1:Rotationaltunnelsplittingforahinderedroto r 106

PAGE 121

levelssplitandgroupaccordingtotheir m values(dependinguponthesymmetryof thebarrier).Notethatthe m =0levelssplitofromtheother m valuessincethere isno dependenceinthepotential. Figure9.2:RotationaltunnelsplittingforH 2 alongadisplacementvectorfromthe globalminimumenergyadsorptionsite. InaMOF,however,theenergylevelsmaysplitinmorecomplex waysgiventhe curvatureofthepotentialenergysurface.Therotationale nergylevelsofhydrogenin thevicinityoftheglobalenergyminimumbindingsiteinMOF -5havebeencalculated asafunctionofcenter-of-massdisplacementfromthissite ,andareshowninFigure 9.2.Theglobalenergyminimumcongurationhadbeenprevio uslydetermined via simulatedannealing.Itshouldbepointedoutthatalongthe negativedisplacement (i.e.inthepore)thehydrogenisrigidrotor-like,withit' sassociateddegeneracies. Tothefarright,upagainstapotentialbarrier,weseecompl etesplittingofenergy levels.However,intheregionneartheminimumweseemoreco mplicatedspacing 107

PAGE 122

ofthelevels,withsomelevelscompletelyshiftingwithres pecttooneanother.(Asa result,theMPMCcodebasedeterminesthesymmetryofeachei genvectorindividually).Transitionsbetweensuchenergylevels(observedin ,forexample,INSspectra) cannowbeassociatedwithspecicbarrierstothebindingsi teintheMOFusingthis methodology. 108

PAGE 123

Chapter10 MicrocanonicalEectivePartitionFunction Themicrocanonicaleectivepartitionfunction,construc tedfromaFeynman-HibbsKleinertpotential,isderivedusinggeneralizedensemble theory.Theformofthe potentialisamenableto NVE MonteCarlosimulationtechniquesandtherelevant Metropolisfunctionispresented.Thelow-temperatureent ropyofaprotoninan anharmonicpotentialisnumericallyevaluatedfromthemic rocanonicaleectivepartitionfunctionandfoundtobeaccuratecomparedtothecano nicaltechnique. 10.1IntroductionTheGreen'sfunctionforthequantumpropagator, G ( x 0 ;t 0 ; x;t )= h x 0 j e i ^ H ( t 0 t ) = ~ j x i (10.1) canbeexpressedinit'spathintegralform[193],afterTrot terfactorizationandmaking useoftheresolutionoftheidentity,as:[194] G ( x 0 ;t 0 ; x;t )=lim P !1 1 Z 1 dx 1 :::dx P 1 m 2 i ~ P= 2 e i ~ t 0 R t d n 1 2 m ( dx d ) 2 V [ x ( )] o (10.2) 109

PAGE 124

wherethetimeinterval =( t 0 t ) =P andthepathfrom x x 0 hasbeendiscretized among P points.AnalyticallycontinuingEq.(10.2) via thesubstitution = it= ~ andlettingtheinitialtime t =0resultsin G ( x 0 ; i ~ ; x )=lim P !1 1 Z 1 dx 1 :::dx P 1 m 2 ~ 2 P= 2 e 1 ~ ~ R 0 d n 1 2 m ( dx d ) 2 + V [ x ( )] o (10.3) Itcanbeshownthatthecanonicalpartitionfunction Q ( N;V; )resultsfrom takingthetraceofexpression(10.3),wherethepathspropa gatefrom x x : Q ( N;V; )= 1 Z 1 dxG ( x; i ~ ; x ) = 1 Z 1 dx lim P !1 1 Z 1 dx 1 :::dx P 1 m 2 ~ 2 P= 2 e 1 ~ ~ R 0 d n 1 2 m ( dx d ) 2 + V [ x ( )] o (10.4) andtheintegrationisdoneoverallpossibleclosedpathsth atstartandendat x Agreatdealofappliedresearchhasproceededfromtheappro ximationwherebyEq. (10.4)isclosedforaniteTrotternumber P .Indeed,insuchaformexpression(10.4) thenlooksverymuchlikeaclassicalpartitionfunction(al beitwithanodd-looking -dependentharmonicterm)andcanbenumericalevaluatedby many-dimensional integrationtechniquessuchasMonteCarlo. However,analternativeapproachistoapproximatetheinte gralsover 1 R 1 dx 1 :::dx P 1 via avariationalprinciple[195]theresultofwhichisthenexp ressedasanexponential ofan eectivepotential f W ( x ): 110

PAGE 125

Q ( N;V; ) e Q ( N;V; )= 1 Z 1 dx r m 2 ~ 2 e f W ( x ) (10.5) where e Q ( N;V; )isthe canonicaleectivepartitionfunction ;inthehigh-temperature limit e Q isequivalenttoEq.(10.4).Init'soriginalformulation, f W ( x )minimizesthe variationiftakentobeagaussian-smearedpotential, f W ( x )= 1 Z 1 dy 1 p 2 a 2 e ( x y ) 2 2 a 2 U ( y )(10.6) whereinit'srstapproximationthegaussianwidth a 2 = ~ 2 = 12 m andthesamexedwidthapproximationismadehere.Techniquesthatimproveu ponthexed-width approximationhavebeenpreviouslymade.[196,197]TheTay lorseriesexpansionof expression(10.6)yieldsthefamiliartermscommonlyusedi nmolecularsimulation. Thecanonicaleectivepartitionfunctionhasbeenofsigni cantvalueinnumericalstatisticalmechanicssinceitincludesquantumru ctuationswhilepreserving theclassicalmathematicalstructureofthepartitionfunc tion.Inthesimplestapproximationofaxed-gaussianwidthof ~ = 12 m theeectiveapproachprovidesaccuracy amenabletothesemiclassicalregime. Curiously,whilethepathintegralexpressionforthemicro canonicalpartition functionhasbeenderived[198],toourknowledgethemicroc anonicaleectivepartitionfunctionhasnotbeenreportedintheliterature.While thecanonicalensemble isquitenaturalforthestudyofmanyphysicalsystems,ther earecaseswherethe microcanonicalensembleismoreconvenientsincethetherm odynamicenergycanbe xed.Ourintentionhereistodevelopthemicrocanonicale ectivepartitionfunctionsuchthatquantumructuationsmaybeincludedin,forin stance, NVE Monte 111

PAGE 126

Carlo[7,8]simulations.10.2MicrocanonicalDerivationWederivethemicrocanonicaleectivepartitionfunctiont hroughapplicationofgeneralizedensembletheory[199{201]whichallowsustorelat etheconstantenergyshell ensembles directly tootherensemblesinwhichthermalenergycanrowbetweensy stemandbath.OfimmediateinterestistheLaplacetransform relationshipbetween thecanonicalandmicrocanonicalpartitionfunctions,sow edemonstratewiththe followingexample: Q ( N;V; )= 1 Z 0 dEe E n( N;V;E )(10.7) sincetheenergyspectrummayalwaysbeshiftedsuchthatthe lowerboundiszero; additionally,ofcourse 2 C .Insolvingforthemicrocanonicalpartitionfunction, theinverseLaplacetransformyields: n( N;V;E )= 1 2 i I de E Q ( N;V; ) = 1 Z 1 d n 1 2 i r + i 1 Z r i 1 de ( E H ) (10.8) where d nisthephasespacedierentialform h 1 dxdp .Since = + i andno singularityispresentintheright-halfofthecomplexplan e,wemaytakethecontour verticallythrough r =0.SinceRe( )=0alongtheintegrationwemaymakethe substitution = i : 112

PAGE 127

n( N;V;E )= 1 Z 1 d n 1 2 1 Z 1 de i ( E H ) = 1 Z 1 d n ( E H )(10.9) whichisthemicrocanonicalpartitionfunction,asitshoul dbe.Anothersimpleexampleisthequantumharmonicoscillator: n HO = 1 2 i I de E Q HO = 1 2 1 Z 1 de iE e 1 2 i ~ 1 e i ~ = 1 2 1 Z 1 de i ( E 1 2 ~ ) X n e i ~ !n = X n E ~ n + 1 2 (10.10) 10.3AnharmonicOscillatorandNumericalEvaluationAlongsimilarlines,wewishtoconstructthemicrocanonica leectivepartitionfunction e n( N;V;E )from e Q ( N;V; )throughuseofthesameLaplacestructure.Proceedinginthismanner, e n( N;V;E )= 1 2 i I de E e Q ( N;V; ) = 1 2 i I de E 1 Z 1 dx r m 2 ~ 2 e f W (10.11) 113

PAGE 128

UsingEq.(10.6),thegaussiansmearedversionoftheanharm onicpotential U AHO = 1 2 kx 2 + 1 4 gx 4 isexactlyintegrableandyields f W AHO = U AHO + ~ 2 24 m k +3 gx 2 + ~ 2 24 m 2 3 g (10.12) = U AHO + W 1 ( )(10.13) fortheeectivepotential.Withthemomentumintegrationh avingbeenundone,the inverseLaplacetransformnowbecomes: e n AHO ( E )= 1 Z 1 d n 1 2 i I de [ E H W 1 ( )] = 1 Z 1 d n 1 2 i I de ( E H ) e 2 h ~ 2 24 m ( k +3 gx 2 ) i e 3 ~ 2 24 m 2 3 g = 1 Z 1 d n 1 2 i I de a b 2 c 3 (10.14) wherethecontourintegralcanbeapproximatedbythemethod ofsteepestdescent toyield = 1 p 2 1 Z 1 d n e a 0 b 2 0 c 3 0 (4 b 2 +12 ac ) 1 4 (10.15) wherethesaddlepoints, 0 ,are 0 = p 4 b 2 +12 ac 2 b 6 c (10.16) 114

PAGE 129

recallingthatthefollowingsubstitutionshavebeenmade, a = E H b = ~ 2 24 m k +3 gx 2 c = ~ 2 24 m 2 3 g Figure10.1:Classicalentropyforaprotoninananharmonic wellvs.thequantum mechanicresult(canonicalensemble). Evalutionofexpression(10.15)hasbeenperformedtoobtai ntheentropyof aprotoninananharmonicwell.InFig.10.1,theFeyman-Hibb s-Kleinertmicrocanonicalentropy, S = k ln e n AHO ,iscomparedwiththeexactclassicalandquantum mechanical[202]entropyfoundfromthecanonicalensemble S = k ln Q + E=T 115

PAGE 130

Chapter11 AStudent-FriendlyDerivationofthePartitionFunctionfo rGeneralized Ensembles Theconnectionsbetweenthecombinatoricformula S = k ln W ,theGibbsentropy, S = k P i p i ln p i ,andthemicrocanonicalentropyexpression S = k lnnareclaried,includingaddressingtheirrangeofvalidity.Thecon ditionformicrocanonical equilibrium,andtheassociatedroleoftheentropyastheth ermodynamicpotentialisshowntoarisefromthepostulateofequal apriori states.Thederivationof thecanonicalpartitionfunctionfollowsbyinvokingtheGi bbsensembleconstructionandtherstandsecondlawofthermodynamics( via thefundamentalequation dE = TdS PdV + dN )thatincorporatetheconditionsofconservationofenergy andcompositionwithouttheneedsforexplicitconstraints .Theneedforexplicitmaximizationofanyfunctionisthusalsoavoided.ByLegendret ransformingtherelevant thermodynamicfunctiontoanensembleofinterest,ananalo gousprocedureleads tothecorrespondingpartitionfunction.Connectionstoge neralizedensembletheory alsoariseinthiscontext.Thecentralroleoftheentropyin establishingequilibrium foragivenensembleemergesnaturallyfromthecurrentappr oach. 116

PAGE 131

11.1IntroductionInderivingthepartitionfunctionforadesiredensemble,t hemostcommonapproach istomaximizeanentropyfunctionwithconstraintsappropr iatetothethermodynamiccondition.Whileequivalenttotheapproachproposed below,suchamethod (calledthetraditionalapproachhereafter)doesnotmakee xplicitthecentralroleof theassumptionofequal apriori statesandthecorrespondingroleoftheentropyasthe thermodynamicpotentialforthemicrocanonicalensemble. Indeed, S = k lnnisoftentakenasapostulate[203]anditsconnectiontothestati sticalformula S = k ln W (appearingonBoltzmann'stombstone)isnotevident.Furth er,inthetraditional approach,theroleoftheentropyinunderstandingequilibr iuminnon-isolated,open ensemblescanbeconfusing. Also,frequentlyomittedistheGibbsentropy, S = k P i p i ln p i ,where p i is theprobabilityofndingasysteminagivenstate,whichcan beinvokedforanyequilibriumensembleandassociatedstateprobabilities.Itis adirectconsequenceofthe statisticalentropyformula, S = k ln W ,inconjunctionwiththeGibbsconstructionof anensemblewithalargenumberofmacroscopicsubsystems,e achconsistentwiththe desiredthermodynamicvariables; W givesthenumberofpossiblerealizationswithin theGibbsconstructionfortheensembleunderconsideratio n.TheGibbsentropyalso permitsthederivationoftheconnectionbetweenthecharac teristicthermodynamic functionandthepartitionfunctionforagivenensemblewit houtfurtherappealto thermodynamicexpressions,asisrequiredinthetradition alapproach. Inthepresentapproach,rst,theconnectionbetweenthest atisticalformula S = k ln W ,theGibbsentropy, S = k P i p i ln p i ,andthemicrocanonicalentropy expression S = k lnnareclariedincludingaddressingtheirrangeofvalidi ty.The conditionformicrocanonicalequilibrium,andtheassocia tedroleoftheentropyasthe thermodynamicpotentialthenarisesfromthepostulateofe qual apriori states.The derivationofthecanonicalpartitionfunctionfollowsbyi nvokingtheGibbsconstruc117

PAGE 132

tionandtherstandsecondlawofthermodynamics via thefundamentalequation, dE = TdS PdV + dN ,thatincorporatestheconditionsofconservationofenerg y andcompositionwithouttheneedsforexplicitconstraints .Theroleofthetemperature(comingfromtheconstraintoftotalenergyandana ppealtoappropriate thermodynamicrelationshipsinthetraditionalapproach) isimmediatelyapparent andalsointroduced via thefundamentalequation.Theneedforexplicitmaximizationofanyfunctionisthusalsoavoided.ByLegendretransf ormingacharacteristic thermodynamicfunctiontoanensembleofinterest,ananalo gousprocedureleads tothecorrespondingpartitionfunction.[204]Connection stogeneralizedensemble theoryalsoariseinthiscontext.Thecentralroleoftheent ropyinestablishing equilibriumforagivenensemblealsoemergesnaturallyfro mthecurrentapproach. Thepresentapproachisnovelinprovingclarityastotherol esplayedbythe dierentformulasandphysicalquantitiesofinterestwhil edrawinguponportionsof severalexistingderivations.Further,itmakesexplicitt heassumptionsinherentin derivingthepartitionfunctionforanensembleandprovide sitsdirectconnection totherelevantthermodynamicpotential.Thisapproachals omakesderivingthe partitionfunctionforagivenensembleasimplied,straig ht-forwardprocess,even formoreobscureexamplessuchastheisothermal-isobarice nsemble. 11.2TheGibbsEntropyandtheMicrocanonicalEnsembleWebeginbyintroducingtheconceptofanensembleofreplica sthatdescribethe molecularstatescorrespondingtoagivenmacrostate;this pictureisreferredtoas the\Gibbsconstruction"herein,duetoit'soriginalintro ductionbyGibbs[205]who addressedmanyofthesubtletiesinherent[203]intheformu lationofstatisticalmechanics.Consideracollectionofmacroscopicmolecularsu bsystemsof N molecules withinavolume V ,eachofwhichispartofthelargerGibbsconstruction.Noot her constraintshaveyetbeenimposed, i.e. thesystem'smacrostateisotherwiseunspec118

PAGE 133

ied.Itisdesirabletodenethemicroscopicstatisticsof thissystemasthoroughly aspossibleandthenapplyanyotherconstraintsattheend. Letthetotalnumberofsubsystemsinourcollectionbeknown asn.Thenlet i ,theoccupationnumber,denotethenumberofsubsystemsfro mthiscollectionthat areinthesamethermodynamicstate.Theseoccupationswill thustakeonalarge valueinthethermodynamiclimitandtheyobeysasumrule, P i i =n.Notethat technicallytheenergyiscourse-grained, i.e. speciedtowithinasmallbutotherwise arbitraryrange(theseargumentsarepresentedindetailel sewhere[203,206])andthe resultsareinsensitivetothischoice. First,considerthefollowingcombinatoricformula: S = k ln W f g = k ln n! 1 ! 2 ::: (11.1) W f g isthenumberofwaysinwhichthesetofoccupations f g maybearranged. First,itistobeshownthatwhenevaluatedatxedenergy,th isquantity S maybe identiedwiththethermodynamicentropyofasystematequi librium. Proceeding,byapplyingtheSterlingapproximation[207]t othefactorialfunctiongives: S = k ( nlnn n X i i ln i + X i i ) = k f nlnn n 1 ln 1 + 1 2 ln 2 + 2 ::: g (11.2) Usingtheabovesumruleeliminatesthemiddletwoterms.Fur therrewriting 119

PAGE 134

theabovesumsusingthepropertyofthenaturalloggives: = k 8<: lnn+lnn+ ::: | {z } ntimes n+ 1 + 2 + ::: | {z } n 1 ln 1 ::: 9=; = k n 1 ln 1 n 2 ln 2 n ::: o (11.3) InEquation11.3thelnn'shavebeendistributedamongstthe occupationterms. Identifyingtheprobability p i = i = nleadstotheGibbsentropyfortheasyet unspeciedensemble;theGibbsentropyisanentirelygener aldenitionthat,forany equilibriumensemble,speciestherelationshipbetweent hepartitionfunctionand theassociatedcharacteristicthermodynamicfunction. S n = k X i p i ln p i (11.4) Now,specializingtoasetofmicrocanonicalsubsystems,an dinvokingthe equilibriumprincipleofequal apriori states, i.e. p i =1 = n,givesthewellknown result: S n = k n X i 1 n ln 1 n = k lnn(11.5) ItisalsosimpleandusefultoshowthattheGibbsentropy,an dthusthethermodynamicentropy,ismaximizedmicrocanonically[208]bythes tate-independentprobabilities p = p i =1 = n.Proceeding,takingthederivativeofEquation11.4andse tting ittozeroas @ @p j k X i p i ln p i =0(11.6) 120

PAGE 135

gives p j =1 =e ,aconstantvalueindependentofthesummationindex.Thus, normalizingtheprobabilitiesas, n P i p i =1immediatelyyields p i =1 = n. Thus,foranisolatedsystem,theassumptionofequal apriori statesleads toaprobability p i thatisindependentofindex, i.e. everysubsystemhasenergy E byconstruction.Further,thecharacteristicmaximumentr opyinthemicrocanonical equilibriumstatealsofollows.ThenapplyingtheGibbsent ropyexpressionleadsto theidenticationofthethermodynamicentropyasthemicro canonicalcharacteristic functionandgivesitsrelationshiptothe N;V;E partitionfunction,n( E ),whichcan alsobeinterpretedasthedensityofsubsystems[203](stat es)atthatenergy. 11.3ASimpliedDerivationoftheCanonicalPartitionFunc tion SpecializingtheGibbsconstructionfromtheprevioussect iontoincludetemperature { N;V;T arenowdenedforeachsubsystem.Thiscanbethoughtofbypl acingthe subsystemsincontactwithalargeheatbathoftemperature T .[203,208] Usingtheearlierresult,theentropyforacollectionofsub systemswitha speciedenergy E i is S i = k lnn( E i ). Considertheratioofthedensityatenergies E i +1 >E i : n( E i ) n( E i +1 ) = e 1 k S i e 1 k S i +1 = e 1 k ( S i +1 S i ) (11.7) Thefundamentalequationofthermodynamics[209]isnowinv oked: dE ( S;V;N )= TdS PdV + dN (11.8) Thecanonicalensembleisgivenbyastatewithwelldenedth ermodynamic 121

PAGE 136

variables, N;V;T .Sotheenergyfunction, E ( S;V;N )isLegendretransformedtoa newthermodynamicfunction,theHelmholtzfreeenergy, A ( T;V;N ) via : A = LT f E g = E S @E @S = E ST (11.9) dA = dE TdS SdT (11.10) wheretheconditionforcanonicalequilibriumisthat dA =0and N;V;T areconstant, giving: 0= dE TdS (11.11) dS = 1 T dE (11.12) Integratingbetweentwostatepointsgives: i +1 Z i dS = 1 T i +1 Z i dE (11.13) S i +1 S i = 1 T ( E i +1 E i )(11.14) Note,theconstraintsofxedtemperature,particlenumber andvolumehave beenexplicitlyenforcedbyusingthefundamentalequation ,Equation11.8anddroppingdierentialtermsthatarexedcanonically. SubstitutingEquation11.14intoEquation11.7gives: n( E i ) n( E i +1 ) = e 1 k ( S i +1 S i ) = e E i +1 e E i (11.15) 122

PAGE 137

where =1 =kT Equation11.15isclearlysuggestiveofcanonicalformsand allowsthedefinitionofthenormalizedprobability, p i = i = P i i = e E i =Q i.e thecanonical probabilityexpression,wherethenormalizationfactor, Q = P i e E i ,isidentiedas thecanonicalpartitionfunction. WecannowproceedtousetheGibbsentropyexpression,Equat ion11.4, substitutingthecanonicalexpressionfor p i toobtain: S = k X i e E i Q ln e E i Q S = k ln Q Q X i e E i + k X i E i e E i Q TS = kT ln Q + h E i NVT (11.16) Above, h E i NVT representsthecanonicalaverageenergythatisidentiedw ith thethermodynamicenergy, E .[191,203]Thus,therelationship A = E TS = kT ln Q isobtaineddirectlyfromtheGibbsentropy.Note,theGibbs entropyis denedforanysetofprobabilitiesand,aswasshownabove,i ssimplyaconsequence ofthecombinatoricformula S = k ln W interpretedinthecontextoftheGibbsconstruction.Thus,anentropycanbeassociatedevenwithnone quilibriumprobabilities. However,inthatcase,theentropydoesnotplaytheroleofbe ingtheconstrained maximizedquantitythatitdoesatequilibriumanditsutili ty,insuchcircumstances, isunclear. Further,notethattheroleoftemperatureisintroduced via thefundamental equationwithoutfurtherappealtothermodynamicrelation ships.Thisemphasizes theroleoftemperatureasthesystemisincontactwithaheat bath{dierentenergy rangesarenowaccessiblewithcanonicalprobabilities.Th eabilityofadiathermal systemtoexchangeenergywithitssurroundingsalsoclari eshowtheconceptsof 123

PAGE 138

workandentropymakesenseforanopensystemandprovidesth eirrelationshipto thetemperature. Figure11.1:Gibbsconstructionforthecanonicalensemble .Thesubsystemsofidentical N;V areinthermalequilibriumwithalargebathattemperature T 11.4GrandCanonicalPartitionFunctionUsingtheGibbsconstructionfromthepreviouslyderivedca nonicalensemble,the constraintthatallsubsystemspossessidentical N cannowberelaxed.Wenow considertheratioofsubsystem,havingchosenaparticular systemfromtheenergy level E i with N j molecules: n( N j +1 ;E i +1 ) n( N j ;E i ) = e 1 k ( S i;j S i +1 ;j +1 ) (11.17) Asbefore,thefundamentalequationofthermodynamicscanb ereliedupon torelatethechangeinentropytotheothervariablesofoure nsemble.Inthiscase, theprobabilitiesthatwillgeneratethemacrostatecorres pondingtoconstant ;V;T 124

PAGE 139

aredesired.Afterdoingso,theentropy viatheBoltzmannlaw isusedtodetermine themicroscopicstates. Legendretransformingthecanonicalthermodynamicequati ontosubstitute for N : G = LT f A g = A N @A @N = A N (11.18) dG = dA Nd dN = dE TdS SdT Nd dN (11.19) whereatequilibrium dG =0andwithconstant ;V;T : 0= dE TdS dN (11.20) dS ( ;V;T )= 1 T ( dE dN )(11.21) Uponintegrating,thedierenceequationfortheentropyis found: i +1 ;j +1 Z i;j dS = 1 T 0@ i +1 ;j +1 Z i;j dE i +1 ;j +1 Z i;j dN 1A (11.22) S i +1 ;j +1 S i;j = 1 T [ E i +1 E i ( N j +1 N j )](11.23) Theratioofmicrostatesthenbecomes: 125

PAGE 140

n( N j ;E i ) n( N j +1 ;E i +1 ) = e 1 k ( S i +1 ;j +1 S i;j ) = e 1 kT ( E i +1 E i N j +1 + N j ) = e E i +1 e N j +1 e E i e N j (11.24) Again,havingachievedanexpressionwherethenumeratoran ddenominator areofthesamefunctionalformandarethusnormalizedwithr especttoboth N j and E i tondtheprobability: Pr ( N j ;E i )= e N j e E i 1 P N j =1 e N j P i e E i = e N j e E i (11.25) wherethenormalizationfactoristhe grandcanonicalpartitionfunction .Itmay benotedthatinthiscasetheconstraintofconstant N wasmerelyrelaxed,Legendre transformedtothecorrespondingmacrostate,andtheparti tionfunctionthenfollowed quitenaturallyandsimply.11.5Isothermal-IsobaricPartitionFunctionHavingsuccessfullyderivedthegrandcanonicalpartition functionbyrelaxingthe constant N constraint,itcannowbeshownthattheisothermal-isobari censembleis generatedbystartingwithconstant NVT andrelaxingtheconditionofconstant V Considerthenumberofsubsystemswithbothvolume V i andenergy E j : 126

PAGE 141

Figure11.2:Gibbsconstructionforthegrandcanonicalens emble. hasbeenLegendretransformedtoreplace N asthemacroscopicconstant,andsothesetofsubsystemsincludesthoseofdiering N values. n( V j ;E i ) n( V j +1 ;E i +1 ) = e 1 k ( S i +1 ;j +1 S i;j ) (11.26) Legendretransformingourdesiredvariablestoanewcharac teristicfunction J andthenapplyingtheconditionofequilibrium dJ =0andourconstantdierential terms: J = A V @A @V = A + PV (11.27) dJ = dA + PdV + VdP =0 = dE TdS SdT + PdV + VdP (11.28) dS = 1 T ( dE + PdV )(11.29) andsotheratioofobservablesubsystemsbecomes: 127

PAGE 142

n( V j ;E i ) n( V j +1 ;E i +1 ) = e 1 k ( S i +1 ;j +1 S i;j ) = e 1 kT [ E i +1 E i + P ( V i +1 V i )] = e E i +1 e PV j +1 e E i e PV j (11.30) Uponnormalizing,theprobabilitiesare: Pr ( V j ;E i )= e E i e PV j (11.31) wherethenormalizationfactor, = X j e PV j X i e E i (11.32) isthe isothermal-isobaricpartitionfunction 11.6ConnectionwithGeneralizedEnsembleTheoryBasedontheprevioussections,itmaybenotedthatifaparti tionfunctionfor any macrostateinthermalequilibriumistobederived,oneshal l always arriveatan expressionthatinvolvesanexponentialfunction;thisfol lowsasaconsequenceof theBoltzmannLaw.Furthermore,thepartitionfunctionbei ngthenormalization factortoexpressthisasaprobabilitymeansthatonewillal wayshaveadiscrete sum.Therefore,ourpartitionfunctionswillalwaysbesome variationonatheme amountingtoa\sumofexponentials". Inthecontinuumlimit,itcanbeshownthatthecanonicalpar titionfunction 128

PAGE 143

Figure11.3:Gibbsconstructionfortheisothermal-isobar icensemble. P hasbeen Legendretransformedtoreplace V asthemacroscopicconstant,andsothesetof subsystemsincludesthoseofdiering V values. Q (writtenasasumoverenergylevels)transformsas: Q ( N;V; )= X i e E i n( E i ) Z 1 0 dEe E n( N;V;E )(11.33) or,inotherwords,thecanonicalpartitionfunctionistheL aplacetransformofthe microcanonicalpartitionfunctionn. Howdoesitworktheotherway?Let'sapplytheinverseLaplac etransform to Q : 129

PAGE 144

n( N;V;E )= 1 2 i I de E Q ( N;V; ) = 1 Z 1 d n 1 2 i r + i 1 Z r i 1 de ( E H ) (11.34) wherethephasespacedierentialform d n=( h 3 N N !) 1 dx 1 :::dx 3 N dp 1 :::dp 3 N .Now, = + i andbecausenosingularityispresentintheright-halfofth ecomplex plane,thecontourmaybetakenverticallythrough r =0.SinceRe( )=0alongthe integration,thesubstitution = i canbemade: n( N;V;E )= 1 Z 1 d n 1 2 1 Z 1 de i ( E H ) = 1 Z 1 d n ( E H )(11.35) whereindeedEquation11.35canbeidentiedasthemicrocan onicalpartitionfunction.Thus,anyconstantenergyshellensemblemaybeLaplac etransformedtoan ensembleofanewintensivevariable.Asthepartitionfunct ionsarerelatedtoone anotherthroughtheLaplacetransform,thisisisomorphict othethermodynamicpotentials(toeachofwhichmaybeassociatedaparticularpar titionfunction)being relatedthroughtheLegendretransform.[204] Thequantumharmonicoscillatorisanillustrativeexample ofhowthecanonicalpartitionfunctionmaybetransformedtothemicrocano nicalcase: 130

PAGE 145

n HO = 1 2 i I de E Q HO = 1 2 1 Z 1 de iE e 1 2 i ~ 1 e i ~ = 1 2 1 Z 1 de i ( E 1 2 ~ ) X n e i ~ !n = X n E ~ n + 1 2 (11.36) Thereasonthattheaforementioned\recipe"forgenerating thepartitionfunction(asoutlinedinSections11.3,11.4and11.5)inanarbit raryensembleworksisdue tothethermodynamicrelationsandtheBoltzmannlaw.Theun derlyingmathematicalstructurethatallowsthishasalsobeenpreviouslyfor mulatedasgeneralized ensembletheory.[199{201,210,211]11.7ConclusionsWe'vepresentedanapproachtowardderivingthepartitionf unctionthatisanalternativetothestandardderivationprovidedbymosttextbook s.ThisapproachemphasizesthecentralrolethattheBoltzmannentropyplaysinco nnectingthemolecular statesofthesystemtotheobservablethermodynamics.Itha sbeenshownhow thiscanbeausefultechniquetoeasilyderiveexpressionsf orthepartitionfunction, evenforthelesscommonensembles.Finally,thesimilariti esbetweenthederivation methoddemonstratedandtherelationsknownfromgeneraliz edensembletheoryhave beennoted.Itisourhopethattheformulaicapproachpresen tedherewillbeofutility 131

PAGE 146

inbothresearchandpedagogy. 132

PAGE 147

Chapter12 VolumeDeterminationofGlobularProteinsbyMolecularDyn amics 12.1IntroductionExperimentaltechniquesfordeterminingthepartialspeci cvolumeandpartialspecicadiabaticcompressibilityofproteinsinsolutionhav eprovidedkeyinsightinto structuralandcatalyticevents.Theapplicationofthesem ethodshasresultedina broadbaseofknowledgeaboutsolvationeects,ligandbind inganddissociation,the inruenceofproteindomainsoncatalyticevents,andprotei nfoldingpathways. Theoreticalmethodsoerthepotentialtolinkspeciceven tstothethermodynamicobservablesthatexperimentalistsmeasureinthec ourseoftheirresearch. Inparticular,moleculardynamics(MD)canprovideapowerf ulapproachtocorrelatingthemoleculartrajectoriesofproteinsthatmaygive risetoanexperimentally measuredmolecularvolumeorchangethereof. Thestate-of-the-artmethodtodatefordeterminingtheapp arentvolumeof aproteinisthemethodof\accessiblesurfacearea,[212]am ethodthatemploys aspherically-accessiblesurfaceintegrationoftheprote inscrystalstructure.This methodisattractiveinthatitisnotcomputationallydeman ding(andisthusac133

PAGE 148

cessibletothetypicalcomputationalequipmentofanexper imentallab),howeverit calculatesvolumesthatcanbesignicantlydierentfromt hosemeasuredinsolution. Priorresearchonthevolumeofsmallmoleculeshasbeenperf ormedbyour group[213,214]andthemethodologypresentedhereisanapp licationofthosetechniquestoproteinsystems.Thisworkdemonstratesthevalid ityoftheMDapproach towarddeterminingtheapparentmolecularvolumeofglobul arproteins. Figure12.1:Aperiodiccellcontaininghorse-heartmyoglo binsolvatedwith10,796 waters,incomparisonwithasystemcontainingonlythebulk TIP3Pwater.ThedifferenceinthevolumebetweeneachcellunderNPTdynamicsre sultsintheapparent molecularvolumeofthemyoglobin.12.2MethodsTheapparentmolecularvolumeofaproteiniscalculatedas: V p = V p + w V w (12.1) 134

PAGE 149

TheNAMDmoleculardynamicspackageusesaLangevin-Hoover hybridmethod whereapistoniscoupledtotheequationsofmotionforapart icleintheisothermalisobaricensemble. Asimulatedannealingalgorithmwasimplementedtoperform aglobalenergy minimization.Thesystemisbroughttoahigherenergystate andallowedtorandomly walkthroughthephasespaceforaholdtimebeforebeingbrou ghtbackdowntothe initialenergystate. Post-simulationanalysisconsistedofcalculatingthecor relationtimeofthe volumesignalusingablock-averagingmethodinordertocal culateanunbiasederror inthevolume,aswellasstructuralanalysisoftheequilibr iumstructures(RMSD, Ramachandranplots)versustheircrystalstructures.12.3ResultsandDiscussionTheapparentmolecularvolumesofwild-typemyoglobinanda spartateaminotransferase(AspAT)werecalculatedandcomparedwithexperimen talvalues. 12.3.1Horse-heartmyoglobinPreparatorysimulationstages(NAMD[215])consistedofco nstructingthesolvated proteinsystemandlocalenergyminimization,followedbyh eatingandequilibration steps.Initialmyoglobinstructuralcoordinateswereobta inedfromtheRCSBproteindatabank(crystalstructureentry1DWR4),solvatedwi th10,796TIP3Pwater moleculesandthenminimizedbythemethodofconjugategrad ients.Thesystemwas thenheatedto300Koveraperiodof1.2ns,followedbyequili brationintheNPT 135

PAGE 150

ensemblefor0.2ns. AproductionNPT(300K/1atm/2.0fstimestep)runof10.0nsr esultedinan averagevolumefortheprotein-watersystemof341,875 A 3 ;simulatingthebulkwater aloneoveratrajectoryofequaltimedurationyieldedanave ragesystemvolumeof 319,775 A 3 .Thedierenceofthesevaluesgivesanapparentmolecularv olumeof wild-typemyoglobincorrespondingto22,100 A 3 0.747cm 3 /g.Thecorrelation timesofbothvolumesignalsweredeterminedbyblock-avera gingandthesignals werethenuncorrelatedtoprovideanunbiasedvolumeerroro f 0.001cm 3 /g.This computationallydeterminedapparentvolumeof0.747 0.001cm 3 /gagreesprecisely withexperimentallyreportedsoundvelocitymeasurements [216]andiswithinthe experimentalerrorofthatstudy.Theequilibriumproteins tructureinsolutionwas alignedandcomparedwiththecrystalstructureofmyoglobi nandwhiletheoverall RMSDwasminimal,alocalregionofaminoacidsnearGLY80was foundtobe displacedby6.0.12.3.2AspartateaminotransferaseThehalozymeofE.coliaspartateaminotransferase(RCSBen try1ASM),[217,218] alargedimerconsistingofidentical404aminoacidsubunit scompletewithLYS258boundpyridoxal-5-phosphatecofactors,wassimulatedint heNPTensemblewith 58,361watermolecules.Anaverageapparentvolumeof0.733 cm 3 /gwascalculated attheendofa0.5nsrun,aresultthatisingoodagreementwit htheexperimentally measuredvalueof0.731cm 3 /g.Workisinprogresstoobtainalongertimescale trajectoryandcalculatetheassociatedvolumetricerror. 136

PAGE 151

Figure12.2:Volumesignalsforthesolvatedmyoglobinsyst emvs.thebulkwater. Afterinitialequilibrationthevolumesructuateaboutthe iraveragevaluesforthe10 nstrajectorythedierenceofwhichgivesanapparentmolec ularvolumeof0.747 cm 3 /g. 137

PAGE 152

Asingle-pointmutation(VAL39toGLY)hasbeenexperimenta llyshownto inducealargeconformationalchangeinthedimer[219]anda nassociatedchangein theapparentvolumeby-0.035cm 3 /goneofthelargestmolecularvolumechanges observedduetoasingleresiduemutation. SincethecrystallographicstructureoftheV39Gmutanthas notyetbeenelucidated,manualalterationoftheVAL39sidechainofthe1AS Mcrystalstructurewas performedtogivetheV39Ginitialconguration.Asimulate dannealingalgorithm wasdevelopedandperformedonthemutanttohelpfacilitate theadoptionofitsnew equilibriumconformationpriortoperformingproductionN PTruns. Figure12.3:VanderWaalsrepresentationshowingthesteri ceectsofthevaline (V39),tyrosine(Y70onthesecondsubunitofthedimer)andi soleucine(I37)residues ofinterestfortheV39Gmutantactivesite.Substitutionof thevalineforaglycine reducesthestericinteractionsleadingtoalargescalecon formationalchangeaswell asadrasticchangeincatalyticactivity.Thesametriadcan beseeninthedistance totheleftontheoppositesideofthedimer. 138

PAGE 153

12.4ConclusionsTheapplicationofmoleculardynamicsforstudyingthevolu meofglobularproteins canaccuratelymodelexperimentaldata.Themethodspresen tedcanoerinsight intostructuralproteinstudiessinceconformationalchan gescanbeexaminedand correlatedwithexperimentallyobservedvolumechangesin solution.Thevolumetric contributionofvariousregionsofaprotein(includingthe moredicultcaseofa single-pointmutation)canbeelucidatedthroughuseofthi spracticalandconsistent methodology. 139

PAGE 154

Chapter13 MassivelyParallelMonteCarlo(MPMC) AstatisticalmechanicssimulationcodenamedMPMC( M assively P arallel M onte C arlo)hasbeendevelopedtoperformsimulationsoftheruid/ materialinterface.The vastmajorityofcalculationsthatthiscodebaseprovidesc anbetriviallyparallelized, andsoit'smassivelyparallelnatureisrerectedinthename .Thesourcecodeofthis simulationpackageislistedinAppendixL. Thecanonical,grandcanonicalandmicrocanonicalensembl eMonteCarlo schemescanbeperformedthroughkeywordspecicationinth einputle.Cavitybiasingschemes(bothgrid-basedanddistancebased)havebee nfoundusefulinGCMC simulationsofdensesystems.Theequationofstateforhydr ogen(formappingthe appliedpressuretothechemicalpotentialusedinGCMC)has beenincludedfora widerangeofconditions. Avarietyofpotentialenergyfunctionshavebeenimplement ed,including Lennard-JonesandSilvera-Goldman.Long-rangeelectrost aticsarecalculatingusingtheEwaldsummationmethod.Morseandharmonicbondpote ntialsareincluded forspecicvibrationalsurfacecalculations.Many-bodyp olarizationofthepointin140

PAGE 155

duceddipoletypecanbeenabledandthepolarizationenergy calculatedbasedupon theinduceddipolecontributiontotheelectrostaticeld. Avarietyofadvancediterativemethodsforsolvingtheself-consistenteldequatio ns,asoutlinedinChapter 8,areemployedtoaccelerateconvengenceoftheinducedel d. Quantumructuationsmaybeincludedinsimulationthroughb othniteTrotterPathIntegralMonteCarlo.Inaddition,alloftheabovep otentialshaveFeynmanHibbseectivepotentialanaloguestoquarticorderthatma ybeactivated.Themore advancediterativeschemeofFeynmanandKleinerthasalsob eenimplemented. Rotationalexcitedstatesarecalculatedbydirectdiagona lizationofthehamiltonianforadiatomicrotorsubjecttoanexternaleld.Inte grationisperformedover aGauss-Lengdrequadraturegrid,andthenthehamiltonian( inasphericalharmonic basis)isdiagonalizedusingtheLAPACKlinearalgebrapack age.Theinversionsymmetryoperatorisactedontheresultingeigenvectorsinord ertodeterminewhether thequantumstatesaresymmetricorantisymmetric.Havingd eterminedthesymmetryoftherotationalwavefunctions,Boltzmannfactorsfor distinctnuclearspinstates maybeincludedintheMonteCarloMetropolisfunction. 141

PAGE 156

References [1]JereyR.Long,A.PaulAlivisatos,MarvinL.Cohen,Jean M.J.Frechet,MartinHead-Gordon,StevenG.Louie,AlexZettl,ThomasJ.Rich ardson,Samuel S.Mao,CaroleReadandJimAlkire,ASynergisticApproachto theDevelopmentofNewClassesofHydrogenStorageMaterials,FY2005Pr ogressReport, DOEHydrogenProgram,2005. [2]J.L.Belof,A.C.Stern,andB.Space,J.Phys.Chem.C. 113 ,9316(2009). [3]S.K.BhatiaandA.L.Myers,Langmuir 22 ,1688(2006). [4]J.L.Belof,A.C.Stern,M.Eddaoudi,andB.Space,J.Am.C hem.Soc. 129 15202(2007). [5]J.L.Belof,A.C.Stern,andB.Space,J.Chem.TheoryComp ut. 4 ,1332 (2008). [6]R.FeynmanandA.Hibbs, QuantumMechanicsandPathIntegrals (McGrawHill,NewYork,1965),"Chapt.10,Sect.3,pg.281". [7]M.Creutz,Phys.Rev.Lett. 50 ,1411(1983). [8]J.R.Ray,Phys.Rev.A 44 ,4061(1991). 142

PAGE 157

[9]R.C.Weast, CRCHandbookofChemistryandPhysics (CRCPress,Inc.,West PalmBeach,1994). [10]J.L.RowsellandO.M.Yaghi,Angew.Chem.Int.Ed. 44 ,4670(2005). [11]A.M.SeayadandD.M.Antonelli,Adv.Mater. 16 ,765(2004). [12]V.Berube,G.Radtke,M.Dresselhaus,andG.Chen,Int.J .EnergyResearch 6-7 ,637(2007). [13]E.David,J.Mater.Process.Technol. 162 ,169(2005). [14]E.Fakioglu,Y.Yurum,andT.Veziroglu,Int.J.Hydroge nEnergy 13 ,1371 (2004). [15]A.SeayadandD.Antonelli,Adv.Mater. 9-10 ,765(2004). [16]G.Garberoglio,A.I.Skoulidas,andJ.K.Johnson,J.Ph ys.Chem.B 109 13094(2005). [17]J.Eckert,Spectrochim.Acta 48A ,363(1992). [18]C.-R.Anderson,D.F.Coker,J.Eckert,andA.L.R.Bug,J .Chem.Phys. 111 7599(1999). [19]Y.Liu etal. ,Angew.Chem.Int.Ed. 46 ,3278(2007). [20]N.L.Rosi etal. ,Science 300 ,1127(2003). [21]B.MoultonandM.J.Zaworotko,Chem.Rev. 101 ,1629(2001). 143

PAGE 158

[22]M.O'KeeeandO.M.Yaghi,seethewebsite:http://rcsr .anu.edu.au/,2003. [23]O.Delgado-Friedrichs,M.O'Keee,andO.M.Yaghi,Act acrystallographica A62 ,350(2006). [24]R.Haber,B.Lucas,andN.Collins,Proc.IEEEVis. 1 ,298(1991). [25]B.Lucas etal. ,Proc.IEEEVis. 92 ,107(1992). [26]G.AbramandL.Treinish,Proc.IEEEComp.Soc. 95 ,263(1995). [27]J.Applequist,J.R.Carl,andK.-K.Fung,J.Am.Chem.So c. 94 ,2952(1972). [28]B.Thole,Chem.Phys. 59 ,341(1981). [29]P.T.vanDuijenandM.Swart,J.Phys.Chem.A 102 ,2399(1998). [30]A.Perry,C.Neipert,P.Moore,andB.Space,Chem.Rev. 106 ,1234(2006). [31]F.Mulder,T.Dingemans,M.Wagemaker,andG.Kearley,C hem.Phys. 317 113(2005). [32]Q.WangandJ.K.Johnson,J.Phys.Chem.B 103 ,4809(1999). [33]G.E.Froudakis,J.Phys.Condens.Matter 14 ,R453(2002). [34]P.DemontisandG.B.Suritti,Chem.Rev. 97 ,2845(1997). [35]T.Sagara,J.Klassen,andE.Ganz,J.Chem.Phys. 121 ,12543(2004). [36]J.A.MacKinnon,J.Eckert,D.F.Coker,andA.L.Bug,J.C hem.Phys. 114 10137(2001). 144

PAGE 159

[37]A.LarinandE.CohenDeLara,J.Chem.Phys. 101 ,8130(1994). [38]D.F.Coker,D.Thirumalai,andB.J.Berne,J.Chem.Phys 86 ,5689(1987). [39]D.F.CokerandB.J.Berne,J.Chem.Phys. 89 ,2128(1988). [40]F.DarkrimandD.Levesque,J.Chem.Phys. 109 ,4981(1998). [41]K.Shirono,A.Endo,andH.Daiguji,J.Phys.Chem.B 109 ,3446(2005). [42]Q.Fu etal. ,Phys.Rev.B 65 ,0753181(2002). [43]Q.Sun,Q.Wang,P.Jena,andY.Kawazoe,J.Am.Chem.Soc. 127 ,14582 (2005). [44]T.Kawakami etal. ,Polyhedron 20 ,1197(2001). [45]T.MuellerandG.Cedar,J.Phys.Chem.B 109 ,17974(2005). [46]Q.WangandJ.K.Johnson,J.Chem.Phys. 110 ,577(1999). [47]V.V.Simonyan,P.Diep,andJ.K.Johnson,J.Chem.Phys. 111 ,9778(1999). [48]Q.WangandJ.K.Johnson,J.Phys.Chem.B 103 ,277(1999). [49]S.M.LeeandY.H.Lee,App.Phys.Lett. 76 ,2877(2000). [50]F.L.Darkrim,P.Makbrunot,andG.P.Tartaglia,Int.J. HydrogenEnergy 27 ,193(2002). [51]L.SchlapbachandA.Zuttel,Nature 414 ,353(2001). [52]S.-H.Jhi,Micro.Meso.Materials 89 ,138(2006). 145

PAGE 160

[53]D.-Y.HwangandA.M.Mebel,Chem.Phys.Lett. 321 ,95(2000). [54]Q.YangandC.Zhong,Phys.Chem.B 110 ,655(2006). [55]R.A.ZidanandR.E.Rocheleau,J.Mater.Res. 14 ,286(1999). [56]S.Bordiga etal. ,J.Phys.Chem.B 109 ,18237(2005). [57]T.Duren,L.Sarkisov,O.M.Yaghi,andR.Q.Snurr,Langm uir 20 ,2683(2004). [58]M.P.AllenandD.J.Tildesley, ComputerSimulationofLiquids (Clarendon Press,Oxford,1989). [59]D.FrenkelandB.Smit, UnderstandingMolecularSimulation:FromAlgorithms toApplications (AcademicPress,NewYork,2002). [60]A.Rappe etal. ,J.Am.Chem.Soc. 114 ,10024(1992). [61]M.W.Schmidt,K.K.Baldridge,J.A.Boatz,S.T.Elbert, M.S.Gordon,J.J. Jensen,S.Koseki,N.Matsunaga,K.A.Nguyen,S.Su,T.L.Win dus,M.Dupuis andJ.A.Montgomery,J.Comput.Chem. 14 ,1347(1993). [62]U.SinghandP.Kollman,J.Comput.Chem. 5 ,129(1984). [63]W.J.Stevens,H.Basch,andM.Krauss,J.Chem.Phys. 81 ,6026(1984). [64]L.A.LaJohn etal. ,J.Chem.Phys. 87 ,2812(1987). [65]P.J.HayandW.R.Wadt,J.Chem.Phys. 82 ,270(1985). [66]W.D.Cornell etal. ,J.Am.Chem.Soc. 117 ,5179(1995). 146

PAGE 161

[67]T.Tsuchiya,M.Abe,T.Nakajima,andK.Hirao,J.Chem.P hys. 115 ,4463 (2001). [68]R.DeVane etal. ,J.Chem.Phys. 121 ,3688(2004). [69]J.ApplequistandC.O.Quicksall,J.Chem.Phys. 66 ,3455(1977). [70]P.RenandJ.W.Ponder,J.Phys.Chem.B 107 ,5933(2003). [71]S.S.X.ChristianJ.Burnham,JichenLiandM.Leslie,J. Chem.Phys. 110 4566(1999). [72]M.SouailleandJ.C.Smith,Mol.Phys. 87 ,1333(1996). [73]D.N.Bernardo,Y.Ding,K.Krogh-Jespersen,andR.M.Le vy,J.Phys.Chem. 98 ,4180(1994). [74]P.RenandJ.W.Ponder,J.Comput.Chem. 23 ,1497(2002). [75]K.A.BodeandJ.Applequist,J.Phys.Chem. 100 ,17825(1996). [76]M.Griebel etal. DiscretizationMethodsandIterativeSolversBasedonDomainDecomposition,LectureNotesinComputationalScienc eandEngineering (Springer,Berlin,2001). [77]T.DinhandG.A.Huber,J.Math.ModellingandAlgorithm s 4 ,111(2005). [78]T.H.Dunning,Jr.,J.Chem.Phys. 90 ,1007(1989). [79]N.C.C.ComparisonandN.S.R.D.N..BenchmarkDatabase http://srdata.nist.gov/cccbdb,Release12,Aug2005. 147

PAGE 162

[80]T.Guella etal. ,Phys.Rev.A 29 ,2977(1984). [81]N.Metropolis etal. ,Phys.Lett.B 21 ,1087(1953). [82]S.Duane,A.Kennedy,B.J.Pendleton,andD.Roweth,Phy s.Lett.B 195 216(1987). [83]B.Mehlig,D.Heermann,andB.Forrest,Phys.Rev.B 45 ,679(1992). [84]P.Moore,C.F.Lopez,andM.L.Klein,Biophys.J. 81 ,24842494(2001). [85]P.Moore,Q.Zhong,T.Husslein,andM.L.Klein,FEBSLet t. 431 ,143148 (1998). [86]Q.Zhong,P.B.Moore,andM.L.Klein,FEBSLett. 427 ,267274(1998). [87]M.Tarek,K.Tu,M.L.Klein,andD.J.Tobias,Biophys.J. 77 ,964972(1999). [88]S.Wolfram,Rev.Mod.Phys. 55 ,601(1983). [89]S.Wolfram, ANewKindofScience (WolframMedia,Champaign,IL,2002). [90]A.M.Horowitz,Phys.Lett.B 268 ,247(1991). [91]E.AkhmatskayaandS.Reich,LectureNotesinComputati onalScienceand Engineering 49 ,141(2005). [92]M.Dinca etal. ,J.Am.Chem.Soc. 128 ,16876(2006). [93]A.Meyers,AmericanInstituteofChemicalEngineers 48 ,145(2002). [94]A.L.MeyersandF.Siperstein,ColloidsandSurfacesA 187-188 ,73(2001). 148

PAGE 163

[95]B.Widom,J.Chem.Phys. 39 ,2808(1963). [96]B.Widom,J.Phys.Chem. 86 ,869(1982). [97]V.BhethanabotlaandW.Steele,J.Phys.Chem. 92 ,3285(1988). [98]J.VanKranendonk, SolidHydrogen:TheoryofthePropertiesofSolid H 2 HD and D 2 ,2nded.(PlenumPress,NewYork,1983),p.45. [99]G.Garberoglio,A.I.Skoulidas,andJ.K.Johnson,J.Ph ys.Chem.B 109 13094(2005). [100]J.Belof,A.Stern,M.Eddaoudi,andB.Space,J.Am.Che m.Soc. 129 ,15202 (2007). [101]J.SchaeferandR.Watts,Mol.Phys. 47 ,933(1982). [102]H.KnaapandJ.Beenakker,Physica 27 ,523(1961). [103]V.Buch,J.Chem.Phys. 100 ,7610(1994). [104]I.F.SilveraandV.V.Goldman,J.Chem.Phys. 69 ,4209(1978). [105]P.DiepandJ.K.Johnson,J.Chem.Phys. 112 ,4465(2000). [106]P.DiepandJ.K.Johnson,J.Chem.Phys. 113 ,3480(2000). [107]G.Gallup,Mol.Phys. 33 ,943(1977). [108]R.Etters,R.Danilowicz,andW.England,Phys.Rev.A 12 ,2199(1975). [109]P.WindandI.Reggen,Chem.Phys. 211 ,179(1996). 149

PAGE 164

[110]F.Mulder,A.vanderAvoird,andP.Wormer,Mol.Phys. 37 ,157(1979). [111]F.DarkrimandD.Levesque,J.Chem.Phys. 109 ,4981(1998). [112]Z.ZhangandZ.Duan,J.Chem.Phys. 122 ,214507(2005). [113]M.K.Kostov etal. ,Chem.Phys.Lett. 332 ,26(2000). [114]B.AxilrodandE.Teller,J.Chem.Phys. 11 ,299(1943). [115]Y.Liu etal. ,Angew.Chem.Int.Ed. 46 ,1433(2007). [116]D.Hartree,Proc.Camb.Phil.Soc. 24 ,89(1928). [117]V.Fock,ZeitschriftfurPhysikA 62 ,795(1930). [118]J.Slater,Phys.Rev. 42 ,33(1932). [119]J.Slater,Phys.Rev. 81 ,385(1950). [120]C.Roothaan,Rev.Mod.Phys. 23 ,69(1951). [121]R.D.J.III,NISTComputationalChemistryComparison andBenchmarkDatabase:NISTStandardReferenceDatabaseNumber101 http://srdata.nist.gov/cccbdb,Release14,Sept2006. [122]G.Herzberg, MolecularSpectraandMolecularStructure,SecondEdition (KriegerPublishingCo.,Malabar,FL,1989),"Vol.I,p.532 ". [123]A.V.Nemukhin,B.L.Grigorenko,andA.A.Granovsky,M oscowUniversity ChemistryBulletin 45 ,75(2004). 150

PAGE 165

[124]C.MllerandM.S.Plesset,Phys.Rev. 46 ,618(1934). [125]J.BinkleyandJ.Pople,Int.J.Quant.Chem. 9 ,229(1975). [126]R.KrishnanandJ.Pople,Int.J.Quant.Chem. 14 ,91(1978). [127]R.KrishnanandJ.Pople,J.Chem.Phys. 72 ,4244(1980). [128]J.T.H.Dunning,J.Chem.Phys. 90 ,1007(1989). [129]T.Helgaker,W.Klopper,H.Koch,andJ.Noga,J.Chem.P hys. 106 ,9639 (1997). [130]S.BoysandF.Bernardi,Mol.Phys. 19 ,553(1970). [131]J.PollandL.Wolniewicz,J.Chem.Phys. 68 ,3053(1978). [132]S.KarnaandM.Dupuis,J.Comp.Chem. 12 ,487(1991). [133]D.R.Lide, HandbookofChemistryandPhysics (CRCPress,Inc.,BocaRaton, FL,2003). [134]W.KolosandL.Wolniewicz,J.Chem.Phys. 46 ,1426(1967). [135]K.A.BodeandJ.Applequist,J.Phys.Chem. 100 ,17820(1996). [136]B.Thole,Chem.Phys. 59 ,341(1981). [137]P.T.vanDuijnenandM.Swart,J.Phys.Chem.A 102 ,2399(1998). [138]M.Brack,R.Bhaduri,andR.K.Bhaduri, SemiclassicalPhysics (Westview Press,Boulder,CO,2003),"Chapt.4,Sect.2,pg.148". 151

PAGE 166

[139]N.Metropolis etal. ,Phys.Lett.B 21 ,1087(1953). [140]D.FrenkelandB.Smit, UnderstandingMolecularSimulation:FromAlgorithms toApplications (AcademicPress,NewYork,2002),"Chapt.5,Sect.6.1,p.12 9". [141]H.ShawandD.Wones,Amer.J.Sci. 262 ,918(1964). [142]L.ZhouandY.Zhou,Int.J.HydrogenEnergy 26 ,597(2001). [143]E.Lemmon,M.McLinden,andD.Friend,in NISTChemistryWebBook ,edited byP.LinstromandW.Mallard(NationalInstituteofStandar dsandTechnology,Gaithersburg,MD,2005),Vol.69,http://webbook.nis t.gov. [144]B.Younglove,J.Phys.Chem.Ref.Data 11 ,1(1982). [145]M.H.Alkordi etal. ,J.Am.Chem.Soc. 130 ,12639(2008). [146]J.EckertandG.J.Kubas,J.Phys.Chem. 97 ,2378(1993). [147]E.Hao,G.Schatz,R.Johnson,andJ.Hupp,J.Chem.Phys 117 ,5961(2006). [148]J.A.GreathouseandM.D.Allendorf,J.Phys.Chem.C 112 ,5795(2008). [149]T.Boublk,FluidPhaseEquil. 240 ,96(2005). [150]B.J.Alder,D.A.Young,andM.A.Mark,J.Chem.Phys. 56 ,3013(1972). [151]D.NicholsonandN.G.Parsonage, ComputerSimulationandtheStatistical MechanicsofAdsorption (AcademicPress,London,1982),"Chapt.3,Sect.4, pg.97". 152

PAGE 167

[152]S.S.KayeandJ.R.Long,unpublishedresults.[153]S.S.Kaye,A.Dailly,O.M.Yaghi,andJ.R.Long,J.Am.C hem.Soc.Comm. 129 ,14176(2007). [154]W.Zhou,H.Wu,M.R.Hartman,andT.Yildirim,J.Phys.C hem.C 111 16131(2007). [155]B.Schmitz etal. ,Chem.Phys.Chem. 9 ,2181(2008). [156]G.K.Platt,SpaceVehicleLowGravityFluidMechanics Problemsandthe FeasibilityoftheirExperimentalInvestigation,NASATec hnicalMemorandum, TMX-53589,1967. [157]A.A.Sheuinina,N.G.Bereznyak,V.P.Vorob'eva,andM .A.Khadzhmuradov, LowTemp.Phys. 19 ,356(1993). [158]E.S.Yakub,Int.J.Thermophys. 22 ,505(2001). [159]R.D.McCarty,HydrogenTechnologicalSurvey-Thermo physicalProperties, NASASP-3089,p.518-519,1975. [160]Y.Liu,V.C.Kravtsov,R.W.Larsen,andM.Eddaoudi,Ch em.Commun. 14 1488(2006). [161]S.Bradamante,A.Facchetti,andG.Pagani,J.Phys.Or g.Chem. 10 ,514 (1997). [162]I.IsakssonandJ.Sandstrom,ActaChim.Scand. 27 ,1183(1973). 153

PAGE 168

[163]D.ChemlaandJ.Zyss, Non-LinearOpticalPropertiesofOrganicMolecules andCrystalsVol.1and2 (AcademicPress,NewYork,1986). [164]L.Cheng etal. ,J.Phys.Chem. 95 ,10631(1991). [165]J.Oudar,J.Chem.Phys. 67 ,446(1977). [166]P.PrasadandD.Williams, Introductiontononlinearopticaleectsinmolecules andpolymers. (JohnWiley,NewYork,1994). [167]J.QuennevilleandT.Martinez,J.Phys.Chem. 107 ,829(2003). [168]J.Zarembowitch etal. ,Mol.Cryst.Liq.Cryst. 234 ,247(1993). [169]S.Decurtis etal. ,Chem.Phys.Lett. 105 ,1(1984). [170]M.Boillot etal. ,J.Inorg.Chem. 35 ,3975(1996). [171]A.Sour,M.Boillet,E.Riviere,andP.Lesot,Eur.J.In org.Chem.2117(1999). [172]M.Boillot,S.Chantraine,J.Z.J.Lallemand,andJ.Pr unet,NewJ.Chem. 179(1999). [173]C.Faulmann etal. ,Eur.J.Inorg.Chem.3261(2005). [174]M.W.Schmidt etal. ,J.Comput.Chem 14 ,1347(1993). [175]C.R.CreccaandA.E.Roitberg,J.Phys.Chem. 110 ,8188(2006). [176]A.Cembran etal. ,J.Am.Chem.Soc. 126 ,3234(2004). [177]M.L.Tiago,S.Ismail-Beigi,andS.G.Louie,J.Chem.P hys. 122 ,94311(2005). 154

PAGE 169

[178]A.D.Becke,J.Chem.Phys. 98 ,5648(1993). [179]P.Stephens,F.Devlin,C.Chabalowski,andM.Frisch, J.Phys.Chem. 98 11623(1994). [180]R.HertwigandW.Koch,Chem.Phys.Lett. 268 ,345(1997). [181]R.Semiat etal. ,Chem.Phys.Lett. 255 ,327(1996). [182]P.J.HayandW.R.Wadt,J.Chem.Phys. 82 ,270(1985). [183]R.W.Larsen,J.Am.Chem.Soc. 130 ,11246(2008). [184]S.KristyanandP.Pulay,Chem.Phys.Lett. 229 ,175(1994). [185]F.Weigend,M.Haser,H.Patzelt,andR.Ahrichs,Chem. Phys.Lett. 294 ,143 (1998). [186]F.Weigend,A.Kohn,andC.Hattig,J.Chem.Phys. 116 ,3175(2002). [187]B.etal.,NWChem,AComputationalChemistryPackagef orParallelComputers,Version5.1,PacicNorthwestNationalLaboratory,20 07. [188]R.A.K.etal.,ComputerPhys.Comm. 128 ,260(2000). [189]K.PalmoandS.Krimm,Chem.Phys.Lett. 395 ,133(2004). [190]H.Yu,T.Hansson,andW.F.vanGunsteren,J.Chem.Phys 118 ,221(2003). [191]D.A.McQuarrie, StatisticalMechanics (UniversityScienceBooks,Sausalito, CA,2000). 155

PAGE 170

[192]R.Curl,H.P.Hopkins,andK.Pitzer,J.Chem.Phys. 48 ,4064(1968). [193]R.P.Feynman,Rev.Mod.Phys. 20 ,367(1948). [194]L.Schulman, TechniquesandApplicationsofPathIntegration (Dover,New York,2005). [195]R.FeynmanandA.Hibbs, QuantumMechanicsandPathIntegrals (McGrawHill,NewYork,1965). [196]R.FeynmanandH.Kleinert,Phys.Rev.A 34 ,5080(1986). [197]H.Kleinert,Phys.Lett.B 280 ,251(1992). [198]J.W.Lawson,Phys.Rev.E 61 ,61(2000). [199]R.A.Sack,Mol.Phys. 2 ,8(1959). [200]E.A.Guggenheim,J.Chem.Phys. 7 ,103(1939). [201]E.M.Pearson,T.Halicioglu,andW.A.Tiller,Phys.Re v.A 32 ,3030(1985). [202]F.Hioe,D.MacMillen,andE.Montroll,Phys.Rep. 43 ,305(1978). [203]R.S.Berry,S.A.Rice,andJ.Ross, PhysicalChemistry,SecondEdition (Oxford UniversityPress,NewYork,2000). [204]R.K.P.Zia,E.F.Redish,andS.R.McKay,Am.J.Phys. 77 ,614(2009). [205]J.W.Gibbs,in TheCollectedWorksofJ.WillardGibbs ,editedbyW.Longley andR.V.Name(Longmans,GreenandCo.,NewYork,1928). 156

PAGE 171

[206]K.Huang, StatisticalMechanics (JohnWileyandSons,NewYork,1963). [207]H.Eyring,D.Henderson,B.J.Stover,andE.M.Eyring, StatisticalMechanics andDynamics (JohnWileyandSons,NewYork,1964). [208]D.Chandler, IntroductiontoModernStatisticalMechanics (OxfordUniversity Press,NewYork,1987). [209]R.A.Alberty,PureAppl.Chem. 73 ,1349(2001). [210]J.HaileandH.Graben,Mol.Phys. 40 ,1433(1980). [211]J.R.Ray,H.Graben,andJ.M.Haile,J.Chem.Phys. 75 ,4076(1981). [212]T.Chalikian,M.Totrov,R.Abagyan,andK.Breslauer, J.Mol.Biol. 260 ,588 (1996). [213]R.Devane etal. ,Biophys.J. 85 ,2801(2003). [214]C.Ridley etal. ,Chem.Phys.Lett. 418 ,137(2006). [215]J.Phillips etal. ,J.Comput.Chem. 26 ,1781(2004). [216]K.Chu etal. ,Nature 403 ,921(2000). [217]K.GekkoandY.Hasegawa,Biochemistry 25 ,6563(1986). [218]K.Gekko etal. ,ProteinScience 5 ,542(1996). [219]J.Jager,M.Moser,U.Sauder,andJ.Jansonius,J.Mol. Biol. 239 ,285(1994). 157

PAGE 172

Appendices 158

PAGE 173

AppendixA.VirialEquationforthePressure Thecanonicalexpressionforthepressureis P = kT 1 Q @Q @V = kT 1 Q @ @V 1 N 3 N Z V dV 1 ::: Z V dV N e U ( r 1 ;:::;r N ) (13.1) where Z V dV i = Z L 0 dr x i Z L 0 dr y i Z L 0 dr z i (13.2) Switchingtoscaledcoordinates,wenotethefollowingtwou sefulitems: r x i = r x i V 1 = 3 (13.3) @r @V = r 3 V (13.4) Expressedinscaledcoordinates,thepressurebecomes: P = kT 1 Q @ @V 1 N 3 N V 1 = 3 Z 1 0 dr x 1 ::: V 1 = 3 Z 1 0 dr Z N e U ( r 1 ;:::; r N ) = kT 1 Q N 1 V N +1 1 N 3 N Z 1 0 dr 1 ::: Z 1 0 dr N e betaU ( r 1 ;:::; r N ) kT 1 Q 1 N 3 N V N Z 1 0 dr 1 ::: Z 1 0 dr N @U @r @r @V e betaU ( r 1 ;:::; r N ) = kT + 1 Q 1 N 3 N V N Z 1 0 dr 1 ::: Z 1 0 dr N @U @r r 3 V e U = kT + 1 3 V h r @U @r i = kT 1 3 V h ~r ~ F i (13.5) 159

PAGE 174

AppendixB.FrenkelVolumeDerivative Thepressureiscanonicallyidentiedas: P = @A @V (13.6) wheretheparticlenumber, N ,andthetemperature T areheldconstant. Thisfreeenergyderivativecanbeapproximatedbycentrald ierence: P 1 2 A ( V + V ) A ( V ) V + A ( V V ) A ( V ) V = 1 2 kT ln Q ( V + V )+ kTQ ( V ) V kT ln Q ( V V )+ kT ln Q ( V ) V = kT 2 V ln Q ( V + V ) Q ( V ) ln Q ( V V ) Q ( V ) = kT 2 V ln ( Q ( V + V ) Q ( V ) Q ( V V ) Q ( V ) ) = kT 2 V ln 8>>>><>>>>: R V + V dV 1 :::e U ( V + V ) R V dV 1 :::e U ( V ) R V V dV 1 :::e U ( V V ) R V dV 1 :::e U ( V ) 9>>>>=>>>>; (13.7)(13.8) sincewecanwrite U ( V + V )= U ( V )+ U ( V )wehave: P = kT 2 V =ln h e U (+ V ) i h e U ( V ) i V + V V N V V V N # = kT 2 V N ln V + V V V +ln h e U (+ V ) i h e U ( V ) i (13.9) 160

PAGE 175

However,wenotethattheTaylorexpansionln(1+ x )= x + O (3)andso ln V + V V V =ln 1+ V V 1 V V =ln 1+ V V ln 1 V V = 2 V V (13.10) P = NkT V + kT 2 V ln h e U (+ V ) i h e U ( V ) i (13.11) wheretheBoltzmannfactorsthatariseduetoperformingvol umechangestothe systemmaybeevaluatedbyMonteCarlo. 161

PAGE 176

AppendixC.WidomPotentialDistributionTheorem ThefollowingisaderivationofthePotentialDistribution Theoremdueto BenjaminWidom.[96]Thisresultisremarkableinthatitexp ressesthechemical potentialofthesystemasalocallyinvariantquantity, evenintheabsenceofhomogeneity Webeginbyconsideringthedensityfunctionforasystemof N molecules underconditionsofconstant V;T : ( r 1 )= N R dr 2 ::: R dr N e U ( r 1 ;:::;r N ) R dr 1 ::: R dr N e betaU ( r 1 ;:::;r N ) (13.12) Inaddition,consideraBoltzmannaverageofthequantity ( r 1 ),theenergy ofinsertinganadditionalmoleculeintoasystemof N 1molecules: h e ( r 1 ) i = R dr 2 ::: R dr N e U ( r 2 ;:::;r N ) e ( r 1 ) R dr 2 ::: R dr N e U ( r 2 ;:::;r N ) (13.13) DividingEquation13.13byEquation13.12weobtain: h e ( r 1 ) i ( r 1 ) = R dr 2 ::: R dr N e U ( r 2 ;:::;r N ) e ( r 1 ) R dr 2 ::: R dr N e U ( r 2 ;:::;r N ) N R dr 2 ::: R dr N e U ( r 1 ;:::;r N ) R dr 1 ::: R dr N e betaU ( r 1 ;:::;r N ) = 1 N Z N Z N 1 (13.14) 162

PAGE 177

NoticethatEquation13.14isaconstant.Itisinterestingt hatinaninterfacial system,wherethequantity h e ( r 1 ) i willbequitesmallinaregionofhighrepulsion, thereisanexactcancellationwiththedensityinthatregio nsuchthataconstantis obtainedinallregionsoftheinterface.Morespecically, = kT ln h e ( r 1 ) i 3 ( r 1 ) (13.15) 163

PAGE 178

AppendixD.Fugacity MakinguseoftheGibbsfreeenergy, dG = SdT + VdP + dN (13.16) andintegratingoveranadiabaticpressurechange,wearriv eat: Z 0 d = P Z P 0 VdP (13.17) Wenotethatforanidealgas: Z 0 d = P Z P 0 kT P dP = kT ln P P 0 (13.18) = 0 + kT ln P P 0 (13.19)(13.20) Ifwehavetheexperimentalmolarvolumeofanon-idealgas(a safunctionof theappliedpressure)thenwewouldhavealloftheinformati onnecessarytoobtain andthusevaluatepropertiesinthegrandcanonicalensembl e. Foranon-idealgas,wedeneacorrectiontothepressurecal ledthefugacity: = 0 + kT ln f f 0 (13.21) 164

PAGE 179

whereintheidealgaslimit f = P Wedenethefunction = P V kT P (13.22) andsotheworkequationofinterestbecomes: P Z P 0 VdP = P Z P 0 kT P + dP = kT ln P P 0 + P Z P 0 dP (13.23) kT ln f f 0 =ln P P 0 + P Z P 0 dP (13.24) = kT ln fP 0 f 0 P = P Z P 0 dP (13.25) (13.26) butwemustobtainanidealgasinthelowpressurelimit,i.e. : lim P 0 f P =1(13.27) andthiscanonlyhappenif P R P 0 dP =0 Therefore, 165

PAGE 180

= kT ln f P = P Z P 0 dP (13.28) Wedene = f P andarriveattheequationforthefugacitycoecient ln = Z P 0 P V kT P dP (13.29) 166

PAGE 181

AppendixE.IsostericHeatofAdsorption(Q st ) Weconsideraclosedsystemashavingadsorbed N a moleculesinequilibrium withagaseousphaseof N g molecules.Startingfromthefundamentalequationof thermodynamics dE = TdS PdV + dN (13.30) wecanidentifytheheatadsorbedbythesystemas dQ = TdS Theisostericheatofadsorption, Q st ,isdenedas Q st = @Q @N a (13.31) Wenotethat dN g = dN a @Q @N a = T @S @N a = T @ @N a ( S g + S a ) = T @S g @N g @S a @N a (13.32) 167

PAGE 182

Wenotethat,atequilibrium,theGibbsfreeenergyis: dG = SdT + VdP + dN =0(13.33) dN = SdT VdP (13.34) = @S @N dT @V @N dP (13.35) (13.36) Sincethegaseousandadsorbedphasesareinequilibrium, g = a .Therefore, @S g @N g dT @V g @N g dP = @S a @N a dT @V a @N a dP (13.37)(13.38) Uponarrangingfor dP=dT ,wehave: dP dT = @S g @N g @S a @N a @V g @N g @V a @N a (13.39) where,makinguseofEquation13.32,wehave: dP dT = Q st T V g V a (13.40) Ifweassumethat(a)themolarvolumeoftheadsorbedphaseis negligible ( V a =0)and(b)thatthereservoiriswithintheidealgasregime, V g = V ideal = 168

PAGE 183

kT=P ideal : dP dT = Q st T kT P ideal = P ideal Q st kT 2 (13.41) Q st = RT 2 1 P dP dT = RT 2 @ ln P @T (13.42) Asanalnote,wepointoutthattheisostericheatofadsorpt ionisdistinct fromthe adsorptionenthalpy @H @N a = RT 2 @ ln f @T (13.43) where f isthefugacityofthegasunderconsideration. 169

PAGE 184

AppendixF.autocorr.c /************************************************** **************************************/ /*Determinesthecorrelationtimeintervalforarandomseq uence*/ /* */ /*Theinputsignalisspecifiedinaninputfilewhereeachli neholdsasingle*/ /*floatingpointvalue.Thesignalvaluesareallshiftedby theaveragevaluein*/ /*orderthatthesignalmayfluctuateaboutthex-axis.Then ormalizationconstantis*/ /*thencalculatedsothattheautocorrelationfunctionwil lbenormalized.*/ /*Arandomsignalwillseearapiddecaytime,whereasasigna lwithgreater*/ /*periodicitywouldbeevidentbyjudgingdecaytimeuntilc rossingthex-axis,thus*/ /*determiningthecorrelationinterval.Thedefaultmetho distointegratethe*/ /*autocorrelationfunctiontogetthecorrelationtime-an alternativemethod*/ /*basedupontheslopeofasemilogscalecanalsobecalculat edbythe-loption*/ /*onthecommandline.Useofbothmethodsyieldsareasonabl evalueforthe*/ /*correlationtimeofthedata. */ /* */ /*Thisimplementationutilizestheautocorrelationfunct ionasfollows.Thej-thvalue*/ /*oftheautocorrelationfunction(inlatex)isgivenby:*//* */ /*ac(j)=\sum_{i=j}^{N-i}s(j)*s(i+j)*//* */ /*wheres(k)isthevalueofthesignalattimekandNisthetot alnumberofdata*/ /*pointsinthesignal.Theaverageofthissumisthentakenb ydividingby*/ /*thenumberofpointsprocessedandanormalizationconsta nt,wherethe*/ /*normalizationconstantisgivenby: */ /* */ /* \sum_i^Ns(i)^2 */ /* */ /*usage: */ /*autocorr<-l>[datfile]>output_file */ /* */ /*compilation: */ /*gcc-oautocorrautocorr.c-lm */ /* */ /*References: */ /*Ifeachor,Jervis"DigitalSignalProcessing:APractica lApproach"*/ /*Mitra,"DigitalSignalProcessing" */ /*Frenkel,"UnderstandingMolecularSimulation" */ /* */ /*@2005JonathanBelof */ /*SpaceResearchGroup */ /*DepartmentofChemistry */ /*UniversityofSouthFlorida */ /************************************************** **************************************/ #include#include#include#include#include#include#include#include#defineNUM_LINES4000000#defineTHRESHOLD0.01/*iftheacgetscloseto0withinthis amount,considera"hit"*/ #defineDECAY_POINT2/*ifthismany"hits"occurs,conside rtheacfunctiondecayed*/ intautocorr(double*dat,intnum,intlog_scale){ inti,j;/*workingindices*/doubleavg=0;/*pre-processedaverageforthesignal*/doublenorm=0;/*normalizationconstant*/doubleac=0;/*currentautocorrelationvalue*/inthits=0;/*numberoftimestheachaspassedthex-axis*/intdecayed=0;/*usedtoflagwhenacisdecayed*/doubleac_integral;/*integrationvalue*/intcorr_time=0;/*correlationtimeestimatedbyintegrat ion*/ intlog_corr_time=0;/*correlationtimeestimatedbysemi logextrapolation*/ /*calculatetheuncorrelatedaverage*/for(i=0;i=DECAY_POINT)decayed=1;/*generatesemilogscale,anddeterminecorrelationtimef romit'sinverseslope*/ 170

PAGE 185

if(log_scale){ printf("%d%f\n",i,exp(ac));if(decayed&&!log_corr_time){/*takeinverseslopeuntil decaypoint*/ log_corr_time=(int)(ceil(((double)i)/(exp(1.0)-exp( ac)))); } }else{ printf("%d%f\n",i,ac);/*sumthiscontributionintotheintegral,untilwegettoth enoisypart*/ if(!decayed)ac_integral+=ac; } }/*returntheestimatedcorrelationtime*/if(log_scale) corr_time=log_corr_time; else corr_time=(int)ceil(ac_integral); return(corr_time); }voidusage(char*progname){ fprintf(stderr,"usage:%s<-l>[datafile]\n",progname) ; fprintf(stderr,"options:-loutputlogarithmicscale\n" ); exit(1); }intmain(intargc,char**argv){ inti,n=0,log_scale=0;char*datfile;FILE*fp;double*dat;intc;externchar*optarg;externintoptind,optopt;if(argc<2)usage((char*)argv[0]);while((c=getopt(argc,(char**)argv,"l"))!=-1){ switch(c){ case'l': log_scale=1;break; case'?':usage((char*)argv[0]); } }datfile=argv[optind];if(!datfile){ fprintf(stderr,"error:invaliddatafile\n");usage((char*)argv[0]); }else fp=fopen(datfile,"r"); if(!fp){ fprintf(stderr,"error:couldnotopendatafile%s\n",dat file); usage((char*)argv[0]); }/*loadinthedata-XXXdowithoutnum_lines*/dat=(double*)calloc(NUM_LINES,sizeof(double));if(!dat){ fprintf(stderr,"couldn'tallocateworkingmemorybuffer \n"); exit(1); }for(i=0;n!=EOF;i++){ n=fscanf(fp,"%lg",(dat+i)); }fclose(fp);printf("#correlationtime=%d\n",autocorr(dat,(i-1),l og_scale)); free(dat);exit(0); } 171

PAGE 186

AppendixG.get virial coecients.c /*CalculatethequantumsecondvirialcoefficienttosecondorderviatheWigner-Kirkwood semiclassicalexpansion,includingthethird-orderideal quantumexchangeterm @2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include#include#include#include#defineH6.626068e-34/*Planck'sconstantinJs*/#defineHBAR1.054571e-34/*abovedividedby2piinJs*/#defineKB1.3806503e-23/*Boltzmann'sconstantinJ/K*/#defineNA6.0221415e23/*Avogadro'snumber*/#defineH2_MASS3.348e-27/*massofH2moleculeinkg*/#defineMAXLINE256voidusage(char*progname){ fprintf(stderr,"usage:%s \n",progname); exit(1); }intmain(intargc,char**argv){ inti,N;FILE*fp_fit;charlinebuf[MAXLINE];doubler,r_min,r_max,r_inc;doublefirst_derivative,second_derivative,integrand;double*r_input,*fit_input;charfit_file[MAXLINE];doubletemperature,temperature_min,temperature_max,t emperature_inc; doubleB,B_classical,B_quantum_first,B_quantum_secon d,B_quantum_ideal; if(argc!=5) usage(argv[0]); temperature_min=atof(argv[1]);temperature_max=atof(argv[2]);temperature_inc=atof(argv[3]);strcpy(fit_file,argv[4]);/*readinthenumberoflines*/fp_fit=fopen(fit_file,"r");for(N=0;fgets(linebuf,MAXLINE,fp_fit);N++);fclose(fp_fit);/*allocatespace*/r_input=calloc(N,sizeof(double));fit_input=calloc(N,sizeof(double));/*readintheisotropicfunction*/fp_fit=fopen(fit_file,"r");for(i=0;i
PAGE 187

first_derivative=KB*(fit_input[i+1]-fit_input[i])/r _inc; second_derivative=KB*((fit_input[i+2]-fit_input[i+1 ])/r_inc-first_derivative)/r_inc; integrand=pow(second_derivative,2.0)+2.0*pow((first _derivative/r),2.0); integrand+=(10.0/(9.0*KB*temperature))*pow(first_de rivative,3.0)/r; integrand-=(5.0/(36.0*pow(KB*temperature,2.0)))*pow (first_derivative,4.0)/r; integrand*=exp(-fit_input[i]/temperature)*pow(r,2.0 )*r_inc; B_quantum_second+=integrand; }B_quantum_second*=pow(H*H/H2_MASS,2.0)/(960.0*M_PI* M_PI*M_PI*pow(KB*temperature,4.0)); B_quantum_second*=-1.0e11*NA;/*theexchangetermforanidealBose-Einsteingas*/B_quantum_ideal=-NA*pow((H*H/(2.0*M_PI*H2_MASS*KB*t emperature)),(3.0/2.0))*pow(2.0,(-5.0/2.0)); B_quantum_ideal*=1.0e6;/*thetotalvirialcoefficient*/B=B_classical+B_quantum_first+B_quantum_second+B_qu antum_ideal; printf("%f%f\n",temperature,B);/*printf("%f%f%f%f%f%f\n",temperature,B,B_classical ,B_quantum_first,B_quantum_second,B_quantum_ideal); */ }return(0); } 173

PAGE 188

AppendixH.virial iso.c /************************************************//**//*Calculatethevirialisothermusingthe"a"*//*coefficientsfromtheCRC*//**//*JonathanBelof*//*DepartmentofChemistry*//*UniversityofSouthFlorida*//**//*compilewith:*//*gcc-std=c99-ov./virial_iso.c-lm*//**//************************************************/#include#include#include#include#include#defineT0298.15/*standardtemperature(K)*/#defineNA6.02214e23/*Avogadro'snumber*/#defineKB1.3806503e-23/*Boltzmann'sconstant*/#defineATM2PSC101325/*convertfromatmtoPascals*/#defineDP100.0/*smallintervalinPascals*/voidusage(char*progname){ fprintf(stderr,"usage:%s[a2][a3]...\n",progname); fprintf(stderr,"\t:molecular/atomicweight(g/mol )\n"); fprintf(stderr,"\t:temperatureofisotherm(K)\n "); fprintf(stderr,"\t:startingpressureo fisotherm(atm)\n"); fprintf(stderr,"\t:stoppingpressureof isotherm(atm)\n"); fprintf(stderr,"\t:numberofdatapointstocalc ulate(integer)\n"); fprintf(stderr,"\t:thei-tha-coefficientfromtheC RC\n"); fprintf(stderr,"\nusefulparameters:\n");fprintf(stderr,"\tH2:\ta1=15.4a2=-9.0a3=-0.2\n");fprintf(stderr,"\tHe:\ta1=12a2=-1\n");fprintf(stderr,"\tH2O:\ta1=-1158a2=-5157a3=-10301a4 =-10597a5=-4415\n"); fprintf(stderr,"\tUF6:\ta1=-1204a2=-2690a3=-2144\n" ); fprintf(stderr,"\tN2:\ta1=-4a2=-56a3=-12\n");fprintf(stderr,"\tO2:\ta1=-16a2=-62a3=-8a4=-3\n");fprintf(stderr,"\tCO:\ta1=-9a2=-58a3=-18\n");fprintf(stderr,"\tNO:\ta1=-12a2=-119a3=89a4=-73\n") ; fprintf(stderr,"\tCO2:\ta1=-127a2=-288a3=-118\n");fprintf(stderr,"\tAr:\ta1=-16a2=-60a3=-10\n");fprintf(stderr,"\tKr:\ta1=-51a2=-118a3=-29a4=-5\n") ; fprintf(stderr,"\tXe:\ta1=-130a2=-262a3=-87\n");exit(1); }intmain(intargc,char**argv){ doublemw;/*molecularweight(g/mol)*/doubletemperature;/*temperaturetoperformtheisotherm at(K)*/ doublekT;/*thermalenergy(J)*/doubleP;/*currentpressure(Pascals)*/doubledP;/*pressureinterval(Pascals)*/doublepressure_lb,pressure_ub;/*lowerandupperpressu rebounds(atm)*/ intpoints;/*numberofdatapointstocalculate*/doubleB;/*2ndvirialcoefficient(cm^3/mol)*/doubledensity;/*density,tobesolvedfor(g/cm^3)*/inti;/*usedforargparsing*/doublecurrent_a;/*usedinparsingoutthe"a"coefficient s*/ if(argc<7) usage(argv[0]); else{++argv;--argc;};/*readinthemainarguments*/mw=atof(*argv);++argv;--argc;temperature=atof(*argv);++argv;--argc;pressure_lb=atof(*argv);++argv;--argc;pressure_ub=atof(*argv);++argv;--argc;points=atoi(*argv);++argv;--argc;/*argumentchecking*/if((mw<1)||(mw>267)){/*synthesizeanewisotopelately? */ fprintf(stderr,"%s:invalidmolecularweight\n",argv[0 ]); usage(argv[0]); }if(temperature<0){ fprintf(stderr,"%s:invalidtemperature\n",argv[0]);usage(argv[0]); }if((pressure_lb>pressure_ub)||(pressure_lb<0)||(pre ssure_ub<0)){ fprintf(stderr,"%s:invalidpressurerangespecified\n" ,argv[0]); usage(argv[0]); }if(points<1){ fprintf(stderr,"%s:invalidnumberofdatapoints\n",arg v[0]); usage(argv[0]); }/*readinthe"a"coefficients*/for(i=0,B=0;i
PAGE 189

B+=current_a*(pow((T0/temperature-1),i)); }/*unitconversionstoSI*/pressure_lb*=ATM2PSC;/*convertfromatmtoPascals*/pressure_ub*=ATM2PSC;/*ditto*/dP=(pressure_ub-pressure_lb)/points;/*intervaltouse incalculatingthefunction*/ B/=NA*1.0e6;/*convertfromcm^3/moltom^3/molec*/kT=KB*temperature;/*calculatekT(J)*/for(P=pressure_lb;P<=pressure_ub;P+=dP){ /*solveforthedensityquadratically*/density=(-1+sqrt(1+4*B*P/kT))/(2*B);density*=mw/(NA*1.0e6);/*converttog/cm^3*/if(!finite(density))/*ifwe'reinnon-physicalterritor y,don'tbotherwithNaN's*/ break; else printf("%f%f\n",P/ATM2PSC,density);/*outputthepress ureinatm,densitying/cm^3*/ }exit(0); } 175

PAGE 190

AppendixI.structure factor.c /************************************************** **************/ /*CalculatesthestructurefactorS(k)fromag(r)*//**//*Inlatex,thestructurefactoris:*//*S(k)=1+4\pi\frac{\rho}{k}\int_0^\inftyr[g(r)-1]\s in(kr)dr*/ /**//*whererhoistheatomicdensity,kisindistanceunits*//**//*InordertoeliminatenoiseformtheS(k),thetailendof*//*theg(r)needstobeextrapolatedtoacleaneranalytical* / /*form.Theformusedhereis:*//*h(r)=\frac{A}{r}e^{-\frac{r}{r_0}}\sin(\frac{r}{r _1})*/ /**//*wheretheparametersA,r0,r1aswellastheextrapolation */ /*point,aredeterminedfromfittingtotheg(r)*//**//*Fittingprocedure:*//*Settheextrapolationpointtothethirdzerovalueinthe* / /*h(r).SetAtotheheightofthenextpeak.Setr0toa*//*largevaluesothattheexponentialdampingisminimial-* / /*thenplaywithr1untilthephaseofthesinwaveisaclose*//*fit.Thendecreaser0toincreasetheexponentialdamping */ /*untilthefitisfinal-Amayneedminortweakingatthat*//*point.*//**//*usage:./sf<-f>[density][xp][A][r0][r1][datafile]* / /*<-f>-turnsonfittingmode,h(r)extrapolatedisoutput* / /*side-by-sidewiththeg(r)-basedh(r)*//*[density]-densityinunitsofmolecules/A^3*//*[datfile]-twocolumnfilecontainingtheg(r)anddomain */ /**//*compilation:gcc-osfsf.c-lm*//**//*@2006*//*JonathanBelof*//*SpaceResearchGroup*//*DepartmentofChemistry*//*UniversityofSouthFlorida*//************************************************** **************/ #defineRESOLUTION0.001#defineMAXLINE4000000#defineSK_LOWER_BOUND0#defineSK_UPPER_BOUND10#defineH_LOWER_BOUND0#defineH_UPPER_BOUND100structgor_t{ doubledomain;doublerange; };#include#include#include#include#include#include#include#include/*generateacurvetofitA,r0andr1*//*firstcolumnoutputisg(r)-1,thesecondcolumnistheext rapolatedform*/ voidfit_gor(structgor_t*gor,intnum_gor,doubleextrap olation_point,doubleA,doubler0,doubler1){ inti,j;/*workingindices*/double*h;/*h(r)=g(r)-1*/double*h_x;/*h(r)=extrapolated*/intlower_bound,upper_bound;/*lower/upperboundsforth edomainofh(r)*/ doubleresolution=RESOLUTION;lower_bound=(int)rint(((double)H_LOWER_BOUND)/resol ution); upper_bound=(int)rint(((double)H_UPPER_BOUND)/resol ution); h=calloc(upper_bound,sizeof(double));h_x=calloc(upper_bound,sizeof(double));printf("#extrapolationpoint=%fA\n",extrapolation_po int); printf("#A=%f\n",A);printf("#r0=%f\n",r0);printf("#r1=%f\n",r1);/*generateh(r)=g(r)-1*/for(i=0;idomain-((double)j)*resolution)range-1.0; } }/*generateh(r)=extrapolated*/for(i=lower_bound;((double)i)*resolution
PAGE 191

double*make_h(structgor_t*gor,intnum_gor,doubleextr apolation_point,doubleA,doubler0,doubler1){ inti,j;/*workingindices*/double*h;/*h(r)=g(r)-1*/double*h_x;/*h(r)=extrapolated*/intlower_bound,upper_bound;/*lower/upperboundsforth edomainofh(r)*/ doubleresolution=RESOLUTION;lower_bound=(int)rint(((double)H_LOWER_BOUND)/resol ution); upper_bound=(int)rint(((double)H_UPPER_BOUND)/resol ution); h=calloc(upper_bound,sizeof(double));h_x=calloc(upper_bound,sizeof(double));printf("#extrapolationpoint=%fA\n",extrapolation_po int); printf("#A=%f\n",A);printf("#r0=%f\n",r0);printf("#r1=%f\n",r1);/*generateh(r)=g(r)-1*/for(i=0;idomain-((double)j)*resolution)range-1.0; } }/*generateh(r)=extrapolated*/for(i=lower_bound;((double)i)*resolution[density][xp][A][r0][r1 ][datafile]\n",progname); fprintf(stderr,"<-f>-turnsonfittingmode,h(r)extrapo latedisoutput\n"); fprintf(stderr,"side-by-sidewiththeg(r)-basedh(r)\n "); fprintf(stderr,"[density]-densityinunitsofmolecules /A^3\n"); fprintf(stderr,"[datfile]-twocolumnfilecontainingth eg(r)anddomain\n"); exit(1); }intmain(intargc,char**argv){ inti,n,c,fitting=0;FILE*fp;char*datfile;doubledensity,xp,A,r0,r1; 177

PAGE 192

structgor_t*gor;externchar*optarg;externintoptind,optopt;if(argc<7)usage((char*)argv[0]);/*getarguments*/c=getopt(argc,(char**)argv,"f");if(c!=-1){ switch(c){ case'f': fitting=1;break; case'?':usage((char*)argv[0]); } }/*getthedensityofparticlesforS(k)*/density=atof(argv[optind]);/*gettheparameters*/xp=atof(argv[++optind]);A=atof(argv[++optind]);r0=atof(argv[++optind]);r1=atof(argv[++optind]);/*getthefilenamecontainingtheg(r)*/datfile=argv[++optind];if(!datfile){ fprintf(stderr,"error:invaliddatafile\n");usage((char*)argv[0]); }else fp=fopen(datfile,"r"); if(!fp){ fprintf(stderr,"error:couldnotopendatafile%s\n",dat file); usage((char*)argv[0]); }/*loadinthedata*/gor=(structgor_t*)calloc(MAXLINE,sizeof(structgor_t )); if(!gor){ fprintf(stderr,"error:couldn'tallocateworkingmemory buffer\n"); exit(1); }for(i=0;n!=EOF;i++){ n=fscanf(fp,"%lg%lg",&(gor+i)->domain,&(gor+i)->ran ge); }fclose(fp);--i;if(!i){ fprintf(stderr,"error:datfile%sisempty\n",datfile);exit(1); }/*realloctosavememory*/gor=realloc(gor,sizeof(structgor_t)*i);if(!gor){ fprintf(stderr,"error:couldn'treallocworkingmemoryb uffer\n"); exit(1); }if(fitting) fit_gor(gor,i,xp,A,r0,r1);/*getthefittedh(r)*/ else structure_factor(gor,i,density,xp,A,r0,r1);/*getthe structurefactor*/ /*freeourg(r)structureandexit*/free(gor);exit(0); } 178

PAGE 193

AppendixJ.rng.c /************************************************** **********************/ /*Cellularautomatarule30-derivedpseudorandomnumberg enerator*/ /**//*Thisimplementationisforboth32and64bitarchitecture s,butis*/ /*ideallyimplementedfor64.Thecodehasbeengeneralized sothat*/ /*classIIIsystemsotherthanrule30canbeutilizedforres earch*/ /*purposes.Theschememakesusearegisterarrayuponwhich therule*/ /*isimposed-thenextstepintheautomataisgeneratedinth eset*/ /*ofoutputregisters.Eachendoftheregisterarrayis'wra pped'*/ /*intoacircularregister;whilethisreducestheperiodic interval*/ /*ofrule30,theliteraturenotesthatthisprobablistical lyoccurs*/ /*ontheorderofmoderncryptographicsystems.Tosimplify thelogic*/ /*theruleisimplementeddirectlyintotheoutputregister array,and*/ /*thenshiftedonebittotherightattheendinorderfortheo utput*/ /*toalign.Noticethatrule30couldbemorecheaplyimpleme nted*/ /*(atthecostofgenerality)by(leftXOR(middleORright)) -that*/ /*isnotdonehere.Thedesignatedcenterbitofeachiterati onis*/ /*usedtogeneratethemantissaofthedoublefloatreturned ,asper*/ /*Wolfram,"ANewKindofScience".ItisknownthatMathemat icauses*/ /*thisexactmethodinit'simplementationofRandom[].*//**//*Benchmarkresults:*//**//*compilewith:*//*gcc-orule30rng-fomit-frame-funroll-loops-O3rule30 .rng.c*/ /**//*@2005JonathanBelof*//*SpaceResearchGroup*//*DepartmentofChemistry*//*UniversityofSouthFlorida*//************************************************** **********************/ /*#defineDEBUG*//*#defineBENCHMARK*/#include#include#include#include#include#include#defineWORDSIZE__WORDSIZE#ifWORDSIZE==64/*64-bitmasks*/#defineRULE300x000000000000001E/*000000000000000000 0000000000000000000000000000000000000000011110*/ #defineRULE1100x000000000000006E/*00000000000000000 00000000000000000000000000000000000000001101110*/ #defineRULE100x000000000000000A/*000000000000000000 0000000000000000000000000000000000000000001010*/ #defineRULE900x000000000000005A/*000000000000000000 0000000000000000000000000000000000000001011010*/ #defineCELL_MASK0x0000000000000007/*000000000000000 0000000000000000000000000000000000000000000000111*/ #defineCENTER_MASK0x0000000100000000/*0000000000000 000000000000000000100000000000000000000000000000000 */ #defineDELTA_CENTER0x0000000000000020/*000000000000 000000000000000000000000000000000000000000000010000 0*/ #defineRHS_ONE0x0000000000000001/*00000000000000000 00000000000000000000000000000000000000000000001*/ #defineLHS_ONE0x8000000000000000/*10000000000000000 00000000000000000000000000000000000000000000000*/ #defineLHS_ZERO0x7FFFFFFFFFFFFFFF/*0111111111111111 111111111111111111111111111111111111111111111111*/ #defineINNER_COUNT0x00000000000000FF/*0000000000000 000000000000000000000000000000000000000000011111111 */ #defineINNER_ONE0x0000000000000001/*000000000000000 0000000000000000000000000000000000000000000000001*/ #defineINNER_ZERO0xFFFFFFFFFFFFFF00/*11111111111111 11111111111111111111111111111111111111111100000000* / #defineOUTER_COUNT0x0000000000FFFF00/*0000000000000 000000000000000000000000000111111111111111100000000 */ #defineOUTER_ONE0x0000000000000100/*000000000000000 0000000000000000000000001000000000000000000000000*/ #defineOUTER_ZERO0xFFFFFFFFFF0000FF/*11111111111111 11111111111111111111111111000000000000000011111111* / #defineDELTA_COUNT0x0000000000000008/*0000000000000 000000000000000000000000000000000000000000000001000 */ #defineDELTA_MANTISSA0x0000000000000034/*0000000000 000000000000000000000000000000000000000000000000110 100*/ #defineMAX_MANTISSA0x000FFFFFFFFFFFFF/*000000000000 111111111111111111111111111111111111111111111111111 1*/ #defineSEED0x38B1D098F2C40E5D#else/*32-bitmasks*/#defineRULE300x0000001E/*00000000000000000000000000 011110*/ #defineRULE1100x0000006E/*0000000000000000000000000 1101110*/ #defineRULE100x0000000A/*00000000000000000000000000 001010*/ #defineRULE900x0000005A/*00000000000000000000000001 011010*/ #defineCELL_MASK0x00000007/*00000000000000000000000 000000111*/ #defineCENTER_MASK0x00010000/*000000000000000100000 00000000000*/ #defineDELTA_CENTER0x00000010/*00000000000000000000 000000010000*/ #defineRHS_ONE0x00000001/*0000000000000000000000000 0000001*/ #defineLHS_ONE0x80000000/*1000000000000000000000000 0000000*/ #defineLHS_ZERO0x7FFFFFFF/*011111111111111111111111 11111111*/ #defineINNER_COUNT0x000000FF/*000000000000000000000 00011111111*/ #defineINNER_ONE0x00000001/*00000000000000000000000 000000001*/ #defineINNER_ZERO0xFFFFFF00/*1111111111111111111111 1100000000*/ #defineOUTER_COUNT0x00FFFF00/*000000001111111111111 11100000000*/ #defineOUTER_ONE0x00000100/*00000001000000000000000 000000000*/ #defineOUTER_ZERO0xFF0000FF/*1111111100000000000000 0011111111*/ #defineDELTA_COUNT0x00000008/*000000000000000000000 00000001000*/ #defineDELTA_MANTISSA0x0000000000000034/*0000000000 000000000000000000000000000000000000000000000000110 100*/ #defineMAX_MANTISSA0x00000000FFFFFFFF/*000000000000 000000000000000000001111111111111111111111111111111 1*/ #defineSEED0xF2C40E5D#endif/*WORDSIZE==64*//*debuggingroutinesinceprintfstilldoesn'thavebinary outputintheyear2005*/ voidprint_binary(unsignedlongintin){ unsignedlongintout=0;inti;for(i=0;i
PAGE 194

else printf("0"); in<<=RHS_ONE; } }voidprint_binary_double(doublein_double){ inti;longlongin;longlongout=0;in=(longlong)in_double;for(i=0;i<64;i++){ out=in&LHS_ONE;if(out&LHS_ONE) printf("1"); else printf("0"); in<<=RHS_ONE; } }#ifWORDSIZE==64/*64-bit*/doublerule30_rng(unsignedlongintseed){ registerunsignedlongintrule=RULE30;/*theruletoenfor ce*/ registerunsignedlongintin_reg1=0,/*inputregisters*/ in_reg2=0,in_reg3=0,in_reg4=0,in_reg5=0,in_reg6=0,in_reg7=0; registerunsignedlongintout_reg1=0,/*outputregisters */ out_reg2=0,out_reg3=0,out_reg4=0,out_reg5=0,out_reg6=0,out_reg7=0; registerunsignedlongintmp=0;/*multi-purposeregister :*/ /*-theright-most8bitsarefortheinnerloopcounter*//*-thenext16bitsarefortheouterloopcounter*//*-theleft-mostbitisforcarries*/ staticunsignedlongintlast_reg1,/*staticmemoryaddrst ostoreresultsfromthecurrentrun*/ last_reg2,last_reg3,last_reg4,last_reg5,last_reg6,last_reg7; doublerandom_result=0;/*returnadoublefrom0.0to1.0*/unsignedlongintrandom_result_int=0;/*integerversion oftheaboveforbooleanops*/ /*startwithinitialconfig*/if(seed){ in_reg1=in_reg2=in_reg3=in_reg4=in_reg5=in_reg6=in_ reg7=seed; }else{ #ifdefDEBUG /*setupthecanonicalstatefordebugging*/in_reg4=CENTER_MASK; #else /*alreadyseeded-restorestatefrommemory*/in_reg1=last_reg1;in_reg2=last_reg2;in_reg3=last_reg3;in_reg4=last_reg4;in_reg5=last_reg5;in_reg6=last_reg6;in_reg7=last_reg7; #endif/*DEBUG*/ } #ifdefDEBUG /*thecurrentcellularautomatarulebeingimposed*/printf("currentrule:%d\n\n",rule);/*printinitialline*/print_binary(in_reg4);printf("\n"); #endif/*DEBUG*/ for((mp&=OUTER_ZERO);((mp&OUTER_COUNT)>>DELTA_COUNT )>(in_reg1&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg2|=((rule>>(in_reg2&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg3|=((rule>>(in_reg3&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg4|=((rule>>(in_reg4&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg5|=((rule>>(in_reg5&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg6|=((rule>>(in_reg6&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg7|=((rule>>(in_reg7&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); 180

PAGE 195

/*rotateallinputregistersonebittotheright,preservec arry*/ mp&=LHS_ZERO;/*clearthecarrybit*/mp|=((in_reg7&RHS_ONE)<<(WORDSIZE-1));/*setcarrybit ifneeded*/ in_reg7>>=RHS_ONE;in_reg7|=((in_reg6&RHS_ONE)<<(WORDSIZE-1));in_reg6>>=RHS_ONE;in_reg6|=((in_reg5&RHS_ONE)<<(WORDSIZE-1));in_reg5>>=RHS_ONE;in_reg5|=((in_reg4&RHS_ONE)<<(WORDSIZE-1));in_reg4>>=RHS_ONE;in_reg4|=((in_reg3&RHS_ONE)<<(WORDSIZE-1));in_reg3>>=RHS_ONE;in_reg3|=((in_reg2&RHS_ONE)<<(WORDSIZE-1));in_reg2>>=RHS_ONE;in_reg2|=((in_reg1&RHS_ONE)<<(WORDSIZE-1));in_reg1>>=RHS_ONE;in_reg1|=mp&LHS_ONE; }/*nowmustrotateoutputregistersonebittotheleft*/mp&=LHS_ZERO;/*clearthecarrybit*/mp|=out_reg1&LHS_ONE;/*setthecarrybitifneeded*/out_reg1<<=RHS_ONE;out_reg1|=((out_reg2&LHS_ONE)>>(WORDSIZE-1));out_reg2<<=RHS_ONE;out_reg2|=((out_reg3&LHS_ONE)>>(WORDSIZE-1));out_reg3<<=RHS_ONE;out_reg3|=((out_reg4&LHS_ONE)>>(WORDSIZE-1));out_reg4<<=RHS_ONE;out_reg4|=((out_reg5&LHS_ONE)>>(WORDSIZE-1));out_reg5<<=RHS_ONE;out_reg5|=((out_reg6&LHS_ONE)>>(WORDSIZE-1));out_reg6<<=RHS_ONE;out_reg6|=((out_reg7&LHS_ONE)>>(WORDSIZE-1));out_reg7<<=RHS_ONE;out_reg7|=((mp&LHS_ONE)>>(WORDSIZE-1));/*setoutputbitsofrandomnumber*/(unsignedlongint)random_result_int|=((out_reg4&CENT ER_MASK)>>DELTA_CENTER)<<((DELTA_MANTISSA-1)-((mp& OUTER_COUNT)>>DELTA_COUNT));#ifdefDEBUG /*givevisualoutput*/print_binary(out_reg4);printf("\t%d\n",(mp&OUTER_CO UNT)>>DELTA_COUNT); #endif/*DEBUG*/ /*swaptheinputandoutputregisters*/in_reg1=out_reg1;in_reg2=out_reg2;in_reg3=out_reg3;in_reg4=out_reg4;in_reg5=out_reg5;in_reg6=out_reg6;in_reg7=out_reg7;/*clearoutputregisters*/out_reg1=out_reg2=out_reg3=out_reg4=out_reg5=out_re g6=out_reg7=0; }/*savelaststatepointtostaticmemory*/last_reg1=in_reg1;last_reg2=in_reg2;last_reg3=in_reg3;last_reg4=in_reg4;last_reg5=in_reg5;last_reg6=in_reg6;last_reg7=in_reg7;random_result=(double)random_result_int;random_result/=(double)MAX_MANTISSA;/*ensurethatres ultisnormalizedfrom0to1*/ return(random_result); }#else/*32-bit*/doublerule30_rng(unsignedlongintseed){ registerunsignedlongintrule=RULE30;/*theruletoenfor ce*/ registerunsignedlongintin_reg1=0,/*inputregisters*/ in_reg2=0,in_reg3=0; registerunsignedlongintout_reg1=0,/*outputregisters */ out_reg2=0,out_reg3=0; registerunsignedlongintmp=0;/*multi-purposeregister :*/ /*-theright-most8bitsarefortheinnerloopcounter*//*-thenext16bitsarefortheouterloopcounter*//*-theleft-mostbitisforcarries*/ staticunsignedlongintlast_reg1,/*staticmemoryaddrst ostoreresultsfromthecurrentrun*/ last_reg2,last_reg3; doublerandom_result=0;/*returnadoublefrom0.0to1.0*/unsignedlonglongintrandom_result_int=0;/*integerver sionoftheaboveforbooleanops*/ /*startwithinitialconfig*/if(seed){ in_reg1=in_reg2=in_reg3=seed; }else{ #ifdefDEBUG /*setupthecanonicalstatefordebugging*/in_reg2=CENTER_MASK; #else 181

PAGE 196

/*alreadyseeded-restorestatefrommemory*/in_reg1=last_reg1;in_reg2=last_reg2;in_reg3=last_reg3; #endif/*DEBUG*/ } #ifdefDEBUG /*thecurrentcellularautomatarulebeingimposed*/printf("currentrule:%d\n\n",rule);/*printinitialline*/print_binary(in_reg1);print_binary(in_reg2);print_b inary(in_reg3);printf("\n"); #endif/*DEBUG*/ for((mp&=OUTER_ZERO);((mp&OUTER_COUNT)>>DELTA_COUNT )>(in_reg1&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg2|=((rule>>(in_reg2&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg3|=((rule>>(in_reg3&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); /*rotateallinputregistersonebittotheright,preservec arry*/ mp&=LHS_ZERO;/*clearthecarrybit*/mp|=((in_reg3&RHS_ONE)<<(WORDSIZE-1));/*setcarrybit ifneeded*/ in_reg3>>=RHS_ONE;in_reg3|=((in_reg2&RHS_ONE)<<(WORDSIZE-1));in_reg2>>=RHS_ONE;in_reg2|=((in_reg1&RHS_ONE)<<(WORDSIZE-1));in_reg1>>=RHS_ONE;in_reg1|=mp&LHS_ONE; }/*nowmustrotateoutputregistersonebittotheleft*/mp&=LHS_ZERO;/*clearthecarrybit*/mp|=out_reg1&LHS_ONE;/*setthecarrybitifneeded*/out_reg1<<=RHS_ONE;out_reg1|=((out_reg2&LHS_ONE)>>(WORDSIZE-1));out_reg2<<=RHS_ONE;out_reg2|=((out_reg3&LHS_ONE)>>(WORDSIZE-1));out_reg3<<=RHS_ONE;out_reg3|=((mp&LHS_ONE)>>(WORDSIZE-1)); /*setoutputbitsofrandomsequence*/random_result_int|=((out_reg2&CENTER_MASK)>>DELTA_C ENTER)<<((DELTA_MANTISSA-1)-((mp&OUTER_COUNT)>> DELTA_COUNT));#ifdefDEBUG /*givevisualoutput*/print_binary(out_reg1);print_binary(out_reg2);print _binary(out_reg3);printf("\t%d\n",(mp&OUTER_COUNT)> >DELTA_COUNT); #endif/*DEBUG*/ /*swaptheinputandoutputregisters*/in_reg1=out_reg1;in_reg2=out_reg2;in_reg3=out_reg3;/*cleartheoutputregisters*/out_reg1=out_reg2=out_reg3=0; }/*savethelaststatepointinstaticmemory*/last_reg1=in_reg1;last_reg2=in_reg2;last_reg3=in_reg3;random_result=(double)random_result_int;random_result/=(double)MAX_MANTISSA;/*ensurethatres ultisnormalizedfrom0to1*/ return(random_result); }#endif/*WORDSIZE==64*/intmain(){ inti;unsignedlongintseed=1234523;doublerand;clock_tinitial_time,final_time;rule30_rng(seed); #ifdefBENCHMARK while(1){ initial_time=final_time=clock();for(i=0;(final_time-initial_time)/CLOCKS_PER_SEC<1. 0;i++){ final_time=clock();rand=rule30_rng(0); }fprintf(stderr,"#performance:%ddoubles/sec\n",i); } #else for(i=0;i<1000000;i++){ rand=rule30_rng(0);printf("%.16f\n",rand); } #endif/*BENCHMARK*/ exit(0);/*NOTREACHED*/ } 182

PAGE 197

183

PAGE 198

AppendixK.Q st RCode ***importLong'sTorr(p/p0)vs.mmol/gisotherm***iso77<-read.table("S8.77K.torr_vs_mmolg.dat")iso87<-read.table("S8.87K.torr_vs_mmolg.dat")***importLong'snormalizedunits***iso77<-read.table("S8.77K.pp0_vs_n0.dat")iso87<-read.table("S8.87K.pp0_vs_n0.dat")***importLong'spercentwtisotherms***iso77<-read.table("S8.77K.pp0_vs_percwt.dat")iso87<-read.table("S8.87K.pp0_vs_percwt.dat")***importME080normalizedunitsofthesameisotherms***iso77<-read.table("ME080.77K.pp0_vs_n0.dat")iso87<-read.table("ME080.87K.pp0_vs_n0.dat")***importME080percentwtunits***iso77<-read.table("ME080.77K.pp0_vs_percwt.dat")iso87<-read.table("ME080.87K.pp0_vs_percwt.dat")***fitisotherm***x77<-iso77$V1y77<-iso77$V2x87<-iso87$V1y87<-iso87$V2isofn<-function(p)sum(((log(x77)-(log(y77)+(p[1]*y7 7^0+p[2]*y77^1+p[3]*y77^2+p[4]*y77^3+p[5]*y77^4)/77 .0+p[6]*y77^0+ p[7]*y77^1+p[8]*y77^2))^2)+((log(x87)-(log(y87)+(p[ 1]*y87^0+p[2]*y87^1+p[3]*y87^2+p[4]*y87^3+p[5]*y87^ 4)/87.0+p[6]*y87^0 +p[7]*y87^1+p[8]*y87^2))^2))fitparams<-nlminb(c(1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 ),isofn) fitiso77<-function(N)exp(log(N)+(fitparams$par[1]*N ^0+fitparams$par[2]*N^1+fitparams$par[3]*N^2+fitpar ams$par[4]*N^3+ fitparams$par[5]*N^4)/77.0+fitparams$par[6]*N^0+fit params$par[7]*N^1+fitparams$par[8]*N^2) fitiso87<-function(N)exp(log(N)+(fitparams$par[1]*N ^0+fitparams$par[2]*N^1+fitparams$par[3]*N^2+fitpar ams$par[4]*N^3+ fitparams$par[5]*N^4)/87.0+fitparams$par[6]*N^0+fit params$par[7]*N^1+fitparams$par[8]*N^2) #independent<-seq(0.0,110.0,0.01)independent<-seq(0.0,3.0,0.001)plot(x77,y77)points(x87,y87)plot(fitiso77(independent),independent)points(fitiso87(independent),independent)***outputisothermstoafile***output77<-data.frame(fitiso77(independent),independ ent) output87<-data.frame(fitiso87(independent),independ ent) write.table(output77,"fit_isotherm77.dat",row.names =FALSE,col.names=FALSE) write.table(output87,"fit_isotherm87.dat",row.names =FALSE,col.names=FALSE) ***generateLongqst***qst<-function(N)-0.008314472*(fitparams$par[1]*N^0+ fitparams$par[2]*N^1+fitparams$par[3]*N^2+fitparams $par[4]*N^3+ fitparams$par[5]*N^4)independent<-seq(0.0,3.0,0.01)plot(independent,qst(independent))outputtofile:output<-data.frame(independent,qst(independent))write.table(output,"fit_qst.dat",row.names=FALSE,co l.names=FALSE) ***finitedifferenceqst***lniso77<-function(N)(log(N)+(fitparams$par[1]*N^0+f itparams$par[2]*N^1+fitparams$par[3]*N^2+fitparams$ par[4]*N^3+ fitparams$par[5]*N^4)/77.0+fitparams$par[6]*N^0+fit params$par[7]*N^1+fitparams$par[8]*N^2) lniso87<-function(N)(log(N)+(fitparams$par[1]*N^0+f itparams$par[2]*N^1+fitparams$par[3]*N^2+fitparams$ par[4]*N^3+ fitparams$par[5]*N^4)/87.0+fitparams$par[6]*N^0+fit params$par[7]*N^1+fitparams$par[8]*N^2) qst<-function(T1,T2,N)-0.008314472*(lniso77(N)-lnis o87(N))/(1.0/T1-1.0/T2) #independent<-seq(0.0,100.0,0.01)independent<-seq(0.0,3.0,0.01)plot(independent,qst(77.0,87.0,independent))***outputqsttoafile***output<-data.frame(independent,qst(77.0,87.0,indepe ndent)) write.table(output,"fit_qst.dat",row.names=FALSE,co l.names=FALSE) **********XXXEXPERIMENTALfdqstwithchoiceoftemperatu re************* 184

PAGE 199

lniso77<-function(N)(log(N)+(fitparams$par[1]*N^0+f itparams$par[2]*N^1 +fitparams$par[3]*N^2+fitparams$par[4]*N^3+fitparam s$par[5]*N^4)/77.0+ fitparams$par[6]*N^0+fitparams$par[7]*N^1+fitparams $par[8]*N^2) lniso87<-function(N)(log(N)+(fitparams$par[1]*N^0+f itparams$par[2]*N^1 +fitparams$par[3]*N^2+fitparams$par[4]*N^3+fitparam s$par[5]*N^4)/87.0+ fitparams$par[6]*N^0+fitparams$par[7]*N^1+fitparams $par[8]*N^2) qst<-function(T1,T2,N)0.008314472*82.0*82.0*(lniso7 7(N)-lniso87(N))/(T1-T2) #independent<-seq(0.0,100.0,0.01)independent<-seq(0.0,3.0,0.01)plot(independent,qst(77.0,87.0,independent))***********XXXEXPERIMENTALvirialqstwithvaryingcoeff icients************ #ADDANOTHER'A'#***fitisotherm***iso77<-read.table("S8.77K.pp0_vs_percwt.dat")iso87<-read.table("S8.87K.pp0_vs_percwt.dat")x77<-iso77$V1y77<-iso77$V2x87<-iso87$V1y87<-iso87$V2isofn<-function(p)sum(((log(x77)-(log(y77)+(p[1]*y7 7^0+p[2]*y77^1+p[3]*y77^2+p[4]*y77^3+p[5]*y77^4+p[6 ]*y77^5)/77.0+ p[7]*y77^0+p[8]*y77^1+p[9]*y77^2))^2)+((log(x87)-(l og(y87)+(p[1]*y87^0+p[2]*y87^1+p[3]*y87^2+p[4]*y87^ 3+p[5]*y87^4+ p[6]*y87^5)/87.0+p[7]*y87^0+p[8]*y87^1+p[9]*y87^2)) ^2)) fitparams<-nlminb(c(1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 ,1.0),isofn) fitiso77<-function(N)exp(log(N)+(fitparams$par[1]*N ^0+fitparams$par[2]*N^1+fitparams$par[3]*N^2+fitpar ams$par[4]*N^3+ fitparams$par[5]*N^4+fitparams$par[6]*N^5)/77.0+fit params$par[7]*N^0+fitparams$par[8]*N^1+fitparams$pa r[9]*N^2) fitiso87<-function(N)exp(log(N)+(fitparams$par[1]*N ^0+fitparams$par[2]*N^1+fitparams$par[3]*N^2+fitpar ams$par[4]*N^3+ fitparams$par[5]*N^4+fitparams$par[6]*N^5)/87.0+fit params$par[7]*N^0+fitparams$par[8]*N^1+fitparams$pa r[9]*N^2) #independent<-seq(0.0,110.0,0.01)independent<-seq(0.0,3.0,0.001)plot(x77,y77)points(x87,y87)plot(fitiso77(independent),independent)points(fitiso87(independent),independent)#***generateLongqst***qst<-function(N)-0.008314472*(fitparams$par[1]*N^0+ fitparams$par[2]*N^1+fitparams$par[3]*N^2+fitparams $par[4]*N^3+ fitparams$par[5]*N^4+fitparams$par[6]*N^5)independent<-seq(0.0,3.0,0.01)plot(independent,qst(independent))#***outputtofile***output<-data.frame(independent,qst(independent))write.table(output,"fit_qst.dat",row.names=FALSE,co l.names=FALSE) #REMOVEAN'A'#***fitisotherm***iso77<-read.table("S8.77K.pp0_vs_percwt.dat")iso87<-read.table("S8.87K.pp0_vs_percwt.dat")x77<-iso77$V1y77<-iso77$V2x87<-iso87$V1y87<-iso87$V2isofn<-function(p)sum(((log(x77)-(log(y77)+(p[1]*y7 7^0+p[2]*y77^1+p[3]*y77^2)/77.0+p[4]*y77^0+p[5]*y77 ^1+p[6]*y77^2) )^2)+((log(x87)-(log(y87)+(p[1]*y87^0+p[2]*y87^1+p[ 3]*y87^2)/87.0+p[4]*y87^0+p[5]*y87^1+p[6]*y87^2))^2 )) fitparams<-nlminb(c(1.0,1.0,1.0,1.0,1.0,1.0),isofn)fitiso77<-function(N)exp(log(N)+(fitparams$par[1]*N ^0+fitparams$par[2]*N^1+fitparams$par[3]*N^2)/77.0+ fitparams$par[4]*N^0+ fitparams$par[5]*N^1+fitparams$par[6]*N^2)fitiso87<-function(N)exp(log(N)+(fitparams$par[1]*N ^0+fitparams$par[2]*N^1+fitparams$par[3]*N^2)/87.0+ fitparams$par[4]*N^0+ fitparams$par[5]*N^1+fitparams$par[6]*N^2)#independent<-seq(0.0,110.0,0.01)independent<-seq(0.0,3.0,0.001)plot(x77,y77)points(x87,y87)plot(fitiso77(independent),independent)points(fitiso87(independent),independent)#***generateLongqst***qst<-function(N)-0.008314472*(fitparams$par[1]*N^0+ fitparams$par[2]*N^1+fitparams$par[3]*N^2) independent<-seq(0.0,3.0,0.01)plot(independent,qst(independent))#***outputtofile***output<-data.frame(independent,qst(independent))write.table(output,"fit_qst.dat",row.names=FALSE,co l.names=FALSE) 185

PAGE 200

AppendixL.MPMC #!/bin/shif[$#!=5]then echo"usage:$0< CUDA:yes|no>" echo"hostnames:bigbencircegalacticdiraclonestarrang erspintimegeneric" echo"compilers:gccpgiicc"exit1 fiHOSTNAME=$1COMPILER=$2MODE=$3POLARIZATION_CUDA=$4QM_ROTATION=$5if[$QM_ROTATION=="yes"]then DEFINES="-DQM_ROTATION" ficase"$HOSTNAME"in "bigben") case"$COMPILER"in "gcc") echo"error:compiler$COMPILERnotsupportedforhostname $HOSTNAME" exit1 ;;"pgi") CC="cc"CFLAGS="-O3-fastsse-Mnontemporal-Mprefetch=distance :8,nta" ;;"icc") echo"error:compiler$COMPILERnotsupportedforhostname $HOSTNAME" exit1 ;;*) echo"error:unknowncompiler$COMPILER"exit1 ;; esac ;;"circe") case"$COMPILER"in "gcc") echo"error:compiler$COMPILERnotsupportedforhostname $HOSTNAME" exit1 ;;"pgi") CC="pgcc"CFLAGS="-O3-fastsse-Mipa=fast"EXTRA_LIBS="-L/usr/local/pgi-7.2-5/linux86-64/7.2-5 /libso-lacml-lacml_mv-lacml_mp-lpgmp-lpgftnrtl" ;;"icc") echo"error:compiler$COMPILERnotsupportedforhostname $HOSTNAME" exit1 ;;*) echo"error:unknowncompiler$COMPILER"exit1 esac ;;"dirac") case"$COMPILER"in "gcc") CC="gcc"CFLAGS="-O3-std=c99"EXTRA_LIBS="-L/usr/local/pgi/linux86-64/7.0-6/libso /-lacml-lacml_mv-lacml_mp-lpgmp-lpgftnrtl-lrt" ;;"pgi") CC="pgcc"CFLAGS="-O3-fastsse-Mipa=fast"EXTRA_LIBS="-L/usr/local/pgi/linux86-64/7.0-6/libso /-lacml-lacml_mv-lacml_mp-lpgmp-lpgftnrtl-lrt" ;;"icc") echo"error:compiler$COMPILERnotsupportedforhostname $HOSTNAME" exit1 ;;*) echo"error:unknowncompiler$COMPILER"exit1 esac ;;"time") case"$COMPILER"in "gcc") CC="gcc"CFLAGS="-O3"EXTRA_LIBS="-lm" ;;"pgi") CC="pgcc"CFLAGS="-O3-fastsse-Mipa=fast"EXTRA_LIBS="-L/usr/local/pgi/linux86-64/7.0-6/libso /-lacml-lacml_mv-lacml_mp-lpgmp-lpgftnrtl-lrt" ;;"icc") echo"error:compiler$COMPILERnotsupportedforhostname $HOSTNAME" exit1 ;;*) echo"error:unknowncompiler$COMPILER"exit1 esac 186

PAGE 201

;;"galactic") case"$COMPILER"in "gcc") echo"error:compiler$COMPILERnotsupportedforhostname $HOSTNAME" exit1 ;;"pgi") echo"error:compiler$COMPILERnotsupportedforhostname $HOSTNAME" exit1 ;;"icc") CC="icc"CFLAGS="-O3-prefetch-mp-axP-ip-unroll" ;;*) echo"error:unknowncompiler$COMPILER"exit1 esac ;;"lonestar") case"$COMPILER"in "gcc") echo"error:compiler$COMPILERnotsupportedforhostname $HOSTNAME" exit1 ;;"pgi") echo"error:compiler$COMPILERnotsupportedforhostname $HOSTNAME" exit1 ;;"icc") CC="icc"CFLAGS="-O3-prefetch-mp-ip-unroll" ;;*) echo"error:unknowncompiler$COMPILER"exit1 esac ;;"ranger") case"$COMPILER"in "gcc") echo"error:compiler$COMPILERnotsupportedforhostname $HOSTNAME" exit1 ;;"pgi") CC="pgcc"CFLAGS="-O3-fastsse-tpbarcelona-64" ;;"icc") echo"error:compiler$COMPILERnotsupportedforhostname $HOSTNAME" exit1 ;;*) echo"error:unknowncompiler$COMPILER"exit1 esac ;;"spin") case"$COMPILER"in "gcc") CC="gcc"CFLAGS="-g3-O3" ;;"pgi") CC="pgcc"CFLAGS="-g-O3-fastsse-Mipa=fast" ;;"icc") CC="icc"CFLAGS="-O3-prefetch-mp-axN-ip-unroll" ;;*) echo"error:unknowncompiler$COMPILER"exit1 esac ;;"generic") case"$COMPILER"in "gcc") CC="gcc"CFLAGS="-O3"EXTRA_LIBS="-lm" ;;"pgi") CC="pgcc"CFLAGS="-O3"EXTRA_LIBS="-lm" ;;"icc") CC="icc"CFLAGS="-O3"EXTRA_LIBS="-lm" ;;*) echo"error:unknowncompiler$COMPILER"exit1 esac ;;*) echo"error:unknownhostname$HOSTNAME"exit1 ;; esaccase"$MODE"in "serial") 187

PAGE 202

DEFINES="$DEFINES" ;;"parallel") DEFINES="$DEFINES-DMPI"#handlespecialcasesforparallelizationcase"$HOSTNAME"in "bigben") CC="cc" ;;"dirac") EXTRA_INCLUDES="-I/usr/include/openmpi/1.2.3-gcc"EXTRA_LIBS="-L/usr/lib64/openmpi/1.2.3-gcc-lmpi" ;;"time") EXTRA_INCLUDES="-I/usr/include/openmpi/1.2.3-gcc"EXTRA_LIBS="-L/usr/lib64/openmpi/1.2.3-gcc-lmpi" ;;"spin") EXTRA_INCLUDES="-I/usr/include/openmpi"EXTRA_LIBS="-L/usr/lib64/openmpi-lmpi" ;;*) CC="mpicc" ;; esac ;;*) echo"error:unknownmode,mustbeserialorparallel"exit1 ;; esacecho>Makefileecho"#HOSTNAME=$HOSTNAMECOMPILER=$COMPILERMODE=$MOD EPOLARIZATION_CUDA=$POLARIZATION_CUDAQM_ROTATION=$Q M_ROTATION">>Makefile echo"CC=$CC">>Makefileecho"CFLAGS=$CFLAGS">>Makefileecho"DEFINES=$DEFINES">>Makefileecho"EXTRA_DEFINES=$EXTRA_DEFINES">>Makefileecho"EXTRA_INCLUDES=$EXTRA_INCLUDES">>Makefileecho"EXTRA_LIBS=$EXTRA_LIBS">>Makefileecho"POLARIZATION_CUDA=$POLARIZATION_CUDA">>Makefil e echo"QM_ROTATION=$QM_ROTATION">>Makefileecho>>Makefileecho"includeMakefile.common">>Makefileecho>>Makefile##########################################!!!commonMakefile-DONOTEDIT!!!##########################################BUILD=.TOP=$(BUILD)/..HEADERS=$(TOP)/include/function_prototypes.h$(TOP)/ include/mc.h$(TOP)/include/physical_constants.h$(TO P)/include/structs.h INCLUDES=-I$(TOP)/includeENERGY=$(TOP)/energyIO=$(TOP)/ioMAIN=$(TOP)/mainMC=$(TOP)/mcifeq($(POLARIZATION_CUDA),yes) POLARIZATION=$(TOP)/polarization_cuda else POLARIZATION=$(TOP)/polarization endifHISTOGRAM=$(TOP)/histogramQUANTUM_ROTATION=$(TOP)/quantum_rotationifeq($(QM_ROTATION),yes)all:energy.opairs.opbc.olj.osg.ocoulombic.opolar.ob ond.obessel.o\ input.ooutput.oaverage.ompi.odxwrite.o\main.ocleanup.orng.o\mc.omc_moves.opimc.osurface.ocavity.o\thole_iterative.othole_matrix.othole_field.othole_p olarizability.o\ histogram.o\rotational_eigenspectrum.orotational_basis.orotatio nal_potential.orotational_integrate.o $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(LIBS)$(EX TRA_LIBS)*.o-ompmc elseall:energy.opairs.opbc.olj.osg.ocoulombic.opolar.ob ond.obessel.o\ input.ooutput.oaverage.ompi.odxwrite.o\main.ocleanup.orng.o\mc.omc_moves.opimc.osurface.ocavity.o\thole_iterative.othole_matrix.othole_field.othole_p olarizability.o\ histogram.o$(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(LIBS)$(EX TRA_LIBS)*.o-ompmc endifclean: rm-f*.o*.oo*.ipampmc #energyroutinesenergy:energy.opairs.opbc.olj.osg.ocoulombic.opolar .obond.obessel.o energy.o:$(ENERGY)/energy.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(ENERGY)/energy.c pairs.o:$(ENERGY)/pairs.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(ENERGY)/pairs.c pbc.o:$(ENERGY)/pbc.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(ENERGY)/pbc.c lj.o:$(ENERGY)/lj.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(ENERGY)/lj.c sg.o:$(ENERGY)/sg.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(ENERGY)/sg.c coulombic.o:$(ENERGY)/coulombic.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(ENERGY)/coulombic.c polar.o:$(ENERGY)/polar.c $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(ENERGY)/polar.c 188

PAGE 203

bond.o:$(ENERGY)/bond.c $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(ENERGY)/bond.c bessel.o:$(ENERGY)/bessel.c $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(ENERGY)/bessel.c #input/outputfunctionsio:input.ooutput.oaverage.ompi.odxwrite.oinput.o:$(IO)/input.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(IO)/input.c output.o:$(IO)/output.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(IO)/output.c average.o:$(IO)/average.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(IO)/average.c mpi.o:$(IO)/mpi.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(IO)/mpi.c dxwrite.o:$(IO)/dxwrite.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(IO)/dxwrite.c #mainassociatedthingsmain:main.ocleanup.orng.omain.o:$(MAIN)/main.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(MAIN)/main.c cleanup.o:$(MAIN)/cleanup.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(MAIN)/cleanup.c rng.o:$(MAIN)/rng.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(MAIN)/rng.c #montecarlosubtreemc:mc.omc_moves.opimc.osurface.ocavity.omc.o:$(MC)/mc.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(MC)/mc.c mc_moves.o:$(MC)/mc_moves.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(MC)/mc_moves.c pimc.o:$(MC)/pimc.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(MC)/pimc.c surface.o:$(MC)/surface.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(MC)/surface.c cavity.o:$(MC)/cavity.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(MC)/cavity.c #many-bodypolarizationpolarization:thole_iterative.othole_matrix.othole_f ield.othole_polarizability.o thole_iterative.o:$(POLARIZATION)/thole_iterative.c $(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(POLARIZATION)/thole_iterative. c thole_matrix.o:$(POLARIZATION)/thole_matrix.c$(HEAD ERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(POLARIZATION)/thole_matrix.c thole_field.o:$(POLARIZATION)/thole_field.c$(HEADER S) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(POLARIZATION)/thole_field.c thole_polarizability.o:$(POLARIZATION)/thole_polari zability.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(POLARIZATION)/thole_polarizabi lity.c #3Dhistogramshistogram:histogram.ohistogram.o:$(HISTOGRAM)/histogram.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(HISTOGRAM)/histogram.c ifeq($(QM_ROTATION),yes)#quantumrotationaldiagonalizationquantum_rotation:rotational_eigenspectrum.orotation al_basis.orotational_potential.orotational_integrat e.o rotational_eigenspectrum.o:$(QUANTUM_ROTATION)/rota tional_eigenspectrum.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(QUANTUM_ROTATION)/rotational_e igenspectrum.c rotational_basis.o:$(QUANTUM_ROTATION)/rotational_b asis.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(QUANTUM_ROTATION)/rotational_b asis.c rotational_potential.o:$(QUANTUM_ROTATION)/rotation al_potential.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(QUANTUM_ROTATION)/rotational_p otential.c rotational_integrate.o:$(QUANTUM_ROTATION)/rotation al_integrate.c$(HEADERS) $(CC)$(CFLAGS)$(DEFINES)$(EXTRA_DEFINES)$(INCLUDES) $(EXTRA_INCLUDES)-c$(QUANTUM_ROTATION)/rotational_i ntegrate.c endif#include/*returnsthemodifiedBesselKfunctionoffractionalorde r*/ /*wrapperfortheNRroutine*/doublebesselK(doubleorder,doublex){ floatfunction_value_i,function_value_k;floatrip,rpk;bessik((float)x,(float)order,&function_value_i,&fun ction_value_k,&rip,&rpk); return((double)function_value_k); }floatchebev(floata,floatb,floatc[],intm,floatx){ voidnrerror(charerror_text[]);floatd=0.0,dd=0.0,sv,y,y2;intj;if((x-a)*(x-b)>0.0)return(-1);y2=2.0*(y=(2.0*x-a-b)/(b-a));for(j=m-1;j>=1;j--){ sv=d;d=y2*d-dd+c[j];dd=sv; }returny*d-dd+0.5*c[0]; }#defineNUSE15#defineNUSE25 189

PAGE 204

voidbeschb(doublex,double*gam1,double*gam2,double*g ampl,double*gammi) { floatchebev(floata,floatb,floatc[],intm,floatx);floatxx;staticfloatc1[]={ -1.142022680371172e0,6.516511267076e-3,3.08709017308e-4,-3.470626964e-6,6.943764e-9,3.6780e-11,-1.36e-13}; staticfloatc2[]={ 1.843740587300906e0,-0.076852840844786e0,1.271927136655e-3,-4.971736704e-6,-3.3126120e-8,2.42310e-10,-1.70e-13,-1.0e-15}; xx=8.0*x*x-1.0;*gam1=chebev(-1.0,1.0,c1,NUSE1,xx);*gam2=chebev(-1.0,1.0,c2,NUSE2,xx);*gampl=*gam2-x*(*gam1);*gammi=*gam2+x*(*gam1); }#undefNUSE1#undefNUSE2#include#defineEPS1.0e-10#defineFPMIN1.0e-30#defineMAXIT10000#defineXMIN2.0#definePI3.141592653589793/*returnserrorstatus*/intbessik(floatx,floatxnu,float*ri,float*rk,float*r ip,float*rkp) { inti,l,nl;doublea,a1,b,c,d,del,del1,delh,dels,e,f,fact,fact2, ff,gam1,gam2, gammi,gampl,h,p,pimu,q,q1,q2,qnew,ril,ril1,rimu,rip 1,ripl, ritemp,rk1,rkmu,rkmup,rktemp,s,sum,sum1,x2,xi,xi2,x mu,xmu2; if(x<=0.0||xnu<0.0)return(-1);nl=(int)(xnu+0.5);xmu=xnu-nl;xmu2=xmu*xmu;xi=1.0/x;xi2=2.0*xi;h=xnu*xi;if(hMAXIT)return(-1);ril=FPMIN;ripl=h*ril;ril1=ril;rip1=ripl;fact=xnu*xi;for(l=nl;l>=1;l--){ ritemp=fact*ril+ripl;fact-=xi;ripl=fact*ritemp+ril;ril=ritemp; }f=ripl/ril;if(xMAXIT)return(-1);rkmu=sum;rk1=sum1*xi2; }else{ b=2.0*(1.0+x);d=1.0/b;h=delh=d;q1=0.0;q2=1.0;a1=0.25-xmu2; 190

PAGE 205

q=c=a1;a=-a1;s=1.0+q*delh;for(i=2;i<=MAXIT;i++){ a-=2*(i-1);c=-a*c/i;qnew=(q1-b*q2)/a;q1=q2;q2=qnew;q+=c*qnew;b+=2.0;d=1.0/(b+a*d);delh=(b*d-1.0)*delh;h+=delh;dels=q*delh;s+=dels;if(fabs(dels/s)MAXIT)return(-1);h=a1*h;rkmu=sqrt(PI/(2.0*x))*exp(-x)/s;rk1=rkmu*(xmu+x+0.5-h)*xi; }rkmup=xmu*xi*rkmu-rk1;rimu=xi/(f*rkmu-rkmup);*ri=(rimu*ril1)/ril;*rip=(rimu*rip1)/ril;for(i=1;i<=nl;i++){ rktemp=(xmu+i)*xi2*rk1+rkmu;rkmu=rk1;rk1=rktemp; }*rk=rkmu;*rkp=xnu*xi*rkmu-rk1;return(0); }#undefEPS#undefFPMIN#undefMAXIT#undefXMIN#undefPI/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include/*energyofmoleculeina1Danharmonicwell*/doubleanharmonic(system_t*system){ doublek,g,x;doubleenergy;molecule_t*molecule_ptr;atom_t*atom_ptr;k=system->rd_anharmonic_k;g=system->rd_anharmonic_g;energy=0;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ x=atom_ptr->pos[0];energy+=anharmonic_energy(k,g,x);if(system->feynman_hibbs){ if(system->feynman_kleinert){ energy=anharmonic_fk(system->temperature,atom_ptr-> mass,k,g,x); }else{ if(system->feynman_hibbs_order==2) energy+=anharmonic_fh_second_order(system->temperat ure,atom_ptr->mass,k,g,x); elseif(system->feynman_hibbs_order==4) energy+=anharmonic_fh_fourth_order(system->temperat ure,atom_ptr->mass,k,g,x); } } } }return(energy); }/*Feynman-Kleinertiterativemethodofeffectivepotenti al*/ doubleanharmonic_fk(doubletemperature,doublemass,do ublek,doubleg,doublex){ intkeep_iterating;doublea_sq;/*widtha^2(A^2)*/doubleomega,omega_sq;/*spacingOmega^2(K/A^2)*/ 191

PAGE 206

doubleprev_a_sq;/*lasta_sq*/doubletolerance;/*iterativetolerance*/doubleV_a;/*V_a^2(K)*/doublepotential;/*W_1(K)*/doubleconversion_factor;/*hbar^2*(m2A)^2/(k*m)*//*convertthemasstokg*/mass*=AMU2KG;conversion_factor=pow(METER2ANGSTROM,2.0)*pow(HBAR, 2.0)/(KB*mass); /*initialguessa^2=beta/12*/a_sq=pow(METER2ANGSTROM,2.0)*pow(HBAR,2.0)/(12.0*KB *temperature*mass); /*solveself-consistently*/keep_iterating=1;while(keep_iterating){ /*savethelasta_sqfortolerance*/prev_a_sq=a_sq;omega_sq=conversion_factor*(k+3.0*g*a_sq+3.0*g*pow( x,2.0));omega=sqrt(omega_sq); a_sq=conversion_factor*(temperature/omega_sq)*((ome ga/(2.0*temperature))*(1.0/tanh(omega/(2.0*temperat ure)))-1.0); tolerance=fabs(prev_a_sq-a_sq);if(tolerance
PAGE 207

}/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include/*totalESenergyterm*/doublecoulombic(system_t*system){ molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;doublereal,reciprocal;doublepotential;/*constructtherelevantewaldterms*/real=coulombic_real(system);reciprocal=coulombic_reciprocal(system);/*returnthetotalelectrostaticenergy*/potential=real+reciprocal;return(potential); }/*fourierspacesum*/doublecoulombic_reciprocal(system_t*system){ molecule_t*molecule_ptr;atom_t*atom_ptr;intq,p;intkmax;doublealpha;doublel[3],k[3],k_squared,norm;doublegaussian,position_product;doubleSF_real,SF_imaginary;/*structurefactor*/doublerecip_potential,self_potential,potential;alpha=system->ewald_alpha;kmax=system->ewald_kmax;recip_potential=0;self_potential=0;/*performthefouriersumoverthereciprocallatticeforea chparticle*/ for(l[0]=0;l[0]<=kmax;l[0]++){ for(l[1]=(!l[0]?0:-kmax);l[1]<=kmax;l[1]++){ for(l[2]=((!l[0]&&!l[1])?1:-kmax);l[2]<=kmax;l[2]++ ){ /*comparethenorm*/for(p=0,norm=0;p<3;p++) norm+=l[p]*l[p]; /*getthereciprocallatticevectors*/for(p=0,k_squared=0;p<3;p++){ for(q=0,k[p]=0;q<3;q++) k[p]+=system->pbc->reciprocal_basis[p][q]*2.0*M_PI* ((double)l[q]); k_squared+=k[p]*k[p]; }/*makesurewearewithink-max*/if((norm<=kmax*kmax)&&(k_squared>0.0)){ gaussian=exp(-k_squared/(4.0*alpha*alpha))/k_square d; /*structurefactor*/SF_real=0;SF_imaginary=0;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ if(!atom_ptr->frozen){ /*theinnerproductofthepositionvectorandthekvector*/for(p=0,position_product=0;p<3;p++) position_product+=k[p]*atom_ptr->pos[p]; SF_real+=atom_ptr->charge*cos(position_product);SF_imaginary+=atom_ptr->charge*sin(position_product ); /*includetheself-interactionterm*//*thisonlyneedtohappenonce,onthefirstk-vec*/if(!l[0]&&!l[1]&&(l[2]==1)){ atom_ptr->es_self_point_energy= alpha*atom_ptr->charge*atom_ptr->charge/sqrt(M_PI); self_potential+=atom_ptr->es_self_point_energy; } }/*!frozen*/ }/*atom*/ }/*molecule*/recip_potential+=gaussian*(SF_real*SF_real+SF_imagi nary*SF_imaginary); }/*endifnorm*/ }/*endforn*/ }/*endform*/ }/*endforl*/ 193

PAGE 208

recip_potential*=4.0*M_PI/system->pbc->volume;potential=recip_potential-self_potential;return(potential); }/*realspacesum*/doublecoulombic_real(system_t*system){ molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;doublealpha,r,erfc_term,gaussian_term;doublepotential;doublepotential_classical,potential_fh_second_order ,potential_fh_fourth_order; doublefirst_derivative,second_derivative,third_deri vative,fourth_derivative; doublereduced_mass;alpha=system->ewald_alpha;potential=0;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next){ if(pair_ptr->recalculate_energy){ pair_ptr->es_real_energy=0;if(!pair_ptr->frozen){ r=pair_ptr->rimg;if(!((r>system->pbc->cutoff)||pair_ptr->es_excluded )){/*unitcellpart*/ erfc_term=erfc(alpha*r);gaussian_term=exp(-alpha*alpha*r*r);potential_classical=atom_ptr->charge*pair_ptr->char ge*erfc_term/r; pair_ptr->es_real_energy+=potential_classical;if(system->feynman_hibbs){ reduced_mass= AMU2KG*molecule_ptr->mass*pair_ptr->molecule->mass/ (molecule_ptr->mass+pair_ptr->molecule->mass); /*FIRSTDERIVATIVE*/first_derivative=-2.0*alpha*gaussian_term/(r*sqrt(M _PI))erfc_term/(r*r); /*SECONDDERIVATIVE*/second_derivative=(4.0/sqrt(M_PI))*gaussian_term*(p ow(alpha,3.0)+pow(r, -2.0)); second_derivative+=2.0*erfc_term/pow(r,3.0);potential_fh_second_order=pow(METER2ANGSTROM, 2.0)*(HBAR*HBAR/(24.0*KB*system->temperature*reduce d_mass))*(second_derivative+2.0*first_derivative/r) ; pair_ptr->es_real_energy+=potential_fh_second_order ; if(system->feynman_hibbs_order>=4){ /*THIRDDERIVATIVE*/third_derivative=(gaussian_term/sqrt(M_PI))*(-8.0*p ow(alpha, 5.0)*r-8.0*pow(alpha,3.0)/r-12.0*alpha/pow(r,3.0)); third_derivative-=6.0*erfc(alpha*r)/pow(r,4.0);/*FOURTHDERIVATIVE*/fourth_derivative=(gaussian_term/sqrt(M_PI))*(8.0*p ow(alpha,5.0) +16.0*pow(alpha,7.0)*r*r+32.0*pow(alpha,3.0)/pow(r, 2.0)+48.0/pow(r,4.0)); fourth_derivative+=24.0*erfc_term/pow(r,5.0);potential_fh_fourth_order=pow(METER2ANGSTROM,4.0)*( pow(HBAR, 4.0)/(1152.0*pow(KB*system->temperature*reduced_mas s,2.0)))*(15.0*first_derivative/pow(r,3.0)+4.0*thir d_derivative/r+ fourth_derivative); pair_ptr->es_real_energy+=potential_fh_fourth_order ; } } }elseif(pair_ptr->es_excluded)/*calculatetheself-in trapart*/ pair_ptr->es_self_intra_energy= atom_ptr->charge*pair_ptr->charge*erf(alpha*pair_pt r->r)/pair_ptr->r; }/*frozen*/ }/*recalculate*//*sumallofthepairwiseterms*/potential+=pair_ptr->es_real_energy-pair_ptr->es_se lf_intra_energy; }/*pair*/ }/*atom*/ }/*molecule*/return(potential); }/*noewaldsummation-regularaccumulationofCoulombicte rmswithoutoutconsiderationofPBC*/ /*onlyusedbysurfacemodule*/doublecoulombic_nopbc(molecule_t*molecules){ molecule_t*molecule_ptr; 194

PAGE 209

atom_t*atom_ptr;pair_t*pair_ptr;doublepe,total_pe;total_pe=0;for(molecule_ptr=molecules;molecule_ptr;molecule_pt r=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next){ if(!pair_ptr->es_excluded){ pe=atom_ptr->charge*pair_ptr->charge/pair_ptr->r;total_pe+=pe; } } } }return(total_pe); }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include/*returnsthetotalpotentialenergyforthesystemandupda tesourobservables*/ doubleenergy(system_t*system){ atom_t*atom_ptr;molecule_t*molecule_ptr;doublepotential_energy,rd_energy,coulombic_energy,p olar_energy; /*zerotheinitialvalues*/potential_energy=0;rd_energy=0;coulombic_energy=0;polar_energy=0;/*gettheperiodicboundaryconditions*/if(system->wpi||system->fvm)pbc(system->pbc);/*doth iseachtimeonlyforfvmandwpi*/ /*getthepairwisetermsnecessaryfortheenergycalculati on*/ pairs(system);/*onlyonthefirstsimulationstep,makesurethatallrecal culateflagsareset*/ if(system->observables->energy==0.0)flag_all_pairs( system); /*gettherepulsion/dispersionpotential*/if(system->rd_anharmonic) rd_energy=anharmonic(system); elseif(system->sg) rd_energy=sg(system); else rd_energy=lj(system); system->observables->rd_energy=rd_energy;/*gettheelectrostaticpotential*/if(!(system->sg||system->rd_only)){ coulombic_energy=coulombic(system);system->observables->coulombic_energy=coulombic_ene rgy; /*getthepolarizationpotential*/if(system->polarization){ polar_energy=polar(system);system->observables->polarization_energy=polar_ener gy; } }/*sumthetotalpotentialenergy*/potential_energy=rd_energy+coulombic_energy+polar_e nergy; system->observables->energy=potential_energy;/*countthenumberofmoleculescurrentlyinthesystem*/for(molecule_ptr=system->molecules,system->observab les->N=0;molecule_ptr;molecule_ptr=molecule_ptr->ne xt){ if(!(molecule_ptr->frozen||molecule_ptr->adiabatic) )system->observables->N+=1.0; if(system->ensemble==ENSEMBLE_NVE)system->N=system>observables->N; }/*forNVE*/if(system->ensemble==ENSEMBLE_NVE){ system->observables->kinetic_energy=system->total_e nergy-potential_energy; system->observables->temperature=(2.0/3.0)*system-> observables->kinetic_energy/system->observables->N; }/*SA*/if(system->simulated_annealing) system->observables->temperature=system->temperatur e; /*needthisfortheisostericheat*/system->observables->NU=system->observables->N*syst em->observables->energy; 195

PAGE 210

return(potential_energy); }/*returnsthetotalpotentialenergyforthesystem*//*thisfunctionismeanttobecalledbyroutinesthatdonot* / /*requireobservablestobeaveragedin,i.e.quantuminteg ration*/ /*routines,widominsertion,etc.*/doubleenergy_no_observables(system_t*system){ atom_t*atom_ptr;molecule_t*molecule_ptr;doublepotential_energy,rd_energy,coulombic_energy,p olar_energy; /*zerotheinitialvalues*/potential_energy=0;rd_energy=0;coulombic_energy=0;polar_energy=0;/*gettheperiodicboundaryconditions*/if(system->wpi||system->fvm)pbc(system->pbc);/*doth iseachtimeonlyforfvmandwpi*/ /*getthepairwisetermsnecessaryfortheenergycalculati on*/ pairs(system);/*gettherepulsion/dispersionpotential*/if(system->sg) rd_energy=sg(system); else rd_energy=lj(system); /*gettheelectrostaticpotential*/if(!(system->sg||system->rd_only)){ coulombic_energy=coulombic(system);/*getthepolarizationpotential*/if(system->polarization) polar_energy=polar(system); }/*sumthetotalpotentialenergy*/potential_energy=rd_energy+coulombic_energy+polar_e nergy; return(potential_energy); }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include/*Lennard-Jonesrepulsion/dispersion*/doublelj(system_t*system){ molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;doublesigma_over_r,term12,term6;doublefirst_derivative,second_derivative,third_deri vative,fourth_derivative; doublepotential,potential_classical,potential_fh_se cond_order,potential_fh_fourth_order; doublereduced_mass;doublesig3,sig_cut,sig_cut3,sig_cut9;potential=0;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next){ if(pair_ptr->recalculate_energy){ pair_ptr->rd_energy=0;/*makesurewe'renotexcludedorbeyondthecutoff*/if(!((pair_ptr->rimg>system->pbc->cutoff)||pair_ptr ->rd_excluded||pair_ptr->frozen)){ sigma_over_r=pair_ptr->sigma/pair_ptr->rimg;/*theLJpotential*/term6=pow(sigma_over_r,6.0);term6*=system->scale_rd;term12=pow(term6,2.0);potential_classical=4.0*pair_ptr->epsilon*(term12-t erm6); pair_ptr->rd_energy+=potential_classical;if(system->feynman_hibbs){ reduced_mass= AMU2KG*molecule_ptr->mass*pair_ptr->molecule->mass/ (molecule_ptr->mass+pair_ptr->molecule->mass); /*FIRSTDERIVATIVE*/first_derivative=-24.0*pair_ptr->epsilon*(2.0*term1 2-term6)/pair_ptr->rimg; 196

PAGE 211

/*SECONDDERIVATIVE*/second_derivative=24.0*pair_ptr->epsilon*(26.0*term 127.0*term6)/pow(pair_ptr->rimg,2.0); potential_fh_second_order=pow(METER2ANGSTROM, 2.0)*(HBAR*HBAR/(24.0*KB*system->temperature*reduce d_mass))*(second_derivative+2.0*first_derivative/pa ir_ptr->rimg); pair_ptr->rd_energy+=potential_fh_second_order;if(system->feynman_hibbs_order>=4){ /*THIRDDERIVATIVE*/third_derivative=-1344.0*pair_ptr->epsilon*(6.0*ter m12term6)/pow(pair_ptr->rimg,3.0); /*FOURTHDERIVATIVE*/fourth_derivative=12096.0*pair_ptr->epsilon*(10.0*t erm12term6)/pow(pair_ptr->rimg,4.0); potential_fh_fourth_order=pow(METER2ANGSTROM,4.0)*( pow(HBAR, 4.0)/(1152.0*pow(KB*system->temperature*reduced_mas s,2.0)))*(15.0*first_derivative/pow(pair_ptr->rimg, 3.0)+ 4.0*third_derivative/pair_ptr->rimg+fourth_derivati ve); pair_ptr->rd_energy+=potential_fh_fourth_order; } }/*causeanautorejectoninsertionscloserthan0.5*sigma* / if(system->cavity_autoreject){ if(pair_ptr->rimgcavity_autoreject_scale*p air_ptr->sigma) pair_ptr->rd_energy=MAXVALUE; } }/*includethelong-rangecorrection*/if(!(pair_ptr->rd_excluded||pair_ptr->frozen)&&(pai r_ptr->lrc==0.0)&&system->rd_lrc){ sig_cut=pair_ptr->sigma/system->pbc->cutoff;sig3=pow(pair_ptr->sigma,3.0);sig_cut3=pow(sig_cut,3.0);sig_cut9=pow(sig_cut,9.0);pair_ptr->lrc=((16.0/3.0)*M_PI*pair_ptr->epsilon*si g3)*((1.0/3.0)*sig_cut9sig_cut3)/system->pbc->volume; } }/*ifrecalculate*//*sumallofthepairwiseterms*/potential+=pair_ptr->rd_energy+pair_ptr->lrc; }/*pair*/ }/*atom*/ }/*molecule*/return(potential); }/*sameasabove,butnoperiodicboundaryconditions*/doublelj_nopbc(molecule_t*molecules){ molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;doublesigma_over_r,term12,term6;doublepotential;for(molecule_ptr=molecules,potential=0;molecule_ptr ;molecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next){ /*makesurewe'renotexcludedorbeyondthecutoff*/if(!pair_ptr->rd_excluded){ sigma_over_r=pair_ptr->sigma/pair_ptr->r;/*theLJpotential*/term6=pow(sigma_over_r,6.0);term12=pow(term6,2.0);potential+=4.0*pair_ptr->epsilon*(term12-term6); } }/*pair*/ }/*atom*/ }/*molecule*/return(potential); }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include 197

PAGE 212

/*flagallpairstohavetheirenergycalculated*//*needstobecalledatsimulationstart,orcan*//*becalledtoperiodicallykeepthetotalenergy*//*fromdrifting*/voidflag_all_pairs(system_t*system){ molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next) for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next) for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next) pair_ptr->recalculate_energy=1; }/*settheexclusionsandLJmixingforrelevantpairs*/voidpair_exclusions(system_t*system,molecule_t*mole cule_i,molecule_t*molecule_j,atom_t*atom_i,atom_t*a tom_j,pair_t*pair_ptr){ /*recalculateexclusions*/if(molecule_i==molecule_j){/*ifbothonsamemolecule,e xcludeallinteractions*/ pair_ptr->rd_excluded=1;pair_ptr->es_excluded=1; }else{ /*excludenullrepulsion/dispersioninterations*/if((atom_i->epsilon==0.0)||(atom_i->sigma==0.0)||(a tom_j->epsilon==0.0)||(atom_j->sigma==0.0)) pair_ptr->rd_excluded=1; else pair_ptr->rd_excluded=0; /*excludenullelectrostaticinteractions*/if((atom_i->charge==0.0)||(atom_j->charge==0.0)) pair_ptr->es_excluded=1; else pair_ptr->es_excluded=0; }/*getthefrozeninteractions*/pair_ptr->frozen=atom_i->frozen&&atom_j->frozen;/*getthemixedLJparameters*/if(!system->sg){ /*Lorentz-Berthelotmixingrules*/pair_ptr->sigma=0.5*(atom_i->sigma+atom_j->sigma);pair_ptr->epsilon=sqrt(atom_i->epsilon*atom_j->epsi lon); /*gettheneighborcharge*/pair_ptr->charge=atom_j->charge;/*gettheneighborpolarizability*/pair_ptr->polarizability=atom_j->polarizability; }/*setthelink*/pair_ptr->atom=atom_j;pair_ptr->molecule=molecule_j; }/*performthemodulominimumimagefordisplacements*/voidminimum_image(system_t*system,atom_t*atom_i,ato m_t*atom_j,pair_t*pair_ptr){ intp,q;doubleimg[3];doubled[3],r,r2;doubledi[3],ri,ri2;/*gettherealdisplacement*/pair_ptr->recalculate_energy=0;/*resettherecalculat eflag*/ for(p=0;p<3;p++){ d[p]=atom_i->pos[p]-atom_j->pos[p];pair_ptr->d[p]=d[p];/*thispairchangedandsoitwillhaveit'senergyrecalcula ted*/ if(pair_ptr->d[p]!=pair_ptr->d_prev[p]){ pair_ptr->recalculate_energy=1;pair_ptr->d_prev[p]=pair_ptr->d[p];/*reset*/ } }/*matrixmultiplywiththeinversebasisandround*/for(p=0;p<3;p++){ for(q=0,img[p]=0;q<3;q++){ img[p]+=system->pbc->reciprocal_basis[p][q]*d[q]; }img[p]=rint(img[p]); }/*matrixmultiplytoprojectbackintoourbasis*/for(p=0;p<3;p++) for(q=0,di[p]=0;q<3;q++) di[p]+=system->pbc->basis[p][q]*img[q]; 198

PAGE 213

/*nowcorrectthedisplacement*/for(p=0;p<3;p++) di[p]=d[p]-di[p]; /*pythagoreanterms*/for(p=0,r2=0,ri2=0;p<3;p++){ r2+=d[p]*d[p];ri2+=di[p]*di[p]; }r=sqrt(r2);ri=sqrt(ri2);/*storetheresultsforthispair*/pair_ptr->r=r;pair_ptr->rimg=ri;for(p=0;p<3;p++) pair_ptr->dimg[p]=di[p]; /*storethe3rdand5thpowersforAmatrixstuff*/if(system->polarization){ pair_ptr->r2=r*r;pair_ptr->r3=r*r*r;pair_ptr->r5=pair_ptr->r3*r*r;pair_ptr->r2img=ri*ri;pair_ptr->r3img=ri*ri*ri;pair_ptr->r5img=pair_ptr->r3img*ri*ri; } }/*updateeverythingnecessarytodescribethecompletepai rwisesystem*/ voidpairs(system_t*system){ inti,j,n;molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;molecule_t**molecule_array;atom_t**atom_array;/*neededforGSrankingmetric*/intp;doubler,rmin;/*generateanarrayofatomptrs*/for(molecule_ptr=system->molecules,n=0,atom_array=N ULL,molecule_array=NULL;molecule_ptr;molecule_ptr= molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next,n++){ molecule_array=realloc(molecule_array,sizeof(molecu le_t*)*(n+1)); molecule_array[n]=molecule_ptr;atom_array=realloc(atom_array,sizeof(atom_t*)*(n+1) ); atom_array[n]=atom_ptr; } }/*loopoverallatomsandpair*/for(i=0;i<(n-1);i++){ for(j=(i+1),pair_ptr=atom_array[i]->pairs;jnext){ /*setanynecessaryexclusions*/pair_exclusions(system,molecule_array[i],molecule_a rray[j],atom_array[i],atom_array[j],pair_ptr); /*gettheminimumimagedisplacement*/minimum_image(system,atom_array[i],atom_array[j],pa ir_ptr); }/*forj*/ }/*fori*//*updatethecomofeachmolecule*/update_com(system->molecules);/*storewrappedcoords*/wrapall(system->molecules,system->pbc);/*rankmetric*/if(system->polar_iterative&&system->polar_gs_ranked ){ /*determinesmallestpolarizableseparation*/rmin=MAXVALUE;for(i=0;ipolarizability!=0.0)&&(a tom_array[j]->polarizability!=0.0)){ for(p=0,r=0;p<3;p++) r+=pow((atom_array[i]->wrapped_pos[p]-atom_array[j] ->wrapped_pos[p]),2.0); r=sqrt(r);if(rrank_metric=0;for(j=0;jpolarizability!=0.0)&&(a tom_array[j]->polarizability!=0.0)){ for(p=0,r=0;p<3;p++) r+=pow((atom_array[i]->wrapped_pos[p]-atom_array[j] ->wrapped_pos[p]),2.0); 199

PAGE 214

r=sqrt(r);if(r<=1.5*rmin) atom_array[i]->rank_metric+=1.0; } } } } /*freeourtemporaryarrays*/free(atom_array); free(molecule_array); }/*molecularcenterofmass*/voidupdate_com(molecule_t*molecules){ inti;molecule_t*molecule_ptr;atom_t*atom_ptr;for(molecule_ptr=molecules;molecule_ptr;molecule_pt r=molecule_ptr->next){ for(i=0;i<3;i++) molecule_ptr->com[i]=0; for(atom_ptr=molecule_ptr->atoms,molecule_ptr->mass =0;atom_ptr;atom_ptr=atom_ptr->next){ molecule_ptr->mass+=atom_ptr->mass;for(i=0;i<3;i++) molecule_ptr->com[i]+=atom_ptr->mass*atom_ptr->pos[ i]; }for(i=0;i<3;i++) molecule_ptr->com[i]/=molecule_ptr->mass; } }/*addnewpairsforwhenanewmoleculeiscreated*/voidupdate_pairs_insert(system_t*system){ inti,n;molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;/*countthenumberofatomspermolecule*/for(atom_ptr=system->checkpoint->molecule_altered-> atoms,n=0;atom_ptr;atom_ptr=atom_ptr->next,n++); /*addnnumberofpairstoalteredandallmoleculesaheadofi tinthelist*/ for(molecule_ptr=system->molecules;molecule_ptr!=sy stem->checkpoint->tail;molecule_ptr=molecule_ptr->n ext){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ /*gototheendofthepairlist*/if(atom_ptr->pairs){ /*gototheendofthepairlist*/for(pair_ptr=atom_ptr->pairs;pair_ptr->next;pair_pt r=pair_ptr->next); /*tagontheextrapairs*/for(i=0;inext=calloc(1,sizeof(pair_t));pair_ptr=pair_ptr->next; } }else{ /*needsanewlist*/atom_ptr->pairs=calloc(1,sizeof(pair_t));pair_ptr=atom_ptr->pairs;for(i=0;i<(n-1);i++){ pair_ptr->next=calloc(1,sizeof(pair_t));pair_ptr=pair_ptr->next; } } }/*foratom*/ }/*formolecule*/ }/*removepairswhenamoleculeisdeleted*/voidupdate_pairs_remove(system_t*system){ inti,n,m;molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr,**pair_array;/*countthenumberofatomspermolecule*/for(atom_ptr=system->checkpoint->molecule_backup->a toms,n=0;atom_ptr;atom_ptr=atom_ptr->next,n++); /*removennumberofpairsforallmoleculesaheadoftheremo valpoint*/ 200

PAGE 215

pair_array=calloc(1,sizeof(pair_t*));for(molecule_ptr=system->molecules;molecule_ptr!=sy stem->checkpoint->tail;molecule_ptr=molecule_ptr->n ext){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ /*buildthepairpointerarray*/for(pair_ptr=atom_ptr->pairs,m=0;pair_ptr;pair_ptr= pair_ptr->next,m++){ pair_array=realloc(pair_array,sizeof(pair_t*)*(m+1) ); pair_array[m]=pair_ptr; }for(i=(m-n);i0) pair_array[(m-n-1)]->next=NULL; else atom_ptr->pairs=NULL; } }/*freeourtemporaryarray*/free(pair_array); }/*ifaninsertmoveisrejected,removethepairsthatwerepr eviouslyadded*/ voidunupdate_pairs_insert(system_t*system){ inti,n,m;molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr,**pair_array;/*countthenumberofatomspermolecule*/for(atom_ptr=system->checkpoint->molecule_altered-> atoms,n=0;atom_ptr;atom_ptr=atom_ptr->next) ++n; /*removennumberofpairsforallmoleculesaheadoftheremo valpoint*/ pair_array=calloc(1,sizeof(pair_t*));for(molecule_ptr=system->molecules;molecule_ptr!=sy stem->checkpoint->tail;molecule_ptr=molecule_ptr->n ext){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ /*buildthepairpointerarray*/for(pair_ptr=atom_ptr->pairs,m=0;pair_ptr;pair_ptr= pair_ptr->next,m++){ pair_array=realloc(pair_array,sizeof(pair_t*)*(m+1) ); pair_array[m]=pair_ptr; }for(i=(m-n);i0) pair_array[(m-n-1)]->next=NULL; else atom_ptr->pairs=NULL; } }/*freeourtemporaryarray*/free(pair_array); }/*ifaremoveisrejected,thenaddbackthepairsthatwerepr eviouslydeleted*/ voidunupdate_pairs_remove(system_t*system){ inti,n;molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;/*countthenumberofatomspermolecule*/for(atom_ptr=system->checkpoint->molecule_backup->a toms,n=0;atom_ptr;atom_ptr=atom_ptr->next) ++n; /*addnnumberofpairstoalteredandallmoleculesaheadofi tinthelist*/ for(molecule_ptr=system->molecules;molecule_ptr!=sy stem->checkpoint->molecule_backup;molecule_ptr=mole cule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ /*gototheendofthepairlist*/if(atom_ptr->pairs){ /*gototheendofthepairlist*/for(pair_ptr=atom_ptr->pairs;pair_ptr->next;pair_pt r=pair_ptr->next); /*tagontheextrapairs*/for(i=0;inext=calloc(1,sizeof(pair_t));pair_ptr=pair_ptr->next; } }else{ /*needsanewlist*/atom_ptr->pairs=calloc(1,sizeof(pair_t));pair_ptr=atom_ptr->pairs; 201

PAGE 216

for(i=0;i<(n-1);i++){ pair_ptr->next=calloc(1,sizeof(pair_t));pair_ptr=pair_ptr->next; } } }/*foratom*/ }/*formolecule*/ }/*allocatethepairlists*/voidsetup_pairs(molecule_t*molecules){ inti,j,n;molecule_t*molecule_ptr,**molecule_array;atom_t*atom_ptr,**atom_array;pair_t*pair_ptr,*prev_pair_ptr;/*generateanarrayofatomptrs*/for(molecule_ptr=molecules,n=0,atom_array=NULL,mole cule_array=NULL;molecule_ptr;molecule_ptr=molecule_ ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ atom_array=realloc(atom_array,sizeof(atom_t*)*(n+1) ); atom_array[n]=atom_ptr;molecule_array=realloc(molecule_array,sizeof(molecu le_t*)*(n+1)); molecule_array[n]=molecule_ptr;++n; } }/*setupthepairs,lowertriangular*/for(i=0;i<(n-1);i++){ atom_array[i]->pairs=calloc(1,sizeof(pair_t));pair_ptr=atom_array[i]->pairs;prev_pair_ptr=pair_ptr;for(j=(i+1);jnext=calloc(1,sizeof(pair_t));prev_pair_ptr=pair_ptr;pair_ptr=pair_ptr->next; }prev_pair_ptr->next=NULL;free(pair_ptr); } }#ifdefDEBUGvoidtest_pairs(molecule_t*molecules){ molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;for(molecule_ptr=molecules;molecule_ptr;molecule_pt r=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next){ if(!(pair_ptr->frozen||pair_ptr->rd_excluded||pair_ ptr->es_excluded))printf("%d:charge=%f,epsilon= %f,sigma=%f,r=%f,rimg=%f\n",atom_ptr->id,pair_ptr-> charge,pair_ptr->epsilon,pair_ptr->sigma,pair_ptr-> r, pair_ptr->rimg);fflush(stdout); } } } }#endif/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include/*calculatetheminimumcutoffradiusfromthebasislattic e*/ /*generalizedtohandleskewedunitcells*//*thereismostlikelyamoreelegantwaytofindthis*/doublepbc_cutoff(pbc_t*pbc){ intp,q;intv1,v2;/*anytwobasisvectors*/doublev1_magnitude;/*magnitudeofthefirstbasis*/doublecomponent;/*thetermsa*a+b*a*/doubler_vector[3],r_magnitude;/*thenewvector*/doublermin[3];/*theradialcutoffforeachbasispair*/doublecutoff;/*theminimalcutoff*//*foreachpairofbasisvectors*/for(p=0;p<3;p++){ 202

PAGE 217

/*theuniquebasispairsformingtheparallelogram*/v1=p;v2=(p+1)%3;/*calculatethefirstbasismagnitude*/v1_magnitude=0;for(q=0;q<3;q++){ v1_magnitude+=pbc->basis[v1][q]*pbc->basis[v1][q]; }v1_magnitude=sqrt(v1_magnitude);/*computevectorcomponentsofaa+ba*/component=0;for(q=0;q<3;q++){ component+=pbc->basis[v1][q]*pbc->basis[v1][q];component+=pbc->basis[v2][q]*pbc->basis[v1][q]; }component/=v1_magnitude;/*finally,thervectoritself*//*r=1/2[a+b-(aa+ba)a]*/r_magnitude=0;for(q=0;q<3;q++){ r_vector[q]=pbc->basis[v1][q]+pbc->basis[v2][q];r_vector[q]-=component*pbc->basis[v1][q]/v1_magnitu de; r_vector[q]*=0.5;r_magnitude+=r_vector[q]*r_vector[q]; }r_magnitude=sqrt(r_magnitude);/*storetheresultforthisparallelogram-sortitoutwhend one*/ rmin[p]=r_magnitude; }/*sortoutthesmallestradialcutoff*/cutoff=MAXVALUE;for(p=0;p<3;p++) if(rmin[p]basis[0][0]*(pbc->basis[1][1]*pbc->basi s[2][2]-pbc->basis[1][2]*pbc->basis[2][1]); volume+=pbc->basis[0][1]*(pbc->basis[1][2]*pbc->bas is[2][0]-pbc->basis[1][0]*pbc->basis[2][2]); volume+=pbc->basis[0][2]*(pbc->basis[1][0]*pbc->bas is[2][1]-pbc->basis[2][1]*pbc->basis[2][0]); return(volume); }/*getthereciprocalspacebasis*/voidpbc_reciprocal(pbc_t*pbc){ intp,q;doubleinverse_volume;inverse_volume=1.0/pbc_volume(pbc);pbc->reciprocal_basis[0][0]=inverse_volume*(pbc->ba sis[1][1]*pbc->basis[2][2]-pbc->basis[1][2]*pbc->ba sis[2][1]); pbc->reciprocal_basis[0][1]=inverse_volume*(pbc->ba sis[0][2]*pbc->basis[2][1]-pbc->basis[0][1]*pbc->ba sis[2][2]); pbc->reciprocal_basis[0][2]=inverse_volume*(pbc->ba sis[0][1]*pbc->basis[1][2]-pbc->basis[0][2]*pbc->ba sis[1][1]); pbc->reciprocal_basis[1][0]=inverse_volume*(pbc->ba sis[1][2]*pbc->basis[2][0]-pbc->basis[1][0]*pbc->ba sis[2][2]); pbc->reciprocal_basis[1][1]=inverse_volume*(pbc->ba sis[0][0]*pbc->basis[2][2]-pbc->basis[0][2]*pbc->ba sis[2][0]); pbc->reciprocal_basis[1][2]=inverse_volume*(pbc->ba sis[0][2]*pbc->basis[1][2]-pbc->basis[0][0]*pbc->ba sis[1][2]); pbc->reciprocal_basis[2][0]=inverse_volume*(pbc->ba sis[1][0]*pbc->basis[2][1]-pbc->basis[1][1]*pbc->ba sis[2][0]); pbc->reciprocal_basis[2][1]=inverse_volume*(pbc->ba sis[0][1]*pbc->basis[2][0]-pbc->basis[0][0]*pbc->ba sis[2][1]); pbc->reciprocal_basis[2][2]=inverse_volume*(pbc->ba sis[0][0]*pbc->basis[1][1]-pbc->basis[0][1]*pbc->ba sis[1][0]); }voidpbc(pbc_t*pbc){ /*gettheunitcellvolumeandcutoff*/pbc->volume=pbc_volume(pbc);pbc->cutoff=pbc_cutoff(pbc);/*getthereciprocalspacelattice*/pbc_reciprocal(pbc); }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include/*gettheinductionenergy*/ 203

PAGE 218

doublepolar(system_t*system){ inti,num_iterations;molecule_t*molecule_ptr;atom_t*atom_ptr;doubledipole_rrms,N,potential;/*takemeasurestoletNfluctuate*/if((system->ensemble==ENSEMBLE_UVT)&&!system->polar _zodid) thole_resize_matrices(system); /*gettheAmatrix*/if(!system->polar_zodid){ thole_amatrix(system);if(system->polarizability_tensor){ output("POLAR:Amatrix:\n");print_matrix(3*((int)system->checkpoint->N_atom),sy stem->A_matrix); } }/*calculatethefieldvectors*/thole_field(system);/*findthedipoles*/if(system->polar_iterative){/*solvetheself-consiste ntfield...*/ num_iterations=thole_iterative(system);system->nodestats->polarization_iterations=(double) num_iterations; /*RRMSofdipoles*/N=0;dipole_rrms=0;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ if(isfinite(atom_ptr->dipole_rrms))dipole_rrms+=ato m_ptr->dipole_rrms; N+=1.0; } }dipole_rrms/=N;system->observables->dipole_rrms=dipole_rrms; }else{/*...ordomatrixinversion*/ thole_bmatrix(system);thole_bmatrix_dipoles(system);/*outputthe3x3molecularpolarizabilitytensor*/if(system->polarizability_tensor){ output("POLAR:Bmatrix:\n");print_matrix(3*((int)system->checkpoint->N_atom),sy stem->B_matrix); thole_polarizability_tensor(system);exit(0); } }/*calculatethepolarizationenergyas1/2mu*E*/for(molecule_ptr=system->molecules,potential=0;mole cule_ptr;molecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(i=0;i<3;i++){ potential+=atom_ptr->mu[i]*atom_ptr->ef_static[i];if(system->polar_palmo) potential+=atom_ptr->mu[i]*atom_ptr->ef_induced_cha nge[i]; } } }potential*=-0.5;return(potential); }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include/*Silvera-GoldmanH2potential*/doublesg(system_t*system){ molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;doublerimg,r6,r8,r10,r_rm;doublerepulsive_term,multipole_term,exponential_ter m; doublefirst_r_diff_term,second_r_diff_term;doublefirst_derivative,second_derivative;doublepotential_classical,potential_fh_second_order ; doublepotential;doubletemperature; 204

PAGE 219

temperature=system->temperature;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next){ if(pair_ptr->recalculate_energy){ pair_ptr->rd_energy=0;rimg=pair_ptr->rimg;if(rimgpbc->cutoff){ /*convertunitstoBohrradii*/rimg/=AU2ANGSTROM;/*classicalpairwisepart*/repulsive_term=exp(ALPHA-BETA*rimg-GAMMA*rimg*rimg) ; r6=pow(rimg,6.0);r8=pow(rimg,8.0);r10=pow(rimg,10.0);multipole_term=C6/r6+C8/r8+C10/r10;r_rm=RM/rimg;if(rimgrd_energy+=potential_classical;if(system->feynman_hibbs){ /*FIRSTDERIVATIVE*/first_derivative=(-BETA-2.0*GAMMA*rimg)*repulsive_t erm; first_derivative+=(6.0*C6/pow(rimg,7.0)+8.0*C8/pow( rimg,9.0)+ 10.0*C10/pow(rimg,11.0))*exponential_term; first_r_diff_term=(r_rm*r_rm-r_rm)/rimg;first_derivative+=-2.0*multipole_term*exponential_t erm*first_r_diff_term; /*SECONDDERIVATIVE*/second_derivative=(pow((BETA+2.0*GAMMA*rimg),2.0)-2 .0*GAMMA)*repulsive_term; second_derivative+=(-exponential_term)*(42.0*C6/pow (rimg,8.0)+72.0*C8/pow(rimg, 10.0)+110.0*C10/pow(rimg,10.0)); second_derivative+=exponential_term*first_r_diff_te rm*(12.0*C6/pow(rimg,7.0)+ 16.0*C8/pow(rimg,9.0)+20.0*C10/pow(rimg,11.0)); second_derivative+=exponential_term*pow(first_r_dif f_term, 2.0)*4.0*multipole_term; second_r_diff_term=(3.0*r_rm*r_rm-2.0*r_rm)/(rimg*r img); second_derivative+=exponential_term*second_r_diff_t erm*2.0*multipole_term; potential_fh_second_order=pow(METER2ANGSTROM, 2.0)*(HBAR*HBAR/(24.0*KB*temperature*(AMU2KG*molecu le_ptr->mass)))*(second_derivative+2.0*first_deriva tive/rimg); pair_ptr->rd_energy+=potential_fh_second_order; }/*convertunitsfromHartreesbacktoKelvin*/pair_ptr->rd_energy*=HARTREE2KELVIN; } }/*recalculate*/ }/*pair*/ }/*atom*/ }/*molecule*/potential=0;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next) for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next) for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next) potential+=pair_ptr->rd_energy; return(potential); }/*sameasabove,butnoperiodicboundaryconditions*/doublesg_nopbc(molecule_t*molecules){ molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;doubler,r6,r8,r10,r9;doubler_rm,r_rm_2,r_exp;doublepotential,multipole_term;doubleresult,exp_result;for(molecule_ptr=molecules,potential=0;molecule_ptr ;molecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next){ if(pair_ptr->recalculate_energy){ r=pair_ptr->r/AU2ANGSTROM; 205

PAGE 220

r6=pow(r,6.0);r8=pow(r,8.0);r10=pow(r,10.0);r9=pow(r,9.0);multipole_term=C6/r6+C8/r8+C10/r10-C9/r9;if(rrd_energy=HARTREE2KELVIN*exp_result; }/*recalculate*/ }/*pair*/ }/*atom*/ }/*molecule*/potential=0;for(molecule_ptr=molecules;molecule_ptr;molecule_pt r=molecule_ptr->next) for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next) for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next) potential+=pair_ptr->rd_energy; return(potential); }#include/*tousethisroutine,compilewith-gdefined. *callthisroutineatanypointintheexecution*thatyouwouldliketoattach.whenexecution*begins,theprocessshouldwriteoutthePIDS*ofallprocessesandhang.openanewterminal*andstartgdb.AttachtothePIDofchoice.go*upthefunctionstackuntilyouareinthescope*ofthe*gdb>attach21456*/ voidattach(void){ /*debugroutinetoattachtogdb*/staticinti=0;printf("RANK:%dPID:%d\n",rank,getpid());fflush(NULL);while(!i)sleep(1); }/*updatetheavg_histogramstoredonroot*/voidupdate_root_histogram(system_t*system){ inti,j,k;intxdim=system->grids->histogram->x_dim;intydim=system->grids->histogram->y_dim;intzdim=system->grids->histogram->z_dim;for(k=0;kgrids->avg_histogram->grid[i][j][k]+=system ->grids->histogram->grid[i][j][k]; /*norm_totalisupdatedheretonormalizeuponwriteout*/system->grids->avg_histogram->norm_total+=system->g rids->histogram->grid[i][j][k]; } } } }/*zerooutthehistogramgrid*/voidzero_grid(int***grid,system_t*system){ inti,j,k;intxdim=system->grids->histogram->x_dim;intydim=system->grids->histogram->y_dim;intzdim=system->grids->histogram->z_dim;for(k=0;kgrids->histogram->x_dim;intydim=system->grids->histogram->y_dim;intzdim=system->grids->histogram->z_dim; 206

PAGE 221

/*weneedthefractionalcoordstosimplifythebincalculat ion*/ cart2frac(frac_coords,cart_coords,system);/*thecoordinatesysteminthesimulationisfrom-0.5to0.5 */ /*soweneedtocorrectforthis:add0.5toeachdimension*/frac_coords[0]+=0.5;frac_coords[1]+=0.5;frac_coords[2]+=0.5;/*computebinineachdimension*/Abin=(int)floor(frac_coords[0]*system->grids->histo gram->x_dim); Bbin=(int)floor(frac_coords[1]*system->grids->histo gram->y_dim); Cbin=(int)floor(frac_coords[2]*system->grids->histo gram->z_dim); /*returnresulttothebin_vectorpassedin*/bin_vector[0]=Abin;bin_vector[1]=Bbin;bin_vector[2]=Cbin; }voidwrap1coord(double*unwrapped,double*wrapped,syst em_t*system) { doubleunit[3],offset[3],frac[3];inti,j;/*zerothevectors*/for(i=0;i<3;i++){offset[i]=0;unit[i]=0;frac[i]=0;}/*putcoordsinfractionalrepresentation*/for(i=0;i<3;i++) for(j=0;j<3;j++) frac[i]+=system->pbc->reciprocal_basis[i][j]*unwrap ped[j]; /*anyfractionalcoord>.5or<-.5roundto1,-1etc.*/for(i=0;i<3;i++)unit[i]=rint(frac[i]);/*multiplythisroundedfractionalunitvectorbybasis*/for(i=0;i<3;i++) for(j=0;j<3;j++) offset[i]+=system->pbc->basis[i][j]*unit[j]; /*subtractthisdistancefromtheincomingvector*/for(i=0;i<3;i++)wrapped[i]=unwrapped[i]-offset[i]; }/*populationhistogramshouldbeperformedonlyeverycorr time *individualnodesstorethedataongrids->histogram*onlyrootwillcompilethesumintogrids->avg_histogram*thenodeonlygrid->histogramwillberezeroedateverycor rtime *topreventoverflow.*NOTE:Thehistogramisnormalizedto1.*e.g.ifthereareatotalof328bincounts->everybinis*dividedby328.*/ voidpopulation_histogram(system_t*system){ molecule_t*mol_p;charlinebuf[MAXLINE];intbin[3];doublewrappedcoords[3];for(mol_p=system->molecules;mol_p;mol_p=mol_p->next ){ if(!mol_p->frozen){ /*wrapthecoordinatesofmol_p*/wrap1coord(mol_p->com,wrappedcoords,system);/*computewhatbintoincrement.storeanswerinbin[]*/compute_bin(wrappedcoords,system,bin);/*incrementthebinreturnedinbin[]*/(system->grids->histogram->grid[(bin[0])][(bin[1])] [(bin[2])])++; } } }/*ThiswritesoutthegridwiththeCbin(lastindex)varying *thefastest.Linebreakbetweendimensions,doubleline*breakbetweenZYsheets,####'sbetweencompletesets*Remember,forthistowork,wehadtooffsettheorigin*by1/2abinwidth*/ voidwrite_histogram(FILE*fp_out,int***grid,system_t *system) { inti,j,k;intxdim,ydim,zdim;intcount=0;xdim=system->grids->histogram->x_dim;ydim=system->grids->histogram->y_dim;zdim=system->grids->histogram->z_dim;rewind(fp_out);fprintf(fp_out,"#OpenDXformatpopulationhistogram\n" ); fprintf(fp_out,"object1classgridpositionscounts%d%d %d\n",xdim,ydim,zdim); fprintf(fp_out,"origin\t%f\t%f\t%f\n",system->grids ->histogram->origin[0],system->grids->histogram->or igin[1],system->grids-> histogram->origin[2]); fprintf(fp_out,"delta \t%f\t%f\t%f\n",system->grids->histogram->delta[0][ 0],system->grids->histogram->delta[0][1],system->gr ids->histogram->delta[0][2]); fprintf(fp_out,"delta \t%f\t%f\t%f\n",system->grids->histogram->delta[1][ 0],system->grids->histogram->delta[1][1],system->gr ids->histogram->delta[1][2]); fprintf(fp_out,"delta \t%f\t%f\t%f\n",system->grids->histogram->delta[2][ 0],system->grids->histogram->delta[2][1],system->gr ids->histogram->delta[2][2]); fprintf(fp_out,"\n");fprintf(fp_out,"object2classgridconnectionscounts%d %d%d\n",xdim,ydim,zdim); fprintf(fp_out,"\n");fprintf(fp_out,"object3classarraytypefloatrank0item s%ddatafollows\n",system->grids->histogram->n_data_ points); for(i=0;i
PAGE 222

fprintf(fp_out,"%f",(float)(grid[i][j][k])/(float)( system->grids->avg_histogram->norm_total)); count+=grid[i][j][k]; }fprintf(fp_out,"\n"); }fprintf(fp_out,"\n"); }fprintf(fp_out,"#count=%d\n",count);fprintf(fp_out,"attribute\"dep\"string\"positions\" \n"); fprintf(fp_out,"object\"regularpositionsregularconn ections\"classfield\n"); fprintf(fp_out,"component\"positions\"value1\n");fprintf(fp_out,"component\"connections\"value2\n");fprintf(fp_out,"component\"data\"value3\n");fprintf(fp_out,"\nend\n");fflush(fp_out); }/*Takeavectorinfractionalcoordinates(frac[])and *convertittocartesiancoordinates.*storetheanswerinanswer[]*/ intfrac2cart(double*answer,double*frac,system_t*sys tem) { inti,j;for(i=0;i<3;i++)answer[i]=0.0;for(i=0;i<3;i++){ for(j=0;j<3;j++){ answer[i]+=system->pbc->basis[i][j]*frac[j]; } }return1; }/*Takeavectorincartesiancoordinates(cart[])and *convertittofractionalcoordinates.*storetheanswerinanwer[]*/ intcart2frac(double*answer,double*cart,system_t*sys tem){ inti,j;for(i=0;i<3;i++)answer[i]=0.0;for(i=0;i<3;i++){ for(j=0;j<3;j++){ answer[i]+=system->pbc->reciprocal_basis[i][j]*cart [j]; } }return1; }/*Returnsthemagnitudeofa3-vector*/doublemagnitude(double*vector){ inti;doublemag=0;for(i=0;i<3;i++)mag+=vector[i]*vector[i];returnsqrt(mag); }voidallocate_histogram_grid(system_t*system){ inti,j,k;intx_dim=system->grids->histogram->x_dim;inty_dim=system->grids->histogram->y_dim;intz_dim=system->grids->histogram->z_dim;/*allocatea3Dgridforthehistogram*/system->grids->histogram->grid=calloc(x_dim,sizeof( int**)); for(i=0;igrids->histogram->grid[i]=calloc(y_dim,size of(int*)); for(i=0;igrids->histogram->grid[i][j]=calloc(z_dim,s izeof(int)); } }/*ifroot,allocateanavg_histogramgrid*/if(!rank){ system->grids->avg_histogram->grid=calloc(x_dim,siz eof(int**)); for(i=0;igrids->avg_histogram->grid[i]=calloc(y_dim, sizeof(int*)); for(i=0;igrids->avg_histogram->grid[i][j]=calloc(z_d im,sizeof(int)); } } } }/*Theseareneededbydxwriteroutines. *deltaisatransformationmatrixthatdefinesthe*stepsizeforsettingupagridinOpenDX*seetheDXuserguide.pdfappendixBfor*moredetails.*/ voidsetup_deltas(histogram_t*hist,system_t*system){ inti,j;for(i=0;i<3;i++) for(j=0;j<3;j++) 208

PAGE 223

hist->delta[i][j]=system->pbc->basis[j][i]/hist->co unt[i]; /*wedividebythecounttogetouractualstepsizeineachdim ension*/ }/*BecauseOpenDXputsourdatavaluesatthepointsofthegri d, *weneedtooffsetthembyhalfabinwidthtoreflectthefactt hat *wehaveahistogram.Ourdatareallyliesbetweeneachpoint .*/ voidoffset_dx_origin(double*real_origin_cartesian,h istogram_t*hist,system_t*system) { doublefractional_binwidth[3];doublecart_halfbin[3];/*figureouthowwideeachbinisineachdimension*/fractional_binwidth[0]=1.0/hist->x_dim;fractional_binwidth[1]=1.0/hist->y_dim;fractional_binwidth[2]=1.0/hist->z_dim;/*figureouthowwidehalfabinwidthisincartesians*/fractional_binwidth[0]/=2.0;fractional_binwidth[1]/=2.0;fractional_binwidth[2]/=2.0;frac2cart(cart_halfbin,fractional_binwidth,system);/*addthisvaluetotheorigin*/real_origin_cartesian[0]+=cart_halfbin[0];real_origin_cartesian[1]+=cart_halfbin[1];real_origin_cartesian[2]+=cart_halfbin[2]; }/*VariablesneededuponprintinginopenDXnativeformat. *seeDXuserguide.pdfappendixBfordetails.*/ voidsetup_dx_variables(histogram_t*hist,system_t*sy stem) { inti,j,k;doublevec[3],origin[3];/*setupcounts*/hist->count[0]=hist->x_dim;hist->count[1]=hist->y_dim;hist->count[2]=hist->z_dim;/*setuporigin*/vec[0]=-0.5;vec[1]=-0.5;vec[2]=-0.5;frac2cart(origin,vec,system);/*IMPORTANT!!!Iamoffsettingtheoriginby1/2abinineach dimension*/ /*theresultoforiginisnotthetrueorigin!!!*/offset_dx_origin(origin,hist,system);hist->origin[0]=origin[0];hist->origin[1]=origin[1];hist->origin[2]=origin[2];/*setupdeltas*/setup_deltas(system->grids->histogram,system);/*setupNdatapoints*/hist->n_data_points=hist->x_dim*hist->y_dim*hist->z _dim; }/*Setupthevariousquantitiesthatdefinethehistogramgr id*/ voidsetup_histogram(system_t*system){ charlinebuf[256];doubletrial_vec1[3];doubletrial_vec2[3];doublemagA,magB,magC;intNbins,i,j,x_dim,y_dim,z_dim;/*getthemagnitudesofallthebasisvectorsandtestthefra c2cartroutine. *defineafractionalvector(1,0,0)andtransformitwithou rbasis. *thencalculateitsmagnitude.Dothisinall3dimensions*/ trial_vec1[0]=1.0;trial_vec1[1]=0.0;trial_vec1[2]=0 .0; frac2cart(trial_vec2,trial_vec1,system);magA=magnitude(trial_vec2);trial_vec1[0]=0.0;trial_vec1[1]=1.0;trial_vec1[2]=0 .0; frac2cart(trial_vec2,trial_vec1,system);magB=magnitude(trial_vec2);trial_vec1[0]=0.0;trial_vec1[1]=0.0;trial_vec1[2]=1 .0; frac2cart(trial_vec2,trial_vec1,system);magC=magnitude(trial_vec2);/*calculatethenumberofbinsineachfractionalcoordinat e*/ x_dim=rint(magA/system->hist_resolution);y_dim=rint(magB/system->hist_resolution);z_dim=rint(magC/system->hist_resolution);sprintf(linebuf,"HISTOGRAM:%fresolution->%dbins(A)* %dbins(B)*%d bins(C)\n",system->hist_resolution,x_dim,y_dim,z_di m);output(linebuf); Nbins=x_dim*y_dim*z_dim;sprintf(linebuf,"HISTOGRAM:TotalBins=%d\n",Nbins);o utput(linebuf); system->grids->histogram->x_dim=x_dim;system->grids->histogram->y_dim=y_dim;system->grids->histogram->z_dim=z_dim;system->grids->avg_histogram->x_dim=x_dim;system->grids->avg_histogram->y_dim=y_dim;system->grids->avg_histogram->z_dim=z_dim;system->grids->histogram->n_data_points=Nbins;system->n_histogram_bins=Nbins;system->grids->avg_histogram->norm_total=0;system->grids->histogram->norm_total=0; 209

PAGE 224

setup_dx_variables(system->grids->histogram,system) ; }/*energy*/doubleenergy(system_t*);doubleenergy_no_observables(system_t*);doublelj(system_t*);doublelj_nopbc(molecule_t*);voidupdate_com(molecule_t*);voidflag_all_pairs(system_t*);voidpair_exclusions(system_t*,molecule_t*,molecule_ t*,atom_t*,atom_t*,pair_t*); voidminimum_image(system_t*,atom_t*,atom_t*,pair_t* ); voidpairs(system_t*);voidsetup_pairs(molecule_t*);voidupdate_pairs_insert(system_t*);voidupdate_pairs_remove(system_t*);voidunupdate_pairs_insert(system_t*);voidunupdate_pairs_remove(system_t*);doublepbc_cutoff(pbc_t*);doublepbc_volume(pbc_t*);voidpbc(pbc_t*);doublesg(system_t*);doublesg_nopbc(molecule_t*);doublecoulombic(system_t*);doublecoulombic_real(system_t*);doublecoulombic_reciprocal(system_t*);doublecoulombic_nopbc(molecule_t*);doublemorse_energy(double,double,double,double);doubleanharmonic(system_t*);doubleanharmonic_energy(double,double,double);doubleanharmonic_fk(double,double,double,double,dou ble); doubleanharmonic_fh_second_order(double,double,doub le,double,double); doubleanharmonic_fh_fourth_order(double,double,doub le,double,double); doubleh2_bond_energy(doubler);intbessik(float,float,float*,float*,float*,float*); /*NRfunction*/ doublebesselK(double,double);/*io*/system_t*read_config(char*);intcheck_config(system_t*);molecule_t*read_molecules(system_t*);system_t*setup_system(char*);voiderror(char*);voidoutput(char*);voidclear_nodestats(nodestats_t*);voidclear_node_averages(avg_nodestats_t*);voidclear_observables(observables_t*);voidclear_root_averages(avg_observables_t*);voidtrack_ar(nodestats_t*);voidupdate_nodestats(nodestats_t*,avg_nodestats_t*) ; voidupdate_root_averages(system_t*,observables_t*,a vg_nodestats_t*,avg_observables_t*); intwrite_performance(int,system_t*);intwrite_averages(avg_observables_t*);intwrite_molecules(system_t*,char*);voidwrite_observables(FILE*,observables_t*);voidwrite_states(FILE*,molecule_t*);intwrapall(molecule_t*,pbc_t*);doubleco2_fugacity(double,double);doubleh2_fugacity(double,double);doubleh2_fugacity_shaw(double,double);doubleh2_fugacity_zhou(double,double);doubleh2_fugacity_back(double,double);doubleh2_comp_back(double,double);intopen_files(system_t*);voidclose_files(system_t*);/*main*/voidusage(char*);doubleget_rand(void);doublerule30_rng(longint);voidseed_rng(longint);#ifdefQM_ROTATIONvoidfree_rotational(system_t*);#endif/*QM_ROTATION*/voidfree_pairs(molecule_t*);voidfree_atoms(molecule_t*);voidfree_molecule(system_t*,molecule_t*);voidfree_molecules(molecule_t*);voidfree_averages(system_t*system);voidfree_matricies(system_t*system);voidfree_cavity_grid(system_t*system);voidcleanup(system_t*);voidterminate_handler(int,system_t*);/*mc*/voidboltzmann_factor(system_t*,double,double);voidregister_accept(system_t*);voidregister_reject(system_t*);intmc(system_t*);molecule_t*copy_molecule(system_t*,molecule_t*);voidtranslate(molecule_t*,pbc_t*,double);voidrotate(molecule_t*,pbc_t*,double);voiddisplace(molecule_t*,pbc_t*,double,double);voiddisplace_1D(system_t*,molecule_t*,double);voidmake_move(system_t*);voidcheckpoint(system_t*);voidrestore(system_t*);doublesurface_energy(system_t*,int);voidmolecule_rotate(molecule_t*,double,double,doubl e); intsurface_dimer_geometry(system_t*,double,double,d ouble,double,double,double,double); intsurface_dimer_parameters(system_t*,param_t*);voidsurface_curve(system_t*,double,double,double,do uble*); intsurface(system_t*);intsurface_fit(system_t*);intsurface_virial(system_t*);voidsetup_cavity_grid(system_t*);voidcavity_volume(system_t*); 210

PAGE 225

voidcavity_probability(system_t*);voidcavity_update_grid(system_t*);/*polarization*/doublepolar(system_t*);voidthole_amatrix(system_t*);voidthole_bmatrix(system_t*);voidthole_bmatrix_dipoles(system_t*);voidthole_polarizability_tensor(system_t*);voidthole_field(system_t*);voidthole_field_nopbc(system_t*);voidthole_field_real(system_t*);voidthole_field_recip(system_t*);voidthole_field_self(system_t*);intthole_iterative(system_t*);voidinvert_matrix(int,double**,double**);intnum_atoms(system_t*);voidthole_resize_matrices(system_t*);/*pimc*/intpimc(system_t*);/*histogram*/inthistogram(system_t*);intcart2frac(double*,double*,system_t*);intfrac2cart(double*,double*,system_t*);voidsetup_histogram(system_t*);voidallocate_histogram_grid(system_t*);voidwrite_histogram(FILE*,int***,system_t*);voidzero_grid(int***,system_t*);voidpopulation_histogram(system_t*);voidmpi_copy_histogram_to_sendbuffer(char*,int***,s ystem_t*); voidmpi_copy_rcv_histogram_to_data(char*,int***,sys tem_t*); voidupdate_root_histogram(system_t*);voidwrite_histogram(FILE*,int***,system_t*);/*dxwrite*/voidwrite_frozen(FILE*fp_frozen,system_t*system);#ifdefQM_ROTATION/*quantumrotation*/voidquantum_system_rotational_energies(system_t*);voidquantum_rotational_energies(system_t*,molecule_ t*,int,int); voidquantum_rotational_grid(system_t*,molecule_t*);complex_t**rotational_hamiltonian(system_t*,molecul e_t*,int,int); intdetermine_rotational_eigensymmetry(molecule_t*,i nt,int); doublerotational_basis(int,int,int,double,double);doublerotational_potential(system_t*,molecule_t*,do uble,double); doublehindered_potential(double);doublerotational_integrate(system_t*,molecule_t*,in t,int,int,int,int); #endif/*QM_ROTATION*/#ifdefDEBUGvoidtest_pairs(molecule_t*);voidtest_molecule(molecule_t*);voidtest_list(molecule_t*);voidtest_cavity_grid(system_t*);#endif/*DEBUG*/externintrank,size;#include#include#include#include#include#include#defineMAXLINE512#defineMAXVALUE1.0e200#defineDARTSCALE0.1#defineQUANTUM_ROTATION_SYMMETRIC0#defineQUANTUM_ROTATION_ANTISYMMETRIC1#defineQUANTUM_ROTATION_SYMMETRY_POINTS64#defineQUANTUM_ROTATION_LEVEL_MAX36#defineQUANTUM_ROTATION_L_MAX5#defineQUANTUM_ROTATION_GRID16#defineQUANTUM_ROTATION_THETA_MAXQUANTUM_ROTATION_G RID #defineQUANTUM_ROTATION_PHI_MAXQUANTUM_ROTATION_GRI D #defineFEYNMAN_KLEINERT_TOLERANCE1.0e-12/*tolerance inA^2*/ #include#ifdefMPI#include#endif/*MPI*/#include#include#include#defineENSEMBLE_UVT1#defineENSEMBLE_NVT2#defineENSEMBLE_SURF3#defineENSEMBLE_SURF_FIT4#defineENSEMBLE_NVE5#defineMOVETYPE_INSERT1#defineMOVETYPE_REMOVE2#defineMOVETYPE_DISPLACE3#defineMOVETYPE_ADIABATIC4 211

PAGE 226

#defineMAX_ITERATION_COUNT128#defineDAMPING_LINEAR1#defineDAMPING_EXPONENTIAL2#defineEWALD_ALPHA0.5#defineEWALD_KMAX7#defineREAL0#defineIMAGINARY1#ifndefM_PI#defineM_PI3.14159265358979323846#endif/*M_PI*/#defineH6.626068e-34/*Planck'sconstantinJs*/#defineHBAR1.054571e-34/*abovedividedby2piinJs*/#defineKB1.3806503e-23/*Boltzmann'sconstantinJ/K*/#defineNA6.0221415e23/*Avogadro'snumber*/#defineC2.99792458e8/*speedoflightinvacuuminm/s*//*H2specificconstants*/#defineH2_MASS3.348e-27/*massofH2moleculeinkg*/#defineH2_REDUCED_MASS0.25*H2_MASS/*reducedmassofH2 moleculeinkg*/ #defineH2_De4.72/*dissocationenergyineV*/#defineH2_R00.742/*equilibriumbonddistanceinangstro ms*/ #defineH2_SPRING_CONSTANT35.2/*harmonicspringconsta ntatwellminimum*/ /*Silvera-Goldmanparameters*/#defineALPHA1.713/*unitless*/#defineBETA1.5671/*1/a.u.*/#defineGAMMA0.00993/*1/a.u.^2*/#defineC612.14/*multipoleterm1a.u.^6*/#defineC8215.2/*multipoleterm2a.u.^8*/#defineC104813.9/*multipoleterm3a.u.^10*/#defineC9143.1/*3-bodyterma.u.^9*/#defineRM8.321/*positionofmaxwelldepth(a.u.)times1. 28*/ /*conversionfactors*/#defineAU2ANGSTROM0.529177249/*convertfromBohrradii toangstroms*/ #defineMETER2ANGSTROM1.0e10/*convertfrommeterstoang stroms*/ #defineHARTREE2KELVIN3.15774655e5/*convertfromHartr eestoKelvin*/ #defineE2REDUCED408.7816/*convertfrometosqrt(K*A)*/#defineATM2REDUCED0.0073389366/*convertfromatmtoK/A ^3*/ #defineATM2PASCALS101325.0/*convertfromatmtoPascals */ #defineATM2PSI14.6959488/*convertfromatmtopsi*/#defineA32CM31.0e-24/*convertfromA^3tocm^3*/#defineAMU2KG1.66053873e-27/*convertamu'stokg*/#defineDEBYE2SKA85.10597636/*convertfromDebyetosqrt (KA)*A*/ #defineEV2K1.160444e4/*converteVtoK*/#defineK2WN0.695039/*convertKtocm^-1*//*complexvalue*/typedefstruct_complex_t{ doublereal;doubleimaginary; }complex_t;typedefstruct_pair{ intfrozen;intrd_excluded,es_excluded;doublelrc;doublecharge;doublepolarizability;doubleepsilon;doublesigma;doubler;doubled[3];doubled_prev[3];intrecalculate_energy;doublerimg;doubledimg[3];doubler2,r3,r5;/*2nd,3rdand5thpowersforAmatrixcalc* / doubler2img,r3img,r5img;doublerd_energy,es_real_energy,es_self_intra_energy ; struct_atom*atom;struct_molecule*molecule;struct_pair*next; }pair_t;typedefstruct_atom{ intid;charatomtype[MAXLINE];intfrozen,adiabatic;doublemass;doublecharge;doublepolarizability;doubleepsilon;doublesigma;doublees_self_point_energy;doublepos[3];doublewrapped_pos[3];doubleef_static[3];doubleef_induced[3];doubleef_induced_change[3];doublemu[3];doubleold_mu[3];doublenew_mu[3];doubledipole_rrms; 212

PAGE 227

doublerank_metric;pair_t*pairs;struct_atom*next; }atom_t;typedefstruct_molecule{ intid;charmoleculetype[MAXLINE];doublemass;intfrozen,adiabatic;doublecom[3];doublewrapped_com[3]; #ifdefQM_ROTATION double*quantum_rotational_energies;complex_t**quantum_rotational_eigenvectors;int*quantum_rotational_eigensymmetry;doublequantum_rotational_potential_grid[QUANTUM_ROT ATION_GRID][QUANTUM_ROTATION_GRID]; #endif/*QM_ROTATION*/#ifdefXXX /*XXX-vibworkinprogress*/double*quantum_vibrational_energies;complex_t**quantum_vibrational_eigenvectors;int*quantum_vibrational_eigensymmetry; #endif/*XXX*/ atom_t*atoms;struct_molecule*next; }molecule_t;typedefstruct_pbc{ doublebasis[3][3];/*unitcelllattice(A)*/doublereciprocal_basis[3][3];/*reciprocalspacelatti ce(1/A)*/ doublecutoff;/*radialcutoff(A)*/doublevolume;/*unitcellvolume(A^3)*/ }pbc_t;typedefstruct_cavity{ intoccupancy;doublepos[3]; }cavity_t;typedefstruct_histogram{ int***grid;intx_dim,y_dim,z_dim;doubleorigin[3];doubledelta[3][3];intcount[3];intn_data_points;intnorm_total; }histogram_t;/*usedinquantumrotationcode*/typedefstruct_spherical_harmonic{ doublelegendre;/*legendrepolynomialpart*/doublereal;/*realpartofthesphericalharmonic*/doubleimaginary;/*imaginarypartofthesphericalharmon ic*/ }spherical_harmonic_t;typedefstruct_nodestats{ intaccept,reject;intaccept_insert,reject_insert;intaccept_remove,reject_remove;intaccept_displace,reject_displace;intaccept_adiabatic,reject_adiabatic;doubleboltzmann_factor;doubleacceptance_rate;doubleacceptance_rate_insert;doubleacceptance_rate_remove;doubleacceptance_rate_displace;doubleacceptance_rate_adiabatic;doublecavity_bias_probability;doublepolarization_iterations; }nodestats_t;typedefstruct_avg_nodestats{ doubleboltzmann_factor;doubleboltzmann_factor_sq;doubleacceptance_rate;doubleacceptance_rate_insert;doubleacceptance_rate_remove;doubleacceptance_rate_displace;doubleacceptance_rate_adiabatic;doublecavity_bias_probability;doublecavity_bias_probability_sq;doublepolarization_iterations;doublepolarization_iterations_sq; }avg_nodestats_t;typedefstruct_observables{ doubleenergy;doublecoulombic_energy;doublerd_energy;doublepolarization_energy;doubledipole_rrms; 213

PAGE 228

doublekinetic_energy;/*forNVE*/doubletemperature;/*forNVE*/doubleN;doubleNU; }observables_t;typedefstruct_avg_observables{ /*theseareuncorrelatedaveragesoftheobservables*/doubleenergy;doubleenergy_sq;doubleenergy_error;/*neededforheatcapacityerrorpropagation*/doubleenergy_sq_sq;doubleenergy_sq_error;doublecoulombic_energy;doublecoulombic_energy_sq;doublecoulombic_energy_error;doublerd_energy;doublerd_energy_sq;doublerd_energy_error;doublepolarization_energy;doublepolarization_energy_sq;doublepolarization_energy_error;doubledipole_rrms;doubledipole_rrms_sq;doubledipole_rrms_error;/*forNVEMC*/doublekinetic_energy;doublekinetic_energy_sq;doublekinetic_energy_error;doubletemperature;doubletemperature_sq;doubletemperature_error;doubleN;doubleN_sq;doubleN_error;/*neededforqst*/doubleNU;/*thesequantitiesarenodestats,notobservables*/doubleboltzmann_factor;doubleboltzmann_factor_sq;doubleboltzmann_factor_error;doubleacceptance_rate;doubleacceptance_rate_insert;doubleacceptance_rate_remove;doubleacceptance_rate_displace;doubleacceptance_rate_adiabatic;doublecavity_bias_probability;doublecavity_bias_probability_sq;doublecavity_bias_probability_error;doublepolarization_iterations;doublepolarization_iterations_sq;doublepolarization_iterations_error;doubleqst;doubleqst_sq;doubleqst_error;doubleheat_capacity;doubleheat_capacity_sq;doubleheat_capacity_error;doublecompressibility;doublecompressibility_sq;doublecompressibility_error;/*theerrorofthesepropogates*/doubledensity;doubledensity_error;doublepore_density;doublepore_density_error;doublepercent_wt;doublepercent_wt_error;doublepercent_wt_me;doublepercent_wt_me_error;doubleexcess_ratio;doubleexcess_ratio_error; }avg_observables_t;typedefstruct_grid{ histogram_t*histogram;histogram_t*avg_histogram; }grid_t;/*beginmpimessagestruct*/typedefstruct_message{ 214

PAGE 229

/*observables*/doubleenergy;doublecoulombic_energy;doublerd_energy;doublepolarization_energy;doublekinetic_energy;doubletemperature;doubleN;doubleNU;/*avg_nodestats*/doubleboltzmann_factor;doubleboltzmann_factor_sq;doubleacceptance_rate;doubleacceptance_rate_insert;doubleacceptance_rate_remove;doubleacceptance_rate_displace;doublecavity_bias_probability;doublecavity_bias_probability_sq;doublepolarization_iterations;doublepolarization_iterations_sq;/*histogram*/int***grid; }message_t;typedefstruct_checkpoint{ intmovetype,biased_move;intN_atom,N_atom_prev;molecule_t*molecule_backup,*molecule_altered;molecule_t*head,*tail;observables_t*observables; }checkpoint_t;typedefstruct_param{ charatomtype[MAXLINE];intntypes;doublecharge;doubleepsilon;doublesigma;doubledr;intaxis;doublelast_charge;doublelast_epsilon;doublelast_sigma;doublelast_dr;struct_param*next; }param_t;typedefstruct_file_pointers{ FILE*fp_energy;FILE*fp_traj;FILE*fp_dipole;FILE*fp_field;FILE*fp_histogram;FILE*fp_frozen; }file_pointers_t;typedefstruct_system{ intensemble;doublesurf_min,surf_max,surf_inc,surf_ang;intsurf_preserve,surf_decomp;longintseed;intnumsteps,corrtime;doublemove_probability,rot_probability,insert_proba bility,adiabatic_probability; intcavity_bias,cavity_grid_size;cavity_t***cavity_grid;intcavities_open;doublecavity_radius,cavity_volume;intcavity_autoreject;doublecavity_autoreject_scale;doubletemperature,pressure,fugacity,free_volume,tot al_energy,N; intsimulated_annealing;doublesimulated_annealing_schedule;intrd_only,rd_anharmonic,rd_lrc;inth2_fugacity,co2_fugacity;doublerd_anharmonic_k,rd_anharmonic_g;intfeynman_hibbs,feynman_kleinert,feynman_hibbs_ord er; intsg,fvm,wpi,wpi_grid;intwrapall;doublescale_charge,scale_rd;doubleewald_alpha;intewald_kmax;intpolarization,polarizability_tensor;intpolar_iterative,polar_ewald,polar_zodid,polar_se lf,polar_palmo,polar_gs,polar_gs_ranked,polar_sor,p olar_esor, polar_max_iter; doublepolar_gamma;doublepolar_damp,field_damp,polar_precision;intquantum_rotation,quantum_rotation_hindered;doublequantum_rotation_B;doublequantum_rotation_hindered_barrier;intquantum_rotation_level_max,quantum_rotation_l_ma x,quantum_rotation_theta_max,quantum_rotation_phi_m ax; intquantum_vibration;intdamp_type;double**A_matrix,**B_matrix,C_matrix[3][3];/*Amatri x,Bmatrixandpolarizabilitytensor*/ char*pdb_input,*pdb_output,*pdb_restart,*traj_outpu t,*energy_output; char*dipole_output,*field_output,*histogram_output, *frozen_output; char*fit_input;grid_t*grids;intcalc_hist;/*flagtocalculatea3Dhistogram*/ 215

PAGE 230

doublehist_resolution;intn_histogram_bins;doublemax_bondlength;/*thresholdtobond(re:outputfil es)*/ pbc_t*pbc;molecule_t*molecules;nodestats_t*nodestats;avg_nodestats_t*avg_nodestats;observables_t*observables;avg_observables_t*avg_observables;checkpoint_t*checkpoint;file_pointers_tfile_pointers; }system_t;/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#includevoidclear_nodestats(nodestats_t*stats){ memset(stats,0,sizeof(nodestats_t)); }voidclear_node_averages(avg_nodestats_t*avgstats){ memset(avgstats,0,sizeof(avg_nodestats_t)); }voidclear_observables(observables_t*obs){ memset(obs,0,sizeof(observables_t)); }voidclear_root_averages(avg_observables_t*avgobs){ memset(avgobs,0,sizeof(avg_observables_t)); }/*determinetheacceptancerate*/voidtrack_ar(nodestats_t*ns){ if(ns->accept+ns->reject) ns->acceptance_rate=((double)ns->accept)/((double)( ns->accept+ns->reject)); else ns->acceptance_rate=0; if(ns->accept_insert+ns->reject_insert) ns->acceptance_rate_insert=((double)ns->accept_inse rt)/((double)(ns->accept_insert+ns->reject_insert)) ; else ns->acceptance_rate_insert=0; if(ns->accept_remove+ns->reject_remove) ns->acceptance_rate_remove=((double)ns->accept_remo ve)/((double)(ns->accept_remove+ns->reject_remove)) ; else ns->acceptance_rate_remove=0; if(ns->accept_displace+ns->reject_displace) ns->acceptance_rate_displace=((double)ns->accept_di splace)/((double)(ns->accept_displace+ns->reject_di splace)); else ns->acceptance_rate_displace=0; if(ns->accept_adiabatic+ns->reject_adiabatic) ns->acceptance_rate_adiabatic=((double)ns->accept_a diabatic)/((double)(ns->accept_adiabatic+ns->reject _adiabatic)); else ns->acceptance_rate_adiabatic=0; }/*updatenodestatisticsrelatedtotheprocessing*/voidupdate_nodestats(nodestats_t*nodestats,avg_node stats_t*avg_nodestats){ staticintcounter=0;doublefactor;++counter;factor=((double)(counter-1))/((double)(counter));avg_nodestats->boltzmann_factor=factor*avg_nodestat s->boltzmann_factor+nodestats->boltzmann_factor/((d ouble)counter); avg_nodestats->boltzmann_factor_sq=factor*avg_nodes tats->boltzmann_factor_sq+ nodestats->boltzmann_factor*nodestats->boltzmann_fa ctor/((double)counter); /*thesereallyaren'taverages,butaccumulativevalues*/avg_nodestats->acceptance_rate=nodestats->acceptanc e_rate; avg_nodestats->acceptance_rate_insert=nodestats->ac ceptance_rate_insert; avg_nodestats->acceptance_rate_remove=nodestats->ac ceptance_rate_remove; avg_nodestats->acceptance_rate_displace=nodestats-> acceptance_rate_displace; avg_nodestats->acceptance_rate_adiabatic=nodestats>acceptance_rate_adiabatic; avg_nodestats->cavity_bias_probability=factor*avg_n odestats->cavity_bias_probability+nodestats->cavity _bias_probability/ 216

PAGE 231

((double)counter); avg_nodestats->cavity_bias_probability_sq=factor*av g_nodestats->cavity_bias_probability_sq+ nodestats->cavity_bias_probability*nodestats->cavit y_bias_probability/((double)counter); avg_nodestats->polarization_iterations=factor*avg_n odestats->polarization_iterations+nodestats->polari zation_iterations/ ((double)counter); avg_nodestats->polarization_iterations_sq=factor*av g_nodestats->polarization_iterations_sq+ nodestats->polarization_iterations*nodestats->polar ization_iterations/((double)counter); }voidupdate_root_averages(system_t*system,observable s_t*observables,avg_nodestats_t*avg_nodestats,avg_o bservables_t*avg_observables) { doubleparticle_mass,frozen_mass;molecule_t*molecule_ptr;staticintcounter=0;doublefactor;++counter;factor=((double)(counter-1))/((double)(counter));/*thephysicalobservables*/avg_observables->energy=factor*avg_observables->ene rgy+observables->energy/((double)counter); avg_observables->energy_sq=factor*avg_observables-> energy_sq+(observables->energy*observables->energy) /((double)counter); avg_observables->energy_error=0.5*sqrt(avg_observab les->energy_sq-avg_observables->energy*avg_observab les->energy); avg_observables->energy_sq_sq=factor*avg_observable s->energy_sq_sq+pow(observables->energy,4.0)/((doub le)counter); avg_observables->energy_sq_error=0.5*sqrt(avg_obser vables->energy_sq_sq-pow(avg_observables->energy,4. 0)); avg_observables->coulombic_energy=factor*avg_observ ables->coulombic_energy+observables->coulombic_ener gy/((double)counter); avg_observables->coulombic_energy_sq=factor*avg_obs ervables->coulombic_energy_sq+ (observables->coulombic_energy*observables->coulomb ic_energy)/((double)counter); avg_observables->coulombic_energy_error=0.5*sqrt(av g_observables->coulombic_energy_sqavg_observables->coulombic_energy*avg_observables-> coulombic_energy); avg_observables->rd_energy=factor*avg_observables-> rd_energy+observables->rd_energy/((double)counter); avg_observables->rd_energy_sq=factor*avg_observable s->rd_energy_sq+(observables->rd_energy*observables ->rd_energy)/ ((double)counter); avg_observables->rd_energy_error=0.5*sqrt(avg_obser vables->rd_energy_sq-avg_observables->rd_energy*avg _observables->rd_energy); avg_observables->polarization_energy=factor*avg_obs ervables->polarization_energy+observables->polariza tion_energy/ ((double)counter); avg_observables->polarization_energy_sq=factor*avg_ observables->polarization_energy_sq+ (observables->polarization_energy*observables->pola rization_energy)/((double)counter); avg_observables->polarization_energy_error=0.5*sqrt (avg_observables->polarization_energy_sqavg_observables->polarization_energy*avg_observable s->polarization_energy); avg_observables->dipole_rrms=factor*avg_observables ->dipole_rrms+observables->dipole_rrms/((double)cou nter); avg_observables->dipole_rrms_sq=factor*avg_observab les->dipole_rrms_sq+(observables->dipole_rrms*obser vables->dipole_rrms)/ ((double)counter); avg_observables->dipole_rrms_error=0.5*sqrt(avg_obs ervables->dipole_rrms_sqavg_observables->dipole_rrms*avg_observables->dipol e_rrms); avg_observables->kinetic_energy=factor*avg_observab les->kinetic_energy+observables->kinetic_energy/((d ouble)counter); avg_observables->kinetic_energy_sq=factor*avg_obser vables->kinetic_energy_sq+ (observables->kinetic_energy*observables->kinetic_e nergy)/((double)counter); avg_observables->kinetic_energy_error=0.5*sqrt(avg_ observables->kinetic_energy_sqavg_observables->kinetic_energy*avg_observables->ki netic_energy); avg_observables->temperature=factor*avg_observables ->temperature+observables->temperature/((double)cou nter); avg_observables->temperature_sq=factor*avg_observab les->temperature_sq+(observables->temperature*obser vables->temperature)/ ((double)counter); avg_observables->temperature_error=0.5*sqrt(avg_obs ervables->temperature_sqavg_observables->temperature*avg_observables->tempe rature); avg_observables->N=factor*avg_observables->N+observ ables->N/((double)counter); avg_observables->N_sq=factor*avg_observables->N_sq+ (observables->N*observables->N)/((double)counter); avg_observables->N_error=0.5*sqrt(avg_observables-> N_sq-avg_observables->N*avg_observables->N); avg_observables->NU=factor*avg_observables->NU+obse rvables->NU/((double)counter); /*avginnodestats*/avg_observables->boltzmann_factor=factor*avg_observ ables->boltzmann_factor+avg_nodestats->boltzmann_fa ctor/((double)counter); avg_observables->boltzmann_factor_sq=factor*avg_obs ervables->boltzmann_factor_sq+avg_nodestats->boltzm ann_factor_sq/ ((double)counter); avg_observables->boltzmann_factor_error=0.5*sqrt(av g_observables->boltzmann_factor_sqavg_observables->boltzmann_factor*avg_observables-> boltzmann_factor); avg_observables->acceptance_rate=factor*avg_observa bles->acceptance_rate+avg_nodestats->acceptance_rat e/((double)counter); avg_observables->acceptance_rate_insert=factor*avg_ observables->acceptance_rate_insert+avg_nodestats-> acceptance_rate_insert/ ((double)counter); avg_observables->acceptance_rate_remove=factor*avg_ observables->acceptance_rate_remove+avg_nodestats-> acceptance_rate_remove/ ((double)counter); avg_observables->acceptance_rate_displace=factor*av g_observables->acceptance_rate_displace+ avg_nodestats->acceptance_rate_displace/((double)co unter); avg_observables->acceptance_rate_adiabatic=factor*a vg_observables->acceptance_rate_adiabatic+ avg_nodestats->acceptance_rate_adiabatic/((double)c ounter); avg_observables->cavity_bias_probability=factor*avg _observables->cavity_bias_probability+avg_nodestats ->cavity_bias_probability /((double)counter); avg_observables->cavity_bias_probability_sq=factor* avg_observables->cavity_bias_probability_sq+ avg_nodestats->cavity_bias_probability_sq/((double) counter); avg_observables->cavity_bias_probability_error=0.5* sqrt(avg_observables->cavity_bias_probability_sqavg_observables->cavity_bias_probability*avg_observ ables->cavity_bias_probability); avg_observables->polarization_iterations=factor*avg _observables->polarization_iterations+avg_nodestats ->polarization_iterations /((double)counter); avg_observables->polarization_iterations_sq=factor* avg_observables->polarization_iterations_sq+ avg_nodestats->polarization_iterations_sq/((double) counter); 217

PAGE 232

avg_observables->polarization_iterations_error=0.5* sqrt(avg_observables->polarization_iterations_sqavg_observables->polarization_iterations*avg_observ ables->polarization_iterations); /*getthemassofthetwophases*/for(molecule_ptr=system->molecules,particle_mass=0, frozen_mass=0;molecule_ptr;molecule_ptr=molecule_pt r->next){ if(molecule_ptr->frozen||molecule_ptr->adiabatic) frozen_mass+=molecule_ptr->mass; else particle_mass=molecule_ptr->mass; }/*densitying/cm^3*/avg_observables->density=avg_observables->N*particl e_mass/(system->pbc->volume*NA*A32CM3); avg_observables->density_error=avg_observables->N_e rror*particle_mass/(system->pbc->volume*NA*A32CM3); /*heatcapacityinkJ/molK*/avg_observables->heat_capacity=(KB*NA/1000.0)*(avg_ observables->energy_sqavg_observables->energy*avg_observables->energy)/(s ystem->temperature*system->temperature); avg_observables->heat_capacity_sq=factor*avg_observ ables->heat_capacity_sq+ (avg_observables->heat_capacity*avg_observables->he at_capacity)/((double)counter); avg_observables->heat_capacity_error=0.5*sqrt(avg_o bservables->heat_capacity_sqavg_observables->heat_capacity*avg_observables->hea t_capacity); /*compressibility*/avg_observables->compressibility=ATM2PASCALS*(syste m->pbc->volume/pow(METER2ANGSTROM,3.0))*(avg_observ ables->N_sqavg_observables->N*avg_observables->N)/(KB*system-> temperature*avg_observables->N*avg_observables->N); avg_observables->compressibility_sq=factor*avg_obse rvables->compressibility_sq+ (avg_observables->compressibility*avg_observables-> compressibility)/((double)counter); avg_observables->compressibility_error=0.5*sqrt(avg _observables->compressibility_sqavg_observables->compressibility*avg_observables->c ompressibility); /*wehaveasolidphase*/if(frozen_mass>0.0){ /*percentweight*/avg_observables->percent_wt=100.0*avg_observables-> N*particle_mass/(frozen_mass+avg_observables->N*par ticle_mass); avg_observables->percent_wt_error=100.0*avg_observa bles->N_error*particle_mass/(frozen_mass+ avg_observables->N_error*particle_mass); /*percentweightlikeME*/avg_observables->percent_wt_me=100.0*avg_observable s->N*particle_mass/frozen_mass; avg_observables->percent_wt_me_error=100.0*avg_obse rvables->N_error*particle_mass/frozen_mass; /*excessweightmg/g*/if(system->free_volume>0.0){ if(system->fugacity>0.0) avg_observables->excess_ratio=1000.0*(avg_observabl es->N*particle_mass(particle_mass*system->free_volume*system->fugacity *ATM2REDUCED)/system->temperature)/frozen_mass; else avg_observables->excess_ratio=1000.0*(avg_observabl es->N*particle_mass(particle_mass*system->free_volume*system->pressure *ATM2REDUCED)/system->temperature)/frozen_mass; avg_observables->excess_ratio_error=1000.0*avg_obse rvables->N_error*particle_mass/frozen_mass; /*poredensity*/avg_observables->pore_density=avg_observables->N*pa rticle_mass/(system->free_volume*NA*A32CM3); avg_observables->pore_density_error=avg_observables ->N_error*particle_mass/(system->free_volume*NA*A32 CM3); }/*calculatetheisostericheat*/avg_observables->qst=-(avg_observables->NU-avg_obse rvables->N*avg_observables->energy); avg_observables->qst/=(avg_observables->N_sq-avg_ob servables->N*avg_observables->N); avg_observables->qst+=system->temperature;avg_observables->qst*=KB*NA/1000.0;/*converttokJ/mo l*/ avg_observables->qst_sq=factor*avg_observables->qst _sq+(avg_observables->qst*avg_observables->qst)/((d ouble)counter); avg_observables->qst_error=0.5*sqrt(avg_observables ->qst_sq-avg_observables->qst*avg_observables->qst) ; } }#include#defineCOLOR_H"0.20.20.2"#defineCOLOR_C"0.10.50.1"#defineCOLOR_N"0.20.21.0"#defineCOLOR_O"1.00.00.0"#defineCOLOR_XXX"0.10.10.1"voidprint_frozen_coords(FILE*fp_frozen,system_t*sys tem) { molecule_t*mol;atom_t*atom;for(mol=system->molecules;mol;mol=mol->next){ if(mol->frozen){ for(atom=mol->atoms;atom;atom=atom->next){ fprintf(fp_frozen,"%f%f%f\n",atom->pos[0],atom->pos [1],atom->pos[2]); } } } }intcount_frozen(system_t*system){ intcount=0;molecule_t*mol;atom_t*atom;for(mol=system->molecules;mol;mol=mol->next){ if(mol->frozen){ 218

PAGE 233

for(atom=mol->atoms;atom;atom=atom->next)count++; } }returncount; }intbondlength_check(atom_t*atom1,atom_t*atom2,syste m_t*system) { doubledistance;doublegm_mass;/*geometricmeanofmass*/intis_bonded;doubleslope=0.0234;/*tunetomeetbondlengthexpectatio ns*/ doubleyint=0.603;/*tunetomeetbondlengthexpectations */ gm_mass=sqrt(atom1->mass*atom2->mass);distance=sqrt(pow(atom1->pos[0]-atom2->pos[0],2)+po w(atom1->pos[1]-atom2->pos[1],2)+pow(atom1->pos[2]atom2->pos[2],2)); if(distance<(gm_mass*slope+yint)*system->max_bondle ngth)is_bonded=1; elseis_bonded=0;returnis_bonded; }intcalculate_bonds(system_t*system){ intinner_index=0,outer_index=0;intbonds=0;doublebondlength;molecule_t*mol;atom_t*atom;atom_t*atom2;double*pos1,*pos2;for(mol=system->molecules;mol;mol=mol->next){ if(mol->frozen){ for(atom=mol->atoms;atom;atom=atom->next,inner_inde x++){ pos1=atom->pos;if(atom->next){ for(atom2=atom->next,outer_index=inner_index+1;atom 2;atom2=atom2->next,outer_index++){ pos2=atom2->pos;if(bondlength_check(atom,atom2,system)){ bonds++; } } } } } }returnbonds; }voidprint_frozen_bonds(FILE*fp_frozen,system_t*syst em) { intinner_index=0,outer_index=0;intbonds=0;doublebondlength;molecule_t*mol;atom_t*atom;atom_t*atom2;double*pos1,*pos2;for(mol=system->molecules;mol;mol=mol->next){ if(mol->frozen){ for(atom=mol->atoms;atom;atom=atom->next,inner_inde x++){ pos1=atom->pos;if(atom->next){ for(atom2=atom->next,outer_index=inner_index+1;atom 2;atom2=atom2->next,outer_index++){ pos2=atom2->pos;if(bondlength_check(atom,atom2,system)){ bonds++;fprintf(fp_frozen,"%d%d\n",inner_index,outer_index) ; } } } } } } }voidprint_frozen_masses(FILE*fp_frozen,system_t*sys tem) { molecule_t*mol;atom_t*atom;for(mol=system->molecules;mol;mol=mol->next){ if(mol->frozen){ for(atom=mol->atoms;atom;atom=atom->next){ fprintf(fp_frozen,"%f\n",atom->mass); } } } }voidprint_frozen_colors(FILE*fp_frozen,system_t*sys tem) { doublemass;molecule_t*mol;atom_t*atom;for(mol=system->molecules;mol;mol=mol->next){ if(mol->frozen){ for(atom=mol->atoms;atom;atom=atom->next){ mass=atom->mass;if(mass<1.1)fprintf(fp_frozen,"%s\n",COLOR_H);elseif(mass<12.2)fprintf(fp_frozen,"%s\n",COLOR_C);elseif(mass<14.1)fprintf(fp_frozen,"%s\n",COLOR_N); 219

PAGE 234

elseif(mass<16.1)fprintf(fp_frozen,"%s\n",COLOR_O);elsefprintf(fp_frozen,"%s\n",COLOR_XXX); } } } }voidwrite_frozen(FILE*fp_frozen,system_t*system){ inti,j,k;intnumatoms;intnumbonds;numatoms=count_frozen(system);numbonds=calculate_bonds(system);rewind(fp_frozen);fprintf(fp_frozen,"#OpenDXformatcoordinatefileforfr ozenatoms\n"); fprintf(fp_frozen,"object1classarraytypefloatrank1s hape3items%ddatafollows\n",numatoms); print_frozen_coords(fp_frozen,system);fprintf(fp_frozen,"object2classarraytypeintrank1sha pe2items%ddatafollows\n",numbonds); print_frozen_bonds(fp_frozen,system);fprintf(fp_frozen,"attribute\"elementtype\"string\" lines\"\n"); fprintf(fp_frozen,"attribute\"ref\"string\"position s\"\n"); fprintf(fp_frozen,"object3classarraytypefloatrank0i tems%ddatafollows\n",numatoms); print_frozen_masses(fp_frozen,system);fprintf(fp_frozen,"attribute\"dep\"string\"position s\"\n"); fprintf(fp_frozen,"object4classarraytypefloatrank1s hape3items%ddatafollows\n",numatoms); print_frozen_colors(fp_frozen,system);fprintf(fp_frozen,"object\"irregularpositionsirregu larconnections\"classfield\n"); fprintf(fp_frozen,"component\"positions\"value1\n") ; fprintf(fp_frozen,"component\"connections\"value2\n "); fprintf(fp_frozen,"component\"data\"value3\n");fprintf(fp_frozen,"component\"colors\"value4\n");fprintf(fp_frozen,"end\n"); }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#includesystem_t*read_config(char*input_file){ system_t*system;charlinebuffer[MAXLINE],*n;chartoken1[MAXLINE],token2[MAXLINE],token3[MAXLINE] ,token4[MAXLINE]; FILE*fp;system=calloc(1,sizeof(system_t));if(!system){ error("INPUT:couldn'tallocatesystemdatastructure\n" ); return(NULL); }system->pbc=calloc(1,sizeof(pbc_t));if(!system->pbc){ error("INPUT:couldn'tallocatethePBCdatastructure\n" ); return(NULL); }/*opentheconfigfileorerror*/fp=fopen(input_file,"r");if(!fp){ error("INPUT:couldn'topenconfigfile\n");return(NULL); }/*setthedefaultscalingto1*/system->scale_charge=1.0;system->scale_rd=1.0;system->rot_probability=1.0;/*sethistogramflagdefault:off*/system->calc_hist=0;system->hist_resolution=0.0;system->histogram_output=NULL;/*defaultewaldparameters*/system->ewald_alpha=EWALD_ALPHA;system->ewald_kmax=EWALD_KMAX;/*defaultpolarizationparameters*/system->polar_gamma=1.0;/*defaultrdLRCflag*/system->rd_lrc=1; #ifdefQM_ROTATION /*defaultQRparameters*/system->quantum_rotation_level_max=QUANTUM_ROTATION _LEVEL_MAX; system->quantum_rotation_l_max=QUANTUM_ROTATION_L_M AX; system->quantum_rotation_theta_max=QUANTUM_ROTATION _THETA_MAX; system->quantum_rotation_phi_max=QUANTUM_ROTATION_P HI_MAX; #endif/*QM_ROTATION*/ /*loopovereachline*/memset(linebuffer,0,MAXLINE);n=fgets(linebuffer,MAXLINE,fp); 220

PAGE 235

while(n){ /*grabalineandparseitout*/memset(token1,0,MAXLINE);memset(token2,0,MAXLINE);memset(token3,0,MAXLINE);memset(token4,0,MAXLINE);sscanf(linebuffer,"%s%s%s%s",token1,token2,token3,t oken4); if(!strcasecmp(token1,"ensemble")){ if(!strcasecmp(token2,"nvt")) system->ensemble=ENSEMBLE_NVT; elseif(!strcasecmp(token2,"uvt")) system->ensemble=ENSEMBLE_UVT; elseif(!strcasecmp(token2,"surf")) system->ensemble=ENSEMBLE_SURF; elseif(!strcasecmp(token2,"surf_fit")) system->ensemble=ENSEMBLE_SURF_FIT; elseif(!strcasecmp(token2,"nve")) system->ensemble=ENSEMBLE_NVE; }/*forNVEonly*/if(!strcasecmp(token1,"total_energy")) system->total_energy=atof(token2); if(!strcasecmp(token1,"surf_decomp")){ if(!strcasecmp(token2,"on")) system->surf_decomp=1; else system->surf_decomp=0; }if(!strcasecmp(token1,"surf_min")) system->surf_min=atof(token2); if(!strcasecmp(token1,"surf_max")) system->surf_max=atof(token2); if(!strcasecmp(token1,"surf_inc")) system->surf_inc=atof(token2); if(!strcasecmp(token1,"surf_ang")) system->surf_ang=atof(token2); if(!strcasecmp(token1,"surf_preserve")){ if(!strcasecmp(token2,"on")) system->surf_preserve=1; else system->surf_preserve=0; }if(!strcasecmp(token1,"seed")) system->seed=atol(token2); if(!strcasecmp(token1,"numsteps")) system->numsteps=atoi(token2); if(!strcasecmp(token1,"corrtime")) system->corrtime=atoi(token2); if(!strcasecmp(token1,"move_probability")) system->move_probability=atof(token2); if(!strcasecmp(token1,"rot_probability")) system->rot_probability=atof(token2); if(!strcasecmp(token1,"adiabatic_probability")) system->adiabatic_probability=atof(token2); if(!strcasecmp(token1,"insert_probability")) system->insert_probability=atof(token2); if(!strcasecmp(token1,"cavity_bias")){ if(!strcasecmp(token2,"on")) system->cavity_bias=1; else system->cavity_bias=0; }if(!strcasecmp(token1,"cavity_grid")) system->cavity_grid_size=atoi(token2); if(!strcasecmp(token1,"cavity_radius")) system->cavity_radius=atof(token2); if(!strcasecmp(token1,"temperature")) system->temperature=atof(token2); if(!strcasecmp(token1,"simulated_annealing")){ if(!strcasecmp(token2,"on")) system->simulated_annealing=1; else system->simulated_annealing=0; }if(!strcasecmp(token1,"simulated_annealing_schedule ")) system->simulated_annealing_schedule=atof(token2); if(!strcasecmp(token1,"pressure")) system->pressure=atof(token2); if(!strcasecmp(token1,"h2_fugacity")){ if(!strcasecmp(token2,"on")) system->h2_fugacity=1; else 221

PAGE 236

system->h2_fugacity=0; }if(!strcasecmp(token1,"co2_fugacity")){ if(!strcasecmp(token2,"on")) system->co2_fugacity=1; else system->co2_fugacity=0; }if(!strcasecmp(token1,"free_volume")) system->free_volume=atof(token2); if(!strcasecmp(token1,"rd_only")){ if(!strcasecmp(token2,"on")) system->rd_only=1; else system->rd_only=0; }if(!strcasecmp(token1,"rd_lrc")){ if(!strcasecmp(token2,"on")) system->rd_lrc=1; else system->rd_lrc=0; }if(!strcasecmp(token1,"rd_anharmonic")){ if(!strcasecmp(token2,"on")) system->rd_anharmonic=1; else system->rd_anharmonic=0; }if(!strcasecmp(token1,"rd_anharmonic_k")) system->rd_anharmonic_k=atof(token2); if(!strcasecmp(token1,"rd_anharmonic_g")) system->rd_anharmonic_g=atof(token2); if(!strcasecmp(token1,"feynman_hibbs")){ if(!strcasecmp(token2,"on")) system->feynman_hibbs=1; else system->feynman_hibbs=0; }if(!strcasecmp(token1,"feynman_kleinert")){ if(!strcasecmp(token2,"on")) system->feynman_kleinert=1; else system->feynman_kleinert=0; }if(!strcasecmp(token1,"feynman_hibbs_order")){ system->feynman_hibbs_order=atoi(token2); }if(!strcasecmp(token1,"wpi")){ if(!strcasecmp(token2,"on")) system->wpi=1; else system->wpi=0; }if(!strcasecmp(token1,"wpi_grid")) system->wpi_grid=atoi(token2); if(!strcasecmp(token1,"fvm")){ if(!strcasecmp(token2,"on")) system->fvm=1; else system->wpi=0; }if(!strcasecmp(token1,"sg")){ if(!strcasecmp(token2,"on")) system->sg=1; elseif(!strcasecmp(token2,"off")) system->sg=0; }if(!strcasecmp(token1,"wrapall")){ if(!strcasecmp(token2,"on")) system->wrapall=1; else system->wrapall=0; }if(!strcasecmp(token1,"scale_charge")){ system->scale_charge=atof(token2); }if(!strcasecmp(token1,"scale_rd")){ system->scale_rd=atof(token2); }if(!strcasecmp(token1,"ewald_alpha")){ system->ewald_alpha=atof(token2); }if(!strcasecmp(token1,"ewald_kmax")){ system->ewald_kmax=atoi(token2); }if(!strcasecmp(token1,"polarization")){ if(!strcasecmp(token2,"on")) system->polarization=1; 222

PAGE 237

else system->polarization=0; }if(!strcasecmp(token1,"cavity_autoreject")){ if(!strcasecmp(token2,"on")) system->cavity_autoreject=1; else system->cavity_autoreject=0; }if(!strcasecmp(token1,"cavity_autoreject_scale")){ system->cavity_autoreject_scale=atof(token2); }if(!strcasecmp(token1,"polar_ewald")){ if(!strcasecmp(token2,"on")) system->polar_ewald=1; else system->polar_ewald=0; }if(!strcasecmp(token1,"polarizability_tensor")){ if(!strcasecmp(token2,"on")) system->polarizability_tensor=1; else system->polarizability_tensor=0; }if(!strcasecmp(token1,"polar_zodid")){ if(!strcasecmp(token2,"on")) system->polar_zodid=1; else system->polar_zodid=0; }if(!strcasecmp(token1,"polar_iterative")){ if(!strcasecmp(token2,"on")) system->polar_iterative=1; else system->polar_iterative=0; }if(!strcasecmp(token1,"polar_palmo")){ if(!strcasecmp(token2,"on")) system->polar_palmo=1; else system->polar_palmo=0; }if(!strcasecmp(token1,"polar_gs")){ if(!strcasecmp(token2,"on")) system->polar_gs=1; else system->polar_gs=0; }if(!strcasecmp(token1,"polar_gs_ranked")){ if(!strcasecmp(token2,"on")) system->polar_gs_ranked=1; else system->polar_gs_ranked=0; }if(!strcasecmp(token1,"polar_sor")){ if(!strcasecmp(token2,"on")) system->polar_sor=1; else system->polar_sor=0; }if(!strcasecmp(token1,"polar_esor")){ if(!strcasecmp(token2,"on")) system->polar_esor=1; else system->polar_esor=0; }if(!strcasecmp(token1,"polar_gamma")){ system->polar_gamma=atof(token2); }if(!strcasecmp(token1,"polar_damp")){ system->polar_damp=atof(token2); }if(!strcasecmp(token1,"field_damp")){ system->field_damp=atof(token2); }if(!strcasecmp(token1,"polar_precision")){ system->polar_precision=atof(token2); }if(!strcasecmp(token1,"polar_max_iter")){ system->polar_max_iter=atoi(token2); }if(!strcasecmp(token1,"polar_damp_type")){ if(!strcasecmp(token2,"linear")) system->damp_type=DAMPING_LINEAR; elseif(!strcasecmp(token2,"exponential")) system->damp_type=DAMPING_EXPONENTIAL; else system->damp_type=0; } 223

PAGE 238

if(!strcasecmp(token1,"polar_self")){ if(!strcasecmp(token2,"on")) system->polar_self=1; else system->polar_self=0; } #ifdefQM_ROTATION if(!strcasecmp(token1,"quantum_rotation")){ if(!strcasecmp(token2,"on")) system->quantum_rotation=1; else system->quantum_rotation=0; }if(!strcasecmp(token1,"quantum_rotation_hindered")) { if(!strcasecmp(token2,"on")) system->quantum_rotation_hindered=1; else system->quantum_rotation_hindered=0; }if(!strcasecmp(token1,"quantum_rotation_hindered_ba rrier")){ system->quantum_rotation_hindered_barrier=atof(toke n2); }if(!strcasecmp(token1,"quantum_rotation_B")){ system->quantum_rotation_B=atof(token2); }if(!strcasecmp(token1,"quantum_rotation_level_max") ){ system->quantum_rotation_level_max=atof(token2); }if(!strcasecmp(token1,"quantum_rotation_l_max")){ system->quantum_rotation_l_max=atof(token2); } #endif/*QM_ROTATION*/#ifdefXXX if(!strcasecmp(token1,"quantum_vibration")){ if(!strcasecmp(token2,"on")) system->quantum_vibration=1; else system->quantum_vibration=0; } #endif/*XXX*/ if(!strcasecmp(token1,"pdb_input")){ if(!system->pdb_input){ system->pdb_input=calloc(MAXLINE,sizeof(char));strcpy(system->pdb_input,token2); } }if(!strcasecmp(token1,"pdb_output")){ if(!system->pdb_output){ system->pdb_output=calloc(MAXLINE,sizeof(char));strcpy(system->pdb_output,token2); } }if(!strcasecmp(token1,"pdb_restart")){ if(!system->pdb_restart){ system->pdb_restart=calloc(MAXLINE,sizeof(char));strcpy(system->pdb_restart,token2); } }if(!strcasecmp(token1,"traj_output")){ if(!system->traj_output){ system->traj_output=calloc(MAXLINE,sizeof(char));strcpy(system->traj_output,token2); } }if(!strcasecmp(token1,"energy_output")){ if(!system->energy_output){ system->energy_output=calloc(MAXLINE,sizeof(char));strcpy(system->energy_output,token2); } }if(!strcasecmp(token1,"pop_histogram_output")){ if(!system->histogram_output){ system->histogram_output=calloc(MAXLINE,sizeof(char )); strcpy(system->histogram_output,token2); } }if(system->polarization&&!strcasecmp(token1,"dipole _output")){ if(!system->dipole_output){ system->dipole_output=calloc(MAXLINE,sizeof(char));strcpy(system->dipole_output,token2); } }if(system->polarization&&!strcasecmp(token1,"field_ output")){ if(!system->field_output){ system->field_output=calloc(MAXLINE,sizeof(char));strcpy(system->field_output,token2); } }if(!strcasecmp(token1,"frozen_output")){ if(!system->frozen_output){ 224

PAGE 239

system->frozen_output=calloc(MAXLINE,sizeof(char));strcpy(system->frozen_output,token2); } }if(!strcasecmp(token1,"fit_input")){ if(!system->fit_input){ system->fit_input=calloc(MAXLINE,sizeof(char));strcpy(system->fit_input,token2); } }if(!strcasecmp(token1,"basis1")){ system->pbc->basis[0][0]=atof(token2);system->pbc->basis[0][1]=atof(token3);system->pbc->basis[0][2]=atof(token4); }if(!strcasecmp(token1,"basis2")){ system->pbc->basis[1][0]=atof(token2);system->pbc->basis[1][1]=atof(token3);system->pbc->basis[1][2]=atof(token4); }if(!strcasecmp(token1,"basis3")){ system->pbc->basis[2][0]=atof(token2);system->pbc->basis[2][1]=atof(token3);system->pbc->basis[2][2]=atof(token4); }if(!strcasecmp(token1,"max_bondlength")){ system->max_bondlength=atof(token2); }if(!strcasecmp(token1,"pop_histogram")){ if(!strcasecmp(token2,"on")) system->calc_hist=1; else system->calc_hist=0; }if(!strcasecmp(token1,"pop_hist_resolution")) system->hist_resolution=atof(token2); memset(linebuffer,0,MAXLINE);n=fgets(linebuffer,MAXLINE,fp); }/*closetheconfigfile*/fclose(fp);/*calculatethingsrelatedtotheperiodicboundarycondit ions*/ pbc(system->pbc);return(system); }doubleh2_fugacity(doubletemperature,doublepressure) { if((temperature==77.0)&&(pressure<=200.0)){ output("INPUT:fugacitycalculationusingZhoufunction\ n"); return(h2_fugacity_zhou(temperature,pressure)); }elseif(temperature>=273.15){ output("INPUT:fugacitycalculationusingShawfunction\ n"); return(h2_fugacity_shaw(temperature,pressure)); }else{ output("INPUT:fugacitycalculationusingBACKEoS\n");return(h2_fugacity_back(temperature,pressure)); }return(0);/*NOTREACHED*/ }/*usethesemi-empiricalBACKequationofstate*//*TomasBoublik,"TheBACKequationofstateforhydrogenan drelatedcompounds",FluidPhaseEquilibria,240,96-100( 2005)*/ doubleh2_fugacity_back(doubletemperature,doublepres sure){ doublefugacity_coefficient,fugacity;doublecomp_factor;doubleP,dP;/*integrate(z-1)/Pfrom0toP*/fugacity_coefficient=0;for(P=0.001,dP=0.001;P<=pressure;P+=dP){ comp_factor=h2_comp_back(temperature,P);fugacity_coefficient+=dP*(comp_factor-1.0)/P; }fugacity_coefficient=exp(fugacity_coefficient);comp_factor=h2_comp_back(temperature,pressure);printf("INPUT:BACKcompressibilityfactorat%.3fatmis% .3f\n",pressure,comp_factor); fugacity=pressure*fugacity_coefficient;return(fugacity); 225

PAGE 240

}#defineBACK_H2_ALPHA1.033#defineBACK_H2_U038.488#defineBACK_H2_V009.746#defineBACK_H2_N0.00#defineBACK_C0.12#defineBACK_MAX_M9#defineBACK_MAX_N4doubleh2_comp_back(doubletemperature,doublepressure ){ doublealpha,y;/*repulsivepartofthecompressibilityfa ctor*/ doubleV,V0,u,D[BACK_MAX_M][BACK_MAX_N];/*attractive part*/ intn,m;/*indicesfordoublesumofattractivepart*/doublecomp_factor;doublecomp_factor_repulsive;doublecomp_factor_attractive;doublefugacity;/*setuptheBACKuniversalDconstants*/D[0][0]=-8.8043;D[0][1]=2.9396;D[0][2]=-2.8225;D[0] [3]=0.34; D[1][0]=4.164627;D[1][1]=-6.0865383;D[1][2]=4.76001 48;D[1][3]=-3.1875014; D[2][0]=-48.203555;D[2][1]=40.137956;D[2][2]=11.257 177;D[2][3]=12.231796; D[3][0]=140.4362;D[3][1]=-76.230797;D[3][2]=-66.382 743;D[3][3]=-12.110681; D[4][0]=-195.23339;D[4][1]=-133.70055;D[4][2]=69.24 8785;D[4][3]=0.0; D[5][0]=113.515;D[5][1]=860.25349;D[5][2]=0.0;D[5][ 3]=0.0; D[6][0]=0.0;D[6][1]=-1535.3224;D[6][2]=0.0;D[6][3]= 0.0; D[7][0]=0.0;D[7][1]=1221.4261;D[7][2]=0.0;D[7][3]=0 .0; D[8][0]=0.0;D[8][1]=-409.10539;D[8][2]=0.0;D[8][3]= 0.0; /*calculateattractivepart*/V0=BACK_H2_V00*(1.0-BACK_C*exp(-3.0*BACK_H2_U0/temp erature)); V=NA*KB*temperature/(pressure*ATM2PASCALS*1.0e-6);u=BACK_H2_U0*(1.0+BACK_H2_N/temperature);comp_factor_attractive=0;for(n=0;n
PAGE 241

#defineMWCO244.0#defineW0.225/*acentricfactorforCO2*/#defineTc304.12/*criticaltemp(K)*/#definePc72.775/*criticalpress(atm)*/#defineRpr82.06/*atmcm^3/(molK)*//*readsintemperatureinK,andpressure(oftheidealgasin theresevoir)inatm*/ /*returntheCO2fugacityviathePeng-Robinsonequationof state*/ /*elsereturn0.0onerror-Idon'thaveanerrorstatement*//*unitsareatm,K,cm^3,gEvenfortheconstantsabove*/doubleco2_fugacity(doubletemperature,doublepressure ){ doublefugacity,lnfoverp,pressurePR;doubledensity_ig,a,b,Tr,alp1,alpha,Vm,Z,Af,Bf;doublep1,p2,f1,f2,f3,f4;/*calculateidealgasdensityfrominputtempandpress*/density_ig=pressure*MWCO2/(temperature*Rpr);/*calculatea,b,Tr,alpha,Vm,pressurePR*/a=0.45724*Rpr*Rpr*Tc*Tc/Pc;b=0.07780*Rpr*Tc/Pc;Tr=temperature/Tc;alp1=(1.0+(0.37464+1.54226*W-0.26992*W*W)*(1.0-sqrt (Tr))); alpha=alp1*alp1;Vm=MWCO2/density_ig;p1=Rpr*temperature/(Vm-b);p2=a*alpha/(Vm*Vm+2*b*Vm-b*b);pressurePR=p1-p2;/*calculateeachtermoffugacitywithPeng-RobinsonEOS*/Z=pressurePR*Vm/(Rpr*temperature);Af=a*pressurePR/(Rpr*Rpr*temperature*temperature);Bf=b*pressurePR/(Rpr*temperature);f1=(Z-1.0)-log(Z-Bf);f2=Af/(2*sqrt(2)*Bf);f3=Z+(1.0+sqrt(2))*Bf;f4=Z-(1.0-sqrt(2))*Bf;lnfoverp=f1-f2*log(f3/f4);fugacity=exp(lnfoverp)*pressurePR;return(fugacity); }intcheck_system(system_t*system){ charlinebuf[MAXLINE];switch(system->ensemble){ caseENSEMBLE_UVT: output("INPUT:Grandcanonicalensemble\n");break; caseENSEMBLE_NVT: output("INPUT:Canonicalensemble\n");break; caseENSEMBLE_SURF: output("INPUT:Potentialenergysurface\n");break; caseENSEMBLE_SURF_FIT: output("INPUT:Potentialenergysurfacefitting\n");break; caseENSEMBLE_NVE: output("INPUT:Microcanonicalensemble\n");break; case'?': error("INPUT:improperensemblespecified\n");return(-1); }if(system->ensemble==ENSEMBLE_SURF_FIT){ if(!system->fit_input){ error("INPUT:surfacefittingrequiresafit_inputfile\n "); return(-1); } }if(system->ensemble==ENSEMBLE_SURF){ output("INPUT:surfacemoduleactivated\n");if(system->surf_maxsurf_min){ error("INPUT:surf_maxisgreaterthansurf_min\n");return(-1); }else{ sprintf(linebuf,"INPUT:minimumsurfacecoordinateis%. 3f\n",system->surf_min); output(linebuf);sprintf(linebuf,"INPUT:maximumsurfacecoordinateis%. 3f\n",system->surf_max); output(linebuf); }if(system->surf_inc<=0.0){ error("INPUT:surf_incislessthanorequalto0\n");return(-1); }else{ sprintf(linebuf,"INPUT:incrementalsurfacedisplaceme ntcoordinateis%.3f\n",system->surf_inc); output(linebuf); }if(!system->surf_preserve&&(system->surf_ang<=0.0)) { error("INPUT:surf_angislessthanorequalto0\n"); 227

PAGE 242

return(-1); }else{ sprintf(linebuf,"INPUT:incrementalsurfaceanglecoord inateis%.3f\n",system->surf_ang); output(linebuf); } }if(system->rd_only)output("INPUT:calculatingrepulsi on/dispersiononly\n"); if(system->rd_lrc) output("INPUT:rdlong-rangecorrectionsareON\n"); else output("INPUT:rdlong-rangecorrectionsareOFF\n"); if(system->sg)output("INPUT:MolecularpotentialisSil vera-Goldman\n"); sprintf(linebuf,"INPUT:frozenatomchargesscaledby%.2 f\n",system->scale_charge); output(linebuf);sprintf(linebuf,"INPUT:frozenatomrdscaledby%.2f\n", system->scale_rd); output(linebuf);if(system->feynman_hibbs){ output("INPUT:Feynman-Hibbseffectivepotentialactiva ted\n"); if(system->feynman_kleinert){ output("INPUT:Feynman-Kleinertiterationmethodactiva ted\n"); if(!system->rd_anharmonic){ error("INPUT:Feynman-Kleinertiterationonlyimplement edforanharmonicoscillator\n"); return(-1); } }else{ switch(system->feynman_hibbs_order){ case2: sprintf(linebuf,"INPUT:Feynman-Hibbssecond-orderqua ntumcorrectionactivated\n"); output(linebuf);break; case4: sprintf(linebuf,"INPUT:Feynman-Hibbsfourth-orderqua ntumcorrectionactivated\n"); output(linebuf);break; default: output("INPUT:Feynman-Hibbsorderunspecified-default ingtoh^2\n"); system->feynman_hibbs_order=2;break; } } } #ifdefQM_ROTATION if(system->quantum_rotation){ output("INPUT:Quantumrotationaleigenspectrumcalcula tionenabled\n"); if(system->quantum_rotation_B<=0.0){ error("INPUT:invalidquantumrotationalconstantBspeci fied\n"); return(-1); }else{ sprintf(linebuf,"INPUT:QuantumrotationalconstantB=% .3fK(%.3fcm^-1)\n",system->quantum_rotation_B, system->quantum_rotation_B*KB/(100.0*H*C)); output(linebuf); }if(system->quantum_rotation_level_max<=0){ error("INPUT:invalidquantumrotationlevelmax\n");return(-1); }else{ sprintf(linebuf,"INPUT:Quantumrotationlevelmax=%d\n ",system->quantum_rotation_level_max); output(linebuf); }if(system->quantum_rotation_l_max<=0){ error("INPUT:invalidquantumrotationl_max\n");return(-1); }else{ sprintf(linebuf,"INPUT:Quantumrotationl_max=%d\n",s ystem->quantum_rotation_l_max); output(linebuf); }if(system->quantum_rotation_level_max>(system->quan tum_rotation_l_max+1)*(system->quantum_rotation_l_m ax+1)){ error("INPUT:quantumrotationallevelscannotexceedl_m ax+1Xl_max+1\n"); return(-1); } } #endif/*QM_ROTATION*/#ifdefXXX if(system->quantum_vibration)output("INPUT:Quantumv ibrationaleigenspectrumcalculationenabled\n"); #endif/*XXX*/ if(system->simulated_annealing){ if(system->ensemble!=ENSEMBLE_NVT){ error("INPUT:Simulatedannealingonlyvalidforcanonica lensemble\n"); return(-1); }else{ output("INPUT:Simulatedannealingactive\n"); } 228

PAGE 243

if((system->simulated_annealing_schedule<0.0)||(sys tem->simulated_annealing_schedule>1.0)){ error("INPUT:invalidsimulatedannealingtemperaturesc hedulespecified\n"); return(-1); }else{ sprintf(linebuf,"INPUT:Simulatedannealingtemperatur eschedule=%.3f\n",system->simulated_annealing_sched ule); output(linebuf); } }if(!system->pdb_input){ error("INPUT:mustspecifyaninputPDB\n");return(-1); }else{ sprintf(linebuf,"INPUT:molecularcoordinatesarein%s\ n",system->pdb_input); output(linebuf); }if(system->polarization){ output("INPUT:Tholepolarizationactivated\n");if(system->polar_iterative&&system->polarizability_ tensor){ error("INPUT:iterativepolarizabilitytensormethodnot implemented\n"); return(-1); }if(!system->polar_iterative&&system->polar_zodid){ error("INPUT:ZODIDandmatrixinversioncannotbothbeset !\n"); return(-1); }if(system->damp_type==DAMPING_LINEAR) output("INPUT:Tholelineardampingactivated\n"); elseif(system->damp_type==DAMPING_EXPONENTIAL) output("INPUT:Tholeexponentialdampingactivated\n"); else{ error("INPUT:Tholedampingmethodnotspecified\n");return(-1); }if(system->polar_damp<=0.0){ error("INPUT:dampingfactormustbespecified\n");return(-1); }else{ sprintf(linebuf,"INPUT:Tholedampingparameteris%.4f\ n",system->polar_damp); output(linebuf);sprintf(linebuf,"INPUT:Fielddampingparameteris%.4f\ n",system->field_damp); output(linebuf); }if(system->polar_iterative){ output("INPUT:Tholeiterativesolveractivated\n");if(system->polar_zodid){ output("INPUT:ZODIDpolarizationenabled\n"); }if((system->polar_precision>0.0)&&(system->polar_ma x_iter>0)){ error("INPUT:cannotspecifybothpolar_precisionandpol ar_max_iter,mustpickone\n"); return(-1); }if(system->polar_precision<0.0){ error("INPUT:invalidpolarizationiterativeprecisions pecified\n"); return(-1); }elseif(system->polar_precision>0.0){ sprintf(linebuf,"INPUT:Tholeiterativeprecisionis%eA *sqrt(KA)(%eD)\n",system->polar_precision, system->polar_precision/DEBYE2SKA); output(linebuf); }else{ sprintf(linebuf,"INPUT:usingpolarmaxSCFiterations=% d\n",system->polar_max_iter); output(linebuf); }if(system->polar_sor&&system->polar_esor){ error("INPUT:cannotspecifybothSORandESORSCFmethods\ n"); return(-1); }if(system->polar_sor)output("INPUT:SORSCFschemeacti ve\n"); elseif(system->polar_esor)output("INPUT:ESORSCFsche meactive\n"); if(system->polar_gamma<0.0){ error("INPUT:invalidPre-cond/SOR/ESORgammaset\n");return(-1); }else{ sprintf(linebuf,"INPUT:Pre-cond/SOR/ESORgamma=%.3f\ n",system->polar_gamma); output(linebuf); }if(system->polar_gs&&system->polar_gs_ranked){ error("INPUT:bothpolar_gsandpolar_gs_rankedcannotbe set\n"); return(-1); }if(system->polar_gs) output("INPUT:Gauss-Seideliterationschemeactive\n") ; elseif(system->polar_gs_ranked) output("INPUT:Gauss-SeidelRankediterationschemeacti ve\n"); if(system->polar_palmo)output("INPUT:Polarizationen ergyofPalmoandKrimmenabled\n"); 229

PAGE 244

}else{ output("INPUT:Matrixpolarizationactivated\n");if(system->polarizability_tensor) output("INPUT:Polarizabilitytensorcalculationactiva ted\n"); }if(system->polar_self)output("INPUT:Polarizationsel f-inductionisactive\n"); }if((system->pbc->volume<0.0)||(system->pbc->cutoff< 0.0)) error("INPUT:somethingiswrongwiththeperiodicboundar yconditions\n"); else{ sprintf(linebuf,"INPUT:basisvector1=%.5f%.5f%.5f\n" ,system->pbc->basis[0][0],system->pbc->basis[0][1], system->pbc->basis[0][2]); output(linebuf);sprintf(linebuf,"INPUT:basisvector2=%.5f%.5f%.5f\n" ,system->pbc->basis[1][0],system->pbc->basis[1][1], system->pbc->basis[1][2]); output(linebuf);sprintf(linebuf,"INPUT:basisvector3=%.5f%.5f%.5f\n" ,system->pbc->basis[2][0],system->pbc->basis[2][1], system->pbc->basis[2][2]); output(linebuf);sprintf(linebuf,"INPUT:unitcellvolume=%.3fA^3(cutof f=%.3fA)\n",system->pbc->volume,system->pbc->cutoff ); output(linebuf);sprintf(linebuf,"INPUT:recipbasisvector1=%.5f%.5f%. 5f\n",system->pbc->reciprocal_basis[0][0], system->pbc->reciprocal_basis[0][1],system->pbc->re ciprocal_basis[0][2]); output(linebuf);sprintf(linebuf,"INPUT:recipbasisvector2=%.5f%.5f%. 5f\n",system->pbc->reciprocal_basis[1][0], system->pbc->reciprocal_basis[1][1],system->pbc->re ciprocal_basis[1][2]); output(linebuf);sprintf(linebuf,"INPUT:recipbasisvector3=%.5f%.5f%. 5f\n",system->pbc->reciprocal_basis[2][0], system->pbc->reciprocal_basis[2][1],system->pbc->re ciprocal_basis[2][2]); output(linebuf); }if(system->rd_anharmonic){ if(!system->rd_only){ error("INPUT:rd_anharmonicbeingsetrequiresrd_only\n "); return(-1); }else{ sprintf(linebuf,"INPUT:rd_anharmonic_k=%.3fK/A^2\n" ,system->rd_anharmonic_k); output(linebuf);sprintf(linebuf,"INPUT:rd_anharmonic_g=%.3fK/A^4\n" ,system->rd_anharmonic_g); output(linebuf); } }if((system->ensemble!=ENSEMBLE_SURF)&&(system->ense mble!=ENSEMBLE_SURF_FIT)){ if(!system->seed){ error("INPUT:noseedspecified\n");return(-1); }else{ sprintf(linebuf,"INPUT:rngseedis%ld\n",system->seed ); output(linebuf); }if(system->numsteps<1){ error("INPUT:impropernumstepsspecified\n");return(-1); }else{ sprintf(linebuf,"INPUT:eachcoreperforming%dsimulati onsteps\n",system->numsteps); output(linebuf); }if(system->corrtime<1){ error("INPUT:impropercorrtimespecified\n");return(-1); }else{ sprintf(linebuf,"INPUT:systemcorrelationtimeis%dste ps\n",system->corrtime); output(linebuf); }if(system->ensemble!=ENSEMBLE_NVE){ if(system->temperature<=0.0){ error("INPUT:invalidtemperaturespecified\n");return(-1); }else{ sprintf(linebuf,"INPUT:systemtemperatureis%.3fK\n", system->temperature); output(linebuf); } }else{ sprintf(linebuf,"INPUT:NVEenergyis%.3fK\n",system-> total_energy); output(linebuf); }if(system->free_volume>0.0){ sprintf(linebuf,"INPUT:systemfree_volumeis%.3fA^3\n ",system->free_volume); output(linebuf); }if((system->ensemble==ENSEMBLE_UVT)&&(system->press ure<=0.0)){ error("INPUT:invalidpressuresetforGCMC\n");return(-1); }else{ if(system->ensemble==ENSEMBLE_UVT){ sprintf(linebuf,"INPUT:reservoirpressureis%.3fatm\n ",system->pressure); output(linebuf); }if(system->h2_fugacity){ system->fugacity=h2_fugacity(system->temperature,sy stem->pressure); if(system->h2_fugacity==0.0){ 230

PAGE 245

error("INPUT:errorinH2fugacityassignment\n");return(-1); }sprintf(linebuf,"INPUT:H2fugacity=%.3fatm\n",system ->fugacity); output(linebuf); }if(system->co2_fugacity){ system->fugacity=co2_fugacity(system->temperature,s ystem->pressure); if(system->co2_fugacity==0.0){ error("INPUT:errorinCO2fugacityassignment\n");return(-1); }sprintf(linebuf,"INPUT:CO2fugacity=%.3fatm\n",syste m->fugacity); output(linebuf); } }if((system->insert_probability<0.0)||(system->inser t_probability>1.0)){ error("INPUT:insertscaleinvalid,shouldbe(0,1)\n");return(-1); }else{ sprintf(linebuf,"INPUT:insertprobabilityis%.3f\n",s ystem->insert_probability); output(linebuf);sprintf(linebuf,"INPUT:moveprobabilityis%.3f\n",sys tem->move_probability); output(linebuf);sprintf(linebuf,"INPUT:rotationprobabilityis%.3f\n" ,system->rot_probability); output(linebuf); }/*autorejectinsertionscloserthansomescalingfactorof sigma*/ if(system->cavity_autoreject){ output("INPUT:cavityautorejectionactivated\n");if((system->cavity_autoreject_scale<=0.0)||(system>cavity_autoreject_scale>1.0)) error("INPUT:cavity_autoreject_scaleeithernotsetoro utofrange\n"); }if(system->cavity_bias){ if((system->cavity_grid_size<=0)||(system->cavity_r adius<=0.0)){ error("INPUT:invalidcavitygridorradiusspecified\n") ; }else{ output("INPUT:cavity-biasedumbrellasamplingactivate d\n"); sprintf(linebuf,"INPUT:cavitygridsizeis%dx%dx%dpoin tswithasphereradiusof%.3fA\n", system->cavity_grid_size,system->cavity_grid_size,s ystem->cavity_grid_size,system->cavity_radius); output(linebuf); } }if(!system->pdb_output){ error("INPUT:mustspecifyanoutputPDB\n");return(-1); }else{ sprintf(linebuf,"INPUT:willbewritingfinalconfigurat ionto%s\n",system->pdb_output); output(linebuf); }if(!system->pdb_restart){ error("INPUT:mustspecifyarestartPDB\n");return(-1); }else{ sprintf(linebuf,"INPUT:willbewritingrestartconfigur ationto%s\n",system->pdb_restart); output(linebuf); }if(!system->traj_output){ error("INPUT:mustspecifyatrajectoryPDB\n");return(-1); }else{ sprintf(linebuf,"INPUT:willbewritingtrajectoryto%s\ n",system->traj_output); output(linebuf); }if(system->polarization&&(!system->dipole_output||! system->field_output)){ error("INPUT:mustspecifyadipoleandfieldoutputfile\n "); return(-1); }elseif(system->polarization){ sprintf(linebuf,"INPUT:dipolefieldwillbewrittento%s \n",system->dipole_output); output(linebuf);sprintf(linebuf,"INPUT:electricfieldwillbewrittento %s\n",system->field_output); output(linebuf); }if(system->wpi){ output("INPUT:WidomParticleInsertionisenabled\n"); } }if(system->calc_hist){ output("INPUT:histogramcalculationwillbeperformed\n "); if(!system->hist_resolution){ output("INPUT:nohistogramresolutionsetbuthistogramc alculationrequested\n"); output("INPUT:settinghist_resolutiontodefaultvalueo f0.7A\n"); 231

PAGE 246

system->hist_resolution=0.7; }elseif(system->hist_resolution<0.01||system->hist_r esolution>5.0){ output("INPUT:histogramresolutionoutofbounds\n");output("INPUT:settinghist_resolutiontodefaultvalueo f0.7A\n"); system->hist_resolution=0.7; }elseif(!system->histogram_output){ output("INPUT:nohistogramoutputfileselected,default ingtohistogram.dat\n"); system->histogram_output=calloc(MAXLINE,sizeof(char )); sprintf(system->histogram_output,"histogram.dat"); }else{ sprintf(linebuf,"INPUT:histogramresolutionsetto%.3f A\n",system->hist_resolution); output(linebuf); }if(system->max_bondlength<.5){ output("INPUT:max_bondlengtheithernotsetoroutofboun ds\n"); output("INPUT:settingmax_bondlengthtodefaultvalueof 1.8A\n"); system->max_bondlength=1.8; }if(!system->frozen_output){ output("INPUT:nofrozen_outputset!settingfrozencoord inateoutputfiletofrozen.dx\n"); system->frozen_output=calloc(MAXLINE,sizeof(char));sprintf(system->frozen_output,"frozen.dx"); }else{ sprintf(linebuf,"INPUT:willbewritingfrozencoordinat esto%s\n",system->frozen_output); output(linebuf); } }return(0); }molecule_t*read_molecules(system_t*system){ inti;molecule_t*molecules,*molecule_ptr;atom_t*atom_ptr,*prev_atom_ptr;charlinebuf[MAXLINE],*n;FILE*fp;chartoken_atom[MAXLINE],token_atomid[MAXLINE],token _atomtype[MAXLINE],token_moleculetype[MAXLINE]; chartoken_frozen[MAXLINE],token_moleculeid[MAXLINE] ,token_x[MAXLINE],token_y[MAXLINE],token_z[MAXLINE] ; chartoken_mass[MAXLINE],token_charge[MAXLINE],token _alpha[MAXLINE],token_epsilon[MAXLINE],token_sigma[ MAXLINE]; intcurrent_frozen,current_adiabatic,current_molecul eid,current_atomid; doublecurrent_x,current_y,current_z;doublecurrent_mass,current_charge,current_alpha,cur rent_epsilon,current_sigma; doublecurrent_molecule_mass;intmoveable;intatom_counter;/*allocatethestartofthelist*/molecules=calloc(1,sizeof(molecule_t));molecule_ptr=molecules;molecule_ptr->id=1;molecule_ptr->atoms=calloc(1,sizeof(atom_t));atom_ptr=molecule_ptr->atoms;prev_atom_ptr=atom_ptr;/*openthemoleculeinputfile*/fp=fopen(system->pdb_input,"r");if(!fp){ sprintf(linebuf,"INPUT:couldn'topenPDBinputfile%s\n ",system->pdb_input); error(linebuf);return(NULL); }/*clearthelinebufferandreadthetokensin*/atom_counter=0;memset(linebuf,0,MAXLINE);n=fgets(linebuf,MAXLINE,fp);while(n){ /*clearthetokens*/memset(token_atom,0,MAXLINE);memset(token_atomid,0,MAXLINE);memset(token_atomtype,0,MAXLINE);memset(token_moleculetype,0,MAXLINE);memset(token_frozen,0,MAXLINE);memset(token_moleculeid,0,MAXLINE);memset(token_x,0,MAXLINE);memset(token_y,0,MAXLINE);memset(token_z,0,MAXLINE);memset(token_mass,0,MAXLINE);memset(token_charge,0,MAXLINE);memset(token_alpha,0,MAXLINE);memset(token_epsilon,0,MAXLINE);memset(token_sigma,0,MAXLINE);/*parsetheline*/sscanf(linebuf,"%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",tok en_atom,token_atomid,token_atomtype,token_moleculet ype, token_frozen,token_moleculeid,token_x,token_y,token _z,token_mass,token_charge,token_alpha,token_epsilo n,token_sigma); if(!strcasecmp(token_atom,"ATOM")&&strcasecmp(token _moleculetype,"BOX")){ current_frozen=0;current_adiabatic=0; 232

PAGE 247

if(!strcasecmp(token_frozen,"F")) current_frozen=1; if(!strcasecmp(token_frozen,"A")) current_adiabatic=1; current_moleculeid=atoi(token_moleculeid);current_atomid=atoi(token_atomid);current_x=atof(token_x);current_y=atof(token_y);current_z=atof(token_z);current_mass=atof(token_mass);/*massinamu*/current_charge=atof(token_charge);current_charge*=E2REDUCED;/*convertchargeintoreduce dunits*/ current_alpha=atof(token_alpha);current_epsilon=atof(token_epsilon);current_sigma=atof(token_sigma);if(current_frozen)current_charge*=system->scale_cha rge; if(molecule_ptr->id!=current_moleculeid){ molecule_ptr->next=calloc(1,sizeof(molecule_t));molecule_ptr=molecule_ptr->next;molecule_ptr->atoms=calloc(1,sizeof(atom_t));prev_atom_ptr->next=NULL;free(atom_ptr);atom_ptr=molecule_ptr->atoms; }strcpy(molecule_ptr->moleculetype,token_moleculetyp e); molecule_ptr->id=current_moleculeid;molecule_ptr->frozen=current_frozen;molecule_ptr->adiabatic=current_adiabatic;molecule_ptr->mass+=current_mass; #ifdefQM_ROTATION /*ifquantumrotcalc.enabled,allocatethenecessarystru ctures*/ if(system->quantum_rotation&&!molecule_ptr->frozen) { molecule_ptr->quantum_rotational_energies=calloc(sy stem->quantum_rotation_level_max,sizeof(double)); molecule_ptr->quantum_rotational_eigenvectors=callo c(system->quantum_rotation_level_max,sizeof(complex _t *)); for(i=0;iquantum_rotation_level_max;i++) molecule_ptr->quantum_rotational_eigenvectors[i]=ca lloc((system->quantum_rotation_l_max+ 1)*(system->quantum_rotation_l_max+1),sizeof(comple x_t)); molecule_ptr->quantum_rotational_eigensymmetry=call oc(system->quantum_rotation_level_max,sizeof(int)); } #endif/*QM_ROTATION*/#ifdefXXX /*ifquantumvibcalc.enabled,allocatethenecessarystru ctures*/ if(system->quantum_vibration&&!molecule_ptr->frozen ){ molecule_ptr->quantum_vibrational_energies=calloc(s ystem->quantum_vibration_level_max,sizeof(double)); molecule_ptr->quantum_vibrational_eigenvectors=call oc(system->quantum_vibration_level_max, sizeof(complex_t*)); for(i=0;iquantum_vibration_level_max;i++) molecule_ptr->quantum_vibrational_eigenvectors[i]=c alloc((system->quantum_vibration_l_max+ 1)*(system->quantum_vibration_l_max+1),sizeof(compl ex_t)); molecule_ptr->quantum_vibrational_eigensymmetry=cal loc(system->quantum_vibration_level_max,sizeof(int) ); } #endif/*XXX*/ ++atom_counter;atom_ptr->id=atom_counter;memset(atom_ptr->atomtype,0,MAXLINE);strcpy(atom_ptr->atomtype,token_atomtype);atom_ptr->frozen=current_frozen;atom_ptr->adiabatic=current_adiabatic;atom_ptr->pos[0]=current_x;atom_ptr->pos[1]=current_y;atom_ptr->pos[2]=current_z;atom_ptr->mass=current_mass;atom_ptr->charge=current_charge;atom_ptr->polarizability=current_alpha;atom_ptr->epsilon=current_epsilon;atom_ptr->sigma=current_sigma;atom_ptr->next=calloc(1,sizeof(atom_t));prev_atom_ptr=atom_ptr;atom_ptr=atom_ptr->next; }memset(linebuf,0,MAXLINE);n=fgets(linebuf,MAXLINE,fp); }/*terminatetheatomlist*/prev_atom_ptr->next=NULL;free(atom_ptr);/*scanthelist,makesurethatthereisatleastonemoveable molecule*/ for(molecule_ptr=molecules,moveable=0;molecule_ptr; molecule_ptr=molecule_ptr->next){ if(!molecule_ptr->frozen)++moveable; }if(!moveable){ error("INPUT:nomoveablemoleculesfound,theremustbeat leastoneinyourPDBfile\n"); return(NULL); }else return(molecules); }system_t*setup_system(char*input_file){ 233

PAGE 248

system_t*system;charlinebuf[MAXLINE];/*readinallofthetokensandparametersfromtheconfigfil e*/ system=read_config(input_file);if(!system){ error("INPUT:errorreadingconfigfile\n");return(NULL); }else output("INPUT:finishedreadingconfigfile\n"); /*validateconfigurationparameters*/if(check_system(system)<0){ error("INPUT:invalidconfigparametersspecified\n");return(NULL); }else output("INPUT:configfilevalidated\n"); /*readintheinputpdbandsetupthedatastructures*/system->molecules=read_molecules(system);if(!system->molecules){ error("INPUT:errorreadinginmolecules\n");return(NULL); }else output("INPUT:finishedreadinginmolecules\n"); /*allocatethenecessarypairs*/setup_pairs(system->molecules);output("INPUT:finishedallocatingpairlists\n");/*calculatetheperiodicboundaryconditions*/pbc(system->pbc);output("INPUT:finishedcalculatingperiodicboundaryco nditions\n"); /*getallofthepairwiseinteractions,exclusions,etc.*/if(system->cavity_bias)setup_cavity_grid(system);pairs(system);/*setallpairstoinitiallyhavetheirenergiescalculated */ flag_all_pairs(system);output("INPUT:finishedcalculatingpairwiseinteractio ns\n"); /*settheewaldgaussianwidthappropriately*/system->ewald_alpha=3.5/system->pbc->cutoff;if(!(system->sg||system->rd_only)){ sprintf(linebuf,"INPUT:Ewaldgaussianwidth=%fA\n",sy stem->ewald_alpha); output(linebuf);sprintf(linebuf,"INPUT:Ewaldkmax=%d\n",system->ewal d_kmax); output(linebuf); }/*writethefrozenlatticeconfiguration*/if(system->file_pointers.fp_frozen)write_frozen(sys tem->file_pointers.fp_frozen,system); return(system); }#ifdefDEBUGvoidtest_list(molecule_t*molecules){ molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;for(molecule_ptr=molecules;molecule_ptr;molecule_pt r=molecule_ptr->next){ printf("moleculeid=%d\n",molecule_ptr->id);printf("moleculetype=%s\n",molecule_ptr->moleculety pe); printf("molecule_frozen=%d\n",molecule_ptr->frozen) ; printf("molecule_mass=%f\n",molecule_ptr->mass);for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ printf("atomtype=%sx=%fy=%fz=%f\n",atom_ptr->atomty pe,atom_ptr->pos[0],atom_ptr->pos[1], atom_ptr->pos[2]); printf("atomfrozen=%dmass=%f,charge=%f,alpha=%f,eps =%f,sig=%f\n",atom_ptr->frozen, atom_ptr->mass,atom_ptr->charge,atom_ptr->polarizab ility,atom_ptr->epsilon,atom_ptr->sigma); for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next) if(!(pair_ptr->rd_excluded||pair_ptr->es_excluded|| pair_ptr->frozen))printf("pair=0x%lxeps=%fsig =%f\n",pair_ptr,pair_ptr->epsilon,pair_ptr->sigma); } }fflush(stdout); }voidtest_molecule(molecule_t*molecule){ atom_t*atom_ptr;pair_t*pair_ptr;printf("moleculeid=%d\n",molecule->id);printf("moleculetype=%s\n",molecule->moleculetype);printf("molecule_frozen=%d\n",molecule->frozen);printf("molecule_mass=%f\n",molecule->mass);for(atom_ptr=molecule->atoms;atom_ptr;atom_ptr=atom _ptr->next){ printf("atomtype=%sx=%fy=%fz=%f\n",atom_ptr->atomty pe,atom_ptr->pos[0],atom_ptr->pos[1],atom_ptr->pos[ 2]); printf("atomfrozen=%dmass=%f,charge=%f,alpha=%f,eps =%f,sig=%f\n",atom_ptr->frozen,atom_ptr->mass, atom_ptr->charge,atom_ptr->polarizability,atom_ptr>epsilon,atom_ptr->sigma); for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next){ printf("pairat0x%lx\n",pair_ptr);fflush(stdout); } } printf("...finished\n");fflush(stdout); 234

PAGE 249

}#endif/*DEBUG*//*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#includevoidmpi_copy_histogram_to_sendbuffer(char*snd,int** *grid,system_t*system){ inti,j,k;intx_dim=system->grids->histogram->x_dim;inty_dim=system->grids->histogram->y_dim;intz_dim=system->grids->histogram->z_dim;int*sndcast=(int*)snd;/*castthesendbufferaddresstoa n(int*)*/ /*histogram*/for(k=0;kgrids->his togram->grid[i][j][k]; } } } }voidmpi_copy_rcv_histogram_to_data(char*rcv,int***h istogram,system_t*system) { inti,j,k;intx_dim=system->grids->histogram->x_dim;inty_dim=system->grids->histogram->y_dim;intz_dim=system->grids->histogram->z_dim;int*rcvcast=(int*)rcv; /*histogram*/for(k=0;kvoiderror(char*msg){ if(!rank)fprintf(stderr,"%s",msg);fflush(stderr); }voidoutput(char*msg){ if(!rank)printf("%s",msg);fflush(stdout); }intopen_files(system_t*system){ if(system->energy_output){ system->file_pointers.fp_energy=fopen(system->energ y_output,"w"); if(!system->file_pointers.fp_energy){ error("MC:couldnotopenenergyfileforwriting\n");return(-1); } }if(system->traj_output){ system->file_pointers.fp_traj=fopen(system->traj_ou tput,"w"); if(!system->file_pointers.fp_traj){ error("MC:couldnotopentrajectoryfileforwriting\n");return(-1); } }if(system->dipole_output){ system->file_pointers.fp_dipole=fopen(system->dipol e_output,"w"); if(!system->file_pointers.fp_dipole){ error("MC:couldnotopendipolefileforwriting\n");return(-1); } 235

PAGE 250

}if(system->field_output){ system->file_pointers.fp_field=fopen(system->field_ output,"w"); if(!system->file_pointers.fp_field){ error("MC:couldnotopenfieldfileforwriting\n");return(-1); } }if(system->histogram_output){ system->file_pointers.fp_histogram=fopen(system->hi stogram_output,"w"); if(!system->file_pointers.fp_histogram){ error("MC:couldnotopenenergyfileforwriting\n");return(-1); } }if(system->frozen_output){ system->file_pointers.fp_frozen=fopen(system->froze n_output,"w"); if(!system->file_pointers.fp_frozen){ error("MC:couldnotopenfrozendxfileforwriting\n");return(-1); } }return(0); }voidclose_files(system_t*system){ if(system->file_pointers.fp_energy)fclose(system->f ile_pointers.fp_energy); if(system->file_pointers.fp_traj)fclose(system->fil e_pointers.fp_traj); if(system->file_pointers.fp_dipole)fclose(system->f ile_pointers.fp_dipole); if(system->file_pointers.fp_field)fclose(system->fi le_pointers.fp_field); if(system->file_pointers.fp_histogram)fclose(system ->file_pointers.fp_histogram); if(system->file_pointers.fp_frozen)fclose(system->f ile_pointers.fp_frozen); }/*enforcemoleculewrappingaroundtheperiodicboundarie sonoutput-keeptheatomstogether*/ intwrapall(molecule_t*molecules,pbc_t*pbc){ inti,j;molecule_t*molecule_ptr;atom_t*atom_ptr;doubled[3],dimg[3];for(molecule_ptr=molecules;molecule_ptr;molecule_pt r=molecule_ptr->next){ if(!molecule_ptr->frozen){ /*gettheminimumimagingdistanceforthecom*/for(i=0;i<3;i++){ for(j=0,d[i]=0;j<3;j++){ d[i]+=pbc->reciprocal_basis[i][j]*molecule_ptr->com [j]; }d[i]=rint(d[i]); }for(i=0;i<3;i++){ for(j=0,dimg[i]=0;j<3;j++) dimg[i]+=pbc->basis[i][j]*d[j]; /*storethewrappedcomcoordinate*/molecule_ptr->wrapped_com[i]=dimg[i]; }/*applythedistancetoalloftheatomsofthismolecule*/for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(i=0;i<3;i++) atom_ptr->wrapped_pos[i]=atom_ptr->pos[i]-dimg[i]; } }else{ /*don'twrapfrozen*/for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(i=0;i<3;i++) atom_ptr->wrapped_pos[i]=atom_ptr->pos[i]; } } }/*molecule*/return(0); }/*writeoutthefinalsystemstateasaPDBfile*/intwrite_molecules(system_t*system,char*filename){ molecule_t*molecule_ptr;atom_t*atom_ptr;charlinebuf[MAXLINE];FILE*fp;inti,j,k;intatom_box,molecule_box,p,q;doublebox_pos[3],box_occupancy[3];intl,m,n,box_labels[2][2][2],diff;fp=fopen(filename,"w");if(!fp){ 236

PAGE 251

sprintf(linebuf,"OUTPUT:couldnotwritepdbtofile%s\n" ,filename); error(linebuf);return(-1); }/*writepdb*/for(molecule_ptr=system->molecules,i=1,j=1;molecule _ptr;molecule_ptr=molecule_ptr->next,j++){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next,i++){ fprintf(fp,"ATOM");fprintf(fp,"%5d",i);/*giveeachoneauniqueid*/fprintf(fp,"%-4.45s",atom_ptr->atomtype);fprintf(fp,"%-3.3s",molecule_ptr->moleculetype);if(atom_ptr->adiabatic) fprintf(fp,"%-1.1s","A"); elseif(atom_ptr->frozen) fprintf(fp,"%-1.1s","F"); else fprintf(fp,"%-1.1s","M"); fprintf(fp,"%4d",j);/*giveeachmoleculeauniqueid*/if(system->wrapall){ fprintf(fp,"%8.3f",atom_ptr->wrapped_pos[0]);fprintf(fp,"%8.3f",atom_ptr->wrapped_pos[1]);fprintf(fp,"%8.3f",atom_ptr->wrapped_pos[2]); }else{ fprintf(fp,"%8.3f",atom_ptr->pos[0]);fprintf(fp,"%8.3f",atom_ptr->pos[1]);fprintf(fp,"%8.3f",atom_ptr->pos[2]); }fprintf(fp,"%8.4f",atom_ptr->mass);fprintf(fp,"%8.4f",atom_ptr->charge/E2REDUCED);/*co nvertchargebacktorealunits*/ fprintf(fp,"%8.5f",atom_ptr->polarizability);fprintf(fp,"%8.5f",atom_ptr->epsilon);fprintf(fp,"%8.5f",atom_ptr->sigma);fprintf(fp,"\n"); } }if(system->wrapall){ /*outputtheboxcoordsasvirtualparticlesforvisualizat ion*/ atom_box=i;molecule_box=j;for(i=0;i<2;i++){ for(j=0;j<2;j++){ for(k=0;k<2;k++){/*makethisfrozen*/fprintf(fp,"ATOM");fprintf(fp,"%5d",atom_box);fprintf(fp,"%-4.45s","X");fprintf(fp,"%-3.3s","BOX");fprintf(fp,"%-1.1s","F");fprintf(fp,"%4d",molecule_box);/*boxcoords*/box_occupancy[0]=((double)i)-0.5;box_occupancy[1]=((double)j)-0.5;box_occupancy[2]=((double)k)-0.5;for(p=0;p<3;p++) for(q=0,box_pos[p]=0;q<3;q++) box_pos[p]+=system->pbc->basis[p][q]*box_occupancy[ q]; for(p=0;p<3;p++) fprintf(fp,"%8.3f",box_pos[p]); /*nullinteractions*/fprintf(fp,"%8.4f",0.0);fprintf(fp,"%8.4f",0.0);fprintf(fp,"%8.5f",0.0);fprintf(fp,"%8.5f",0.0);fprintf(fp,"%8.5f",0.0);fprintf(fp,"\n");box_labels[i][j][k]=atom_box;++atom_box;} } }/*outputtheconnectivityinformation*/for(i=0;i<2;i++){ for(j=0;j<2;j++){ for(k=0;k<2;k++){ for(l=0;l<2;l++){ for(m=0;m<2;m++){ for(n=0;n<2;n++){ diff=fabs(i-l)+fabs(j-m)+fabs(k-n);if(diff==1) fprintf(fp,"CONECT%4d%4d\n",box_labels[i][j][k], box_labels[l][m][n]); }/*n*/ }/*m*/ }/*l*/ }/*k*/ }/*j*/ }/*i*/ }/*ifwrapall*/ 237

PAGE 252

fprintf(fp,"END\n");fflush(fp);fclose(fp);return(0); }voidwrite_states(FILE*fp,molecule_t*molecules){ molecule_t*molecule_ptr;atom_t*atom_ptr;charlinebuf[MAXLINE];inti,j,k;intatom_box,molecule_box,p,q;doublebox_pos[3],box_occupancy[3];intl,m,n,box_labels[2][2][2],diff;intnum_frozen_molecules,num_moveable_molecules;intnum_frozen_atoms,num_moveable_atoms;/*countthenumberofmolecules,atoms,etc.*/num_frozen_molecules=0,num_moveable_molecules=0;num_frozen_atoms=0,num_moveable_atoms=0;for(molecule_ptr=molecules;molecule_ptr;molecule_pt r=molecule_ptr->next){ if(molecule_ptr->frozen){ ++num_frozen_molecules;for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next) ++num_frozen_atoms; }else{ ++num_moveable_molecules;for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next) ++num_moveable_atoms; } }fprintf(fp,"REMARKtotal_molecules=%d,total_atoms=%d \n",(num_frozen_molecules+num_moveable_molecules),( num_frozen_atoms+ num_moveable_atoms)); fprintf(fp,"REMARKfrozen_molecules=%d,moveable_mole cules=%d\n",num_frozen_molecules,num_moveable_molec ules); fprintf(fp,"REMARKfrozen_atoms=%d,moveable_atoms=%d \n",num_frozen_atoms,num_moveable_atoms); /*writepdbformattedstates*/for(molecule_ptr=molecules,i=1,j=1;molecule_ptr;mol ecule_ptr=molecule_ptr->next,j++){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next,i++){ fprintf(fp,"ATOM");fprintf(fp,"%5d",i);/*giveeachoneauniqueid*/fprintf(fp,"%-4.45s",atom_ptr->atomtype);fprintf(fp,"%-3.3s",molecule_ptr->moleculetype);if(atom_ptr->adiabatic) fprintf(fp,"%-1.1s","A"); elseif(atom_ptr->frozen) fprintf(fp,"%-1.1s","F"); else fprintf(fp,"%-1.1s","M"); fprintf(fp,"%4d",j);/*giveeachmoleculeauniqueid*/fprintf(fp,"%8.3f",atom_ptr->wrapped_pos[0]);fprintf(fp,"%8.3f",atom_ptr->wrapped_pos[1]);fprintf(fp,"%8.3f",atom_ptr->wrapped_pos[2]);fprintf(fp,"%8.4f",atom_ptr->mass);fprintf(fp,"%8.4f",atom_ptr->charge/E2REDUCED);/*co nvertchargebacktorealunits*/ fprintf(fp,"%8.5f",atom_ptr->polarizability);fprintf(fp,"%8.5f",atom_ptr->epsilon);fprintf(fp,"%8.5f",atom_ptr->sigma);fprintf(fp,"\n"); } }fprintf(fp,"ENDMDL\n");fflush(fp); }intwrite_performance(inti,system_t*system){ charlinebuf[MAXLINE];time_tcurrent_time;doublesec_step;statictime_tlast_time;staticintlast_step;current_time=time(NULL);if(i>system->corrtime){ sec_step=difftime(current_time,last_time)/((double) (i-last_step)); if(system->ensemble==ENSEMBLE_UVT){ sprintf(linebuf,"OUTPUT:GrandCanonicalMonteCarlosim ulationrunningon%dcores\n",size); output(linebuf); }else{ sprintf(linebuf,"OUTPUT:CanonicalMonteCarlosimulati onrunningon%dcores\n",size); output(linebuf); }sprintf(linebuf,"OUTPUT:Rootcollectingstatisticsat% s",ctime(¤t_time)); output(linebuf);sprintf(linebuf,"OUTPUT:Completedstep%d/%d\n",i,sys tem->numsteps); output(linebuf);sprintf(linebuf,"OUTPUT:%fsec/step,ETA=%.3fhrs\n",s ec_step,sec_step*(system->numsteps-i)/3600.0); output(linebuf); }last_step=i;last_time=current_time; 238

PAGE 253

return(0); }voidwrite_observables(FILE*fp_energy,observables_t* observables){ fprintf(fp_energy,"%f%f%f%f%f%f%f\n",observables->e nergy,observables->coulombic_energy,observables->rd _energy, observables->polarization_energy,observables->kinet ic_energy,observables->temperature,observables->N); fflush(fp_energy); }intwrite_averages(avg_observables_t*averages){ if(averages->boltzmann_factor>0.0) printf("OUTPUT:BF=%.3f+-%.3f\n",averages->boltzmann _factor,0.5*averages->boltzmann_factor_error); if(averages->acceptance_rate>0.0){ printf("OUTPUT:AR=%.3f(%.3fI/%.3fR/%.3fD",averages>acceptance_rate,averages->acceptance_rate_insert, averages->acceptance_rate_remove,averages->acceptan ce_rate_displace); if(averages->acceptance_rate_adiabatic>0.0)printf(" /%.3fA",averages->acceptance_rate_adiabatic); printf(")\n"); }if(averages->cavity_bias_probability>0.0) printf("OUTPUT:Cavitybiasprobability=%.5f+-%.5f\n", averages->cavity_bias_probability, 0.5*averages->cavity_bias_probability_error); printf("OUTPUT:potentialenergy=%.3f+-%.3fK\n",avera ges->energy,0.5*averages->energy_error); if(averages->coulombic_energy!=0.0) printf("OUTPUT:electrostaticenergy=%.3f+-%.3fK\n",a verages->coulombic_energy,0.5*averages->coulombic_e nergy_error); printf("OUTPUT:repulsion/dispersionenergy=%.3f+-%.3 fK\n",averages->rd_energy,0.5*averages->rd_energy_e rror); if(averages->polarization_energy!=0.0){ printf("OUTPUT:polarizationenergy=%.5f+-%.5fK",aver ages->polarization_energy, 0.5*averages->polarization_energy_error); if(averages->polarization_iterations!=0.0) printf("(iterations=%.1f+-%.1frrms=%e+-%e)",average s->polarization_iterations, 0.5*averages->polarization_iterations_error,average s->dipole_rrms,0.5*averages->dipole_rrms_error); printf("\n"); }if(averages->kinetic_energy>0.0){ printf("OUTPUT:kineticenergy=%.3f+-%.3fK\n",average s->kinetic_energy,0.5*averages->kinetic_energy_erro r); printf("OUTPUT:temperature=%.3f+-%.3fK\n",averages>temperature,0.5*averages->temperature); }printf("OUTPUT:N=%.3f+-%.3fmolecules\n",averages->N ,0.5*averages->N_error); printf("OUTPUT:density=%.5f+-%.5fg/cm^3\n",averages ->density,0.5*averages->density_error); if(averages->pore_density!=0.0) printf("OUTPUT:poredensity=%.5f+-%.5fg/cm^3\n",aver ages->pore_density,0.5*averages->pore_density_error ); if(averages->percent_wt>0.0){ printf("OUTPUT:wt%%=%.5f+-%.5f%%\n",averages->perce nt_wt,0.5*averages->percent_wt_error); printf("OUTPUT:wt%%(ME)=%.5f+-%.5f%%\n",averages->p ercent_wt_me,0.5*averages->percent_wt_me_error); }if(averages->excess_ratio>0.0) printf("OUTPUT:excessadsorptionratio=%.5f+-%.5fmg/g \n",averages->excess_ratio,0.5*averages->excess_rat io_error); if(averages->qst>0.0){ if(averages->qst_error>MAXDOUBLE)/*lackoferrorbar,a voidnanfromsqrt(-small)*/ printf("OUTPUT:qst=%.3f+-N/AkJ/mol\n",averages->qst ); else printf("OUTPUT:qst=%.3f+-%.3fkJ/mol\n",averages->qs t,0.5*averages->qst_error); }if(averages->heat_capacity>0.0){ if(averages->heat_capacity_error>MAXDOUBLE) printf("OUTPUT:heatcapacity=%.3f+-N/AkJ/molK\n",ave rages->heat_capacity); else printf("OUTPUT:heatcapacity=%.3f+-%.3fkJ/molK\n",av erages->heat_capacity, 0.5*averages->heat_capacity_error); }if(averages->compressibility>0.0){ if(averages->compressibility_error>MAXDOUBLE){ printf("OUTPUT:compressibility=%.6f+-N/Aatm^-1\n",a verages->compressibility); printf("OUTPUT:bulkmodulus=%.6f+-N/AGPa\n",ATM2PASC ALS*1.0e-9/averages->compressibility); }else{ printf("OUTPUT:compressibility=%.6f+-%.6fatm^-1\n", averages->compressibility, 0.5*averages->compressibility_error); printf("OUTPUT:bulkmodulus=%.6f+-%.6fGPa\n",ATM2PAS CALS*1.0e-9/averages->compressibility, ATM2PASCALS*1.0e-9/(0.5*averages->compressibility_e rror)); } }printf("\n");fflush(stdout);return(0); }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/ 239

PAGE 254

#include/*freeamoleculeandallofit'sassociatedstuff*/voidfree_molecule(system_t*system,molecule_t*molecu le){ inti;molecule->next=NULL; #ifdefQM_ROTATION if(system->quantum_rotation&&!molecule->frozen){ free(molecule->quantum_rotational_energies);free(molecule->quantum_rotational_eigensymmetry);for(i=0;iquantum_rotation_level_max;i++) free(molecule->quantum_rotational_eigenvectors[i]); free(molecule->quantum_rotational_eigenvectors); } #endif/*QM_ROTATION*/ free_pairs(molecule);free_atoms(molecule);free(molecule); }voidfree_pairs(molecule_t*molecules){ inti;pair_t**ptr_array;molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;/*buildanarrayofptrstobefreed*/for(molecule_ptr=molecules,i=0,ptr_array=NULL;molec ule_ptr;molecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next){ ptr_array=realloc(ptr_array,sizeof(pair_t*)*(i+1));ptr_array[i]=pair_ptr;++i; } } }/*freethewholearrayofptrs*/for(--i;i>=0;i--)free(ptr_array[i]);/*zeroouttheheads*/for(molecule_ptr=molecules;molecule_ptr;molecule_pt r=molecule_ptr->next) for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next) atom_ptr->pairs=NULL; /*freeourtemporaryarray*/if(ptr_array)free(ptr_array); }voidfree_atoms(molecule_t*molecules){ inti,n;atom_t**ptr_array;molecule_t*molecule_ptr;atom_t*atom_ptr;/*buildtheptrarray*/for(molecule_ptr=molecules,i=0,n=0,ptr_array=NULL;m olecule_ptr;molecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ ptr_array=realloc(ptr_array,sizeof(atom_t*)*(i+1));ptr_array[i]=atom_ptr;++i,++n; } }/*freethewholearrayofptrs*/for(i=0;inext){ ptr_array=realloc(ptr_array,sizeof(molecule_t*)*(i+ 1)); ptr_array[i]=molecule_ptr;++i; }/*freethewholearrayofptrs*/for(--i;i>=0;i--)free(ptr_array[i]);/*freeourtemporaryarray*/free(ptr_array); } 240

PAGE 255

/*freethepolarizationmatrices*/voidfree_matrices(system_t*system){ inti,N;N=3*system->checkpoint->N_atom;for(i=0;iA_matrix[i]);if(!system->polar_iterative) free(system->B_matrix[i]); }free(system->A_matrix);free(system->B_matrix); }/*freethecavitybiasinsertiongrid*/voidfree_cavity_grid(system_t*system){ inti,j,N;N=system->cavity_grid_size;for(i=0;icavity_grid[i][j]); free(system->cavity_grid[i]); }free(system->cavity_grid); }#ifdefQM_ROTATION/*freestructuresassociatedwithquantumrotations*/voidfree_rotational(system_t*system){ inti;molecule_t*molecule_ptr;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ if(!molecule_ptr->frozen){ free(molecule_ptr->quantum_rotational_energies);free(molecule_ptr->quantum_rotational_eigensymmetry ); for(i=0;iquantum_rotation_level_max;i++) free(molecule_ptr->quantum_rotational_eigenvectors[ i]); free(molecule_ptr->quantum_rotational_eigenvectors) ; } } }#endif/*QM_ROTATION*//*freeallofourdatastructures*/voidcleanup(system_t*system){#ifdefQM_ROTATION if(system->quantum_rotation)free_rotational(system) ; #endif/*QM_ROTATION*/ free_pairs(system->molecules);free_atoms(system->molecules);free_molecules(system->molecules);free(system->pdb_input);free(system->pdb_output);free(system->energy_output);if(system->traj_output)free(system->traj_output);if(system->dipole_output)free(system->dipole_output ); if(system->field_output)free(system->field_output);if(system->polarization)free_matrices(system);if(system->cavity_bias)free_cavity_grid(system);free(system); }/*onSIGTERM,cleanupandexit*/voidterminate_handler(intsigtype,system_t*sys_ptr){ staticsystem_t*system;switch(sigtype){ caseSIGTERM: output("CLEANUP:************SIGTERMreceived,exiting *************\n"); close_files(sys_ptr);cleanup(system); #ifdefMPI if(!rank)close_files(sys_ptr);MPI_Finalize(); #else exit(1); #endif/*MPI*/ break; 241

PAGE 256

caseSIGUSR1: output("CLEANUP:************SIGUSR1received,exiting *************\n"); close_files(sys_ptr);cleanup(system); #ifdefMPI if(!rank)close_files(sys_ptr);MPI_Finalize(); #else exit(1); #endif/*MPI*/ break; caseSIGUSR2: output("CLEANUP:************SIGUSR2received,exiting *************\n"); close_files(sys_ptr);cleanup(system); #ifdefMPI if(!rank)close_files(sys_ptr);MPI_Finalize(); #else exit(1); #endif/*MPI*/ break; case-1:/*installthestaticptr*/ system=sys_ptr;break; } }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/intrank,size;#includevoidusage(char*progname){ if(!rank)fprintf(stderr,"usage:%s\n",progna me); #ifdefMPI MPI_Finalize(); #else exit(1); #endif/*MPI*/}voidseed_rng(longintseed){ rule30_rng(seed); }doubleget_rand(void){ return(rule30_rng(0)); }intmain(intargc,char**argv){ inti,j,N;molecule_t*molecule_ptr;atom_t*atom_ptr;charlinebuf[MAXLINE];charinput_file[MAXLINE];system_t*system;/*setthedefaultrank*/rank=0;size=1;/*checkargs*/if(argc<2)usage(argv[0]);if(!argv[1]){ error("MAIN:invalidconfigfilespecified");exit(1); }/*startuptheMPIchain*/ #ifdefMPI MPI_Init(&argc,&argv);MPI_Comm_rank(MPI_COMM_WORLD,&rank);MPI_Comm_size(MPI_COMM_WORLD,&size);sprintf(linebuf,"MAIN:processesstartedon%dcores\n", size); output(linebuf); #endif/*MPI*/ /*gettheconfigfilearg*/strcpy(input_file,argv[1]);sprintf(linebuf,"MAIN:runningparametersfoundin%s\n" ,input_file); output(linebuf);/*readtheinputfilesandsetupthesimulation*/system=setup_system(input_file);if(!system){ error("MAIN:couldnotinitializethesimulation\n"); #ifdefMPI 242

PAGE 257

MPI_Finalize(); #else exit(1); #endif/*MPI*/ }else{ output("MAIN:thesimulationhasbeeninitialized\n"); }/*installthesignalhandlertocatchSIGTERMcleanly*/terminate_handler(-1,system);signal(SIGTERM,((void*)(terminate_handler)));signal(SIGUSR1,((void*)(terminate_handler)));signal(SIGUSR2,((void*)(terminate_handler)));output("MAIN:signalhandlerinstalled\n");/*allocatespaceforthestatistics*/system->nodestats=calloc(1,sizeof(nodestats_t));system->avg_nodestats=calloc(1,sizeof(avg_nodestats _t)); system->observables=calloc(1,sizeof(observables_t)) ; system->avg_observables=calloc(1,sizeof(avg_observa bles_t)); system->checkpoint=calloc(1,sizeof(checkpoint_t));system->checkpoint->observables=calloc(1,sizeof(obs ervables_t)); system->grids=calloc(1,sizeof(grid_t));system->grids->histogram=calloc(1,sizeof(histogram_ t)); system->grids->avg_histogram=calloc(1,sizeof(histog ram_t)); if(!system->observables||!system->avg_observables|| !system->checkpoint||!system->checkpoint->observabl es){ error("MAIN:couldn'tallocatespaceforstatisticsand/o rcheckpoint\n"); exit(1); }/*ifpolarizationactive,allocatethenecessarymatrices */ if(system->polarization){ /*countthenumberofatomsinitiallyinthesystem*/for(molecule_ptr=system->molecules,N=0;molecule_ptr ;molecule_ptr=molecule_ptr->next) for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next) ++N; system->A_matrix=calloc(3*N,sizeof(double*));for(i=0;i<3*N;i++)system->A_matrix[i]=calloc(3*N,si zeof(double)); if(!system->polar_iterative){ system->B_matrix=calloc(3*N,sizeof(double*));for(i=0;i<3*N;i++)system->B_matrix[i]=calloc(3*N,si zeof(double)); } }/*ifhistogramcalculationflagisset,allocategrid*/if(system->calc_hist){ setup_histogram(system);allocate_histogram_grid(system); }/*seedtherng*/seed_rng(system->seed+rank);output("MAIN:therandomseedsonthecomputecoresarealls et\n"); #ifdefMPI MPI_Barrier(MPI_COMM_WORLD);sprintf(linebuf,"MAIN:all%dcoresareinsync\n",size);output(linebuf); #endif/*MPI*/ /*starttheMCsimulation*/if(system->ensemble==ENSEMBLE_UVT){ output("MAIN:************************************** *****************\n"); output("MAIN:***startingGrandCanonicalMonteCarlosim ulation***\n"); output("MAIN:************************************** *****************\n"); }elseif(system->ensemble==ENSEMBLE_NVT){ output("MAIN:************************************** ***********\n"); output("MAIN:***startingCanonicalMonteCarlosimulati on***\n"); output("MAIN:************************************** ***********\n"); }elseif(system->ensemble==ENSEMBLE_NVE){ output("MAIN:************************************** ****************\n"); output("MAIN:***startingMicrocanonicalMonteCarlosim ulation***\n"); output("MAIN:************************************** ****************\n"); }elseif(system->ensemble==ENSEMBLE_SURF){/*surfacer un*/ output("MAIN:************************************** ***************\n"); output("MAIN:***startingpotentialenergysurfacecalcu lation***\n"); output("MAIN:************************************** ***************\n"); }elseif(system->ensemble==ENSEMBLE_SURF_FIT){/*surf acefittingrun*/ output("MAIN:************************************** ***********************\n"); output("MAIN:***startingpotentialenergysurfacefitti ngcalculation***\n"); output("MAIN:************************************** ***********************\n"); }if(!((system->ensemble==ENSEMBLE_SURF)||(system->en semble==ENSEMBLE_SURF_FIT))){ if(mc(system)<0){ error("MAIN:MCfailedonerror,exiting\n"); #ifdefMPI MPI_Finalize(); #else exit(1); #endif/*MPI*/ }else{ if(system->ensemble==ENSEMBLE_UVT){ output("MAIN:************************************** ******************\n"); output("MAIN:***finishingGrandCanonicalMonteCarlosi mulation***\n"); output("MAIN:************************************** ******************\n\n"); }elseif(system->ensemble==ENSEMBLE_NVT){ output("MAIN:************************************** ************\n"); output("MAIN:***finishingCanonicalMonteCarlosimulat ion***\n"); output("MAIN:************************************** ************\n\n"); 243

PAGE 258

}elseif(system->ensemble==ENSEMBLE_NVE){ output("MAIN:************************************** *****************\n"); output("MAIN:***finishingMicrocanonicalMonteCarlosi mulation***\n"); output("MAIN:************************************** *****************\n\n"); } } }elseif(system->ensemble==ENSEMBLE_SURF){/*surface* / if(surface(system)<0){ error("MAIN:surfacemodulefailedonerror,exiting\n"); #ifdefMPI MPI_Finalize(); #else exit(1); #endif/*MPI*/ }else{ output("MAIN:************************************** ****************\n"); output("MAIN:***finishingpotentialenergysurfacecalc ulation***\n"); output("MAIN:************************************** ****************\n"); } }elseif(system->ensemble==ENSEMBLE_SURF_FIT){/*surf acefitting*/ if(surface_fit(system)<0){ error("MAIN:surfacefittingmodulefailedonerror,exiti ng\n"); #ifdefMPI MPI_Finalize(); #else exit(1); #endif/*MPI*/ }else{ output("MAIN:************************************** ************************\n"); output("MAIN:***finishingpotentialenergysurfacefitt ingcalculation***\n"); output("MAIN:************************************** ************************\n"); } }/*cleanup*/output("MAIN:freeingalldatastructures....");cleanup(system);output("...done\n");output("MAIN:simulationexitingsuccessfully\n\n"); #ifdefMPI MPI_Finalize(); #else exit(0); #endif/*MPI*/}/************************************************** **********************/ /*Cellularautomatarule30-derivedpseudorandomnumberg enerator*/ /**//*Thisimplementationisforboth32and64bitarchitecture s,butis*/ /*ideallyimplementedfor64.Thecodehasbeengeneralized sothat*/ /*classIIIsystemsotherthanrule30canbeutilizedforres earch*/ /*purposes.Theschememakesusearegisterarrayuponwhich therule*/ /*isimposed-thenextstepintheautomataisgeneratedinth eset*/ /*ofoutputregisters.Eachendoftheregisterarrayis'wra pped'*/ /*intoacircularregister;whilethisreducestheperiodic interval*/ /*ofrule30,theliteraturenotesthatthisprobablistical lyoccurs*/ /*ontheorderofmoderncryptographicsystems.Tosimplify thelogic*/ /*theruleisimplementeddirectlyintotheoutputregister array,and*/ /*thenshiftedonebittotherightattheendinorderfortheo utput*/ /*toalign.Noticethatrule30couldbemorecheaplyimpleme nted*/ /*(atthecostofgenerality)by(leftXOR(middleORright)) -that*/ /*isnotdonehere.Thedesignatedcenterbitofeachiterati onis*/ /*usedtogeneratethemantissaofthedoublefloatreturned ,asper*/ /*Wolfram,"ANewKindofScience".ItisknownthatMathemat icauses*/ /*thisexactmethodinit'simplementationofRandom[].*//**//*Benchmarkresults:*//**//*compilewith:*//*gcc-orule30rng-fomit-frame-funroll-loops-O3rule30 .rng.c*/ /**//*@2005JonathanBelof*//*SpaceResearchGroup*//*DepartmentofChemistry*//*UniversityofSouthFlorida*//************************************************** **********************/ #include#include#include#include#include#include#defineWORDSIZE__WORDSIZE#ifWORDSIZE==64/*64-bitmasks*/#defineRULE300x000000000000001E/*000000000000000000 0000000000000000000000000000000000000000011110*/ #defineRULE1100x000000000000006E/*00000000000000000 00000000000000000000000000000000000000001101110*/ #defineRULE100x000000000000000A/*000000000000000000 0000000000000000000000000000000000000000001010*/ #defineRULE900x000000000000005A/*000000000000000000 0000000000000000000000000000000000000001011010*/ #defineCELL_MASK0x0000000000000007/*000000000000000 0000000000000000000000000000000000000000000000111*/ #defineCENTER_MASK0x0000000100000000/*0000000000000 000000000000000000100000000000000000000000000000000 */ #defineDELTA_CENTER0x0000000000000020/*000000000000 000000000000000000000000000000000000000000000010000 0*/ 244

PAGE 259

#defineRHS_ONE0x0000000000000001/*00000000000000000 00000000000000000000000000000000000000000000001*/ #defineLHS_ONE0x8000000000000000/*10000000000000000 00000000000000000000000000000000000000000000000*/ #defineLHS_ZERO0x7FFFFFFFFFFFFFFF/*0111111111111111 111111111111111111111111111111111111111111111111*/ #defineINNER_COUNT0x00000000000000FF/*0000000000000 000000000000000000000000000000000000000000011111111 */ #defineINNER_ONE0x0000000000000001/*000000000000000 0000000000000000000000000000000000000000000000001*/ #defineINNER_ZERO0xFFFFFFFFFFFFFF00/*11111111111111 11111111111111111111111111111111111111111100000000* / #defineOUTER_COUNT0x0000000000FFFF00/*0000000000000 000000000000000000000000000111111111111111100000000 */ #defineOUTER_ONE0x0000000000000100/*000000000000000 0000000000000000000000001000000000000000000000000*/ #defineOUTER_ZERO0xFFFFFFFFFF0000FF/*11111111111111 11111111111111111111111111000000000000000011111111* / #defineDELTA_COUNT0x0000000000000008/*0000000000000 000000000000000000000000000000000000000000000001000 */ #defineDELTA_MANTISSA0x0000000000000034/*0000000000 000000000000000000000000000000000000000000000000110 100*/ #defineMAX_MANTISSA0x000FFFFFFFFFFFFF/*000000000000 111111111111111111111111111111111111111111111111111 1*/ #defineSEED0x38B1D098F2C40E5D#else/*32-bitmasks*/#defineRULE300x0000001E/*00000000000000000000000000 011110*/ #defineRULE1100x0000006E/*0000000000000000000000000 1101110*/ #defineRULE100x0000000A/*00000000000000000000000000 001010*/ #defineRULE900x0000005A/*00000000000000000000000001 011010*/ #defineCELL_MASK0x00000007/*00000000000000000000000 000000111*/ #defineCENTER_MASK0x00010000/*000000000000000100000 00000000000*/ #defineDELTA_CENTER0x00000010/*00000000000000000000 000000010000*/ #defineRHS_ONE0x00000001/*0000000000000000000000000 0000001*/ #defineLHS_ONE0x80000000/*1000000000000000000000000 0000000*/ #defineLHS_ZERO0x7FFFFFFF/*011111111111111111111111 11111111*/ #defineINNER_COUNT0x000000FF/*000000000000000000000 00011111111*/ #defineINNER_ONE0x00000001/*00000000000000000000000 000000001*/ #defineINNER_ZERO0xFFFFFF00/*1111111111111111111111 1100000000*/ #defineOUTER_COUNT0x00FFFF00/*000000001111111111111 11100000000*/ #defineOUTER_ONE0x00000100/*00000001000000000000000 000000000*/ #defineOUTER_ZERO0xFF0000FF/*1111111100000000000000 0011111111*/ #defineDELTA_COUNT0x00000008/*000000000000000000000 00000001000*/ #defineDELTA_MANTISSA0x0000000000000034/*0000000000 000000000000000000000000000000000000000000000000110 100*/ #defineMAX_MANTISSA0x00000000FFFFFFFF/*000000000000 000000000000000000001111111111111111111111111111111 1*/ #defineSEED0xF2C40E5D#endif/*WORDSIZE==64*/#ifWORDSIZE==64/*64-bit*/doublerule30_rng(unsignedlongintseed){ registerunsignedlongintrule=RULE30;/*theruletoenfor ce*/ registerunsignedlongintin_reg1=0,/*inputregisters*/ in_reg2=0,in_reg3=0,in_reg4=0,in_reg5=0,in_reg6=0,in_reg7=0; registerunsignedlongintout_reg1=0,/*outputregisters */ out_reg2=0,out_reg3=0,out_reg4=0,out_reg5=0,out_reg6=0,out_reg7=0; registerunsignedlongintmp=0;/*multi-purposeregister :*/ /*-theright-most8bitsarefortheinnerloopcounter*//*-thenext16bitsarefortheouterloopcounter*//*-theleft-mostbitisforcarries*/ staticunsignedlongintlast_reg1,/*staticmemoryaddrst ostoreresultsfromthecurrentrun*/ last_reg2,last_reg3,last_reg4,last_reg5,last_reg6,last_reg7; doublerandom_result=0;/*returnadoublefrom0.0to1.0*/unsignedlongintrandom_result_int=0;/*integerversion oftheaboveforbooleanops*/ /*startwithinitialconfig*/if(seed){ in_reg1=in_reg2=in_reg3=in_reg4=in_reg5=in_reg6=in_ reg7=seed; }else{ /*alreadyseeded-restorestatefrommemory*/in_reg1=last_reg1;in_reg2=last_reg2;in_reg3=last_reg3;in_reg4=last_reg4;in_reg5=last_reg5;in_reg6=last_reg6;in_reg7=last_reg7; }for((mp&=OUTER_ZERO);((mp&OUTER_COUNT)>>DELTA_COUNT )>(in_reg1&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg2|=((rule>>(in_reg2&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg3|=((rule>>(in_reg3&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg4|=((rule>>(in_reg4&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg5|=((rule>>(in_reg5&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg6|=((rule>>(in_reg6&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg7|=((rule>>(in_reg7&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); /*rotateallinputregistersonebittotheright,preservec arry*/ mp&=LHS_ZERO;/*clearthecarrybit*/mp|=((in_reg7&RHS_ONE)<<(WORDSIZE-1));/*setcarrybit ifneeded*/ in_reg7>>=RHS_ONE;in_reg7|=((in_reg6&RHS_ONE)<<(WORDSIZE-1)); 245

PAGE 260

in_reg6>>=RHS_ONE;in_reg6|=((in_reg5&RHS_ONE)<<(WORDSIZE-1));in_reg5>>=RHS_ONE;in_reg5|=((in_reg4&RHS_ONE)<<(WORDSIZE-1));in_reg4>>=RHS_ONE;in_reg4|=((in_reg3&RHS_ONE)<<(WORDSIZE-1));in_reg3>>=RHS_ONE;in_reg3|=((in_reg2&RHS_ONE)<<(WORDSIZE-1));in_reg2>>=RHS_ONE;in_reg2|=((in_reg1&RHS_ONE)<<(WORDSIZE-1));in_reg1>>=RHS_ONE;in_reg1|=mp&LHS_ONE; }/*nowmustrotateoutputregistersonebittotheleft*/mp&=LHS_ZERO;/*clearthecarrybit*/mp|=out_reg1&LHS_ONE;/*setthecarrybitifneeded*/out_reg1<<=RHS_ONE;out_reg1|=((out_reg2&LHS_ONE)>>(WORDSIZE-1));out_reg2<<=RHS_ONE;out_reg2|=((out_reg3&LHS_ONE)>>(WORDSIZE-1));out_reg3<<=RHS_ONE;out_reg3|=((out_reg4&LHS_ONE)>>(WORDSIZE-1));out_reg4<<=RHS_ONE;out_reg4|=((out_reg5&LHS_ONE)>>(WORDSIZE-1));out_reg5<<=RHS_ONE;out_reg5|=((out_reg6&LHS_ONE)>>(WORDSIZE-1));out_reg6<<=RHS_ONE;out_reg6|=((out_reg7&LHS_ONE)>>(WORDSIZE-1));out_reg7<<=RHS_ONE;out_reg7|=((mp&LHS_ONE)>>(WORDSIZE-1));/*setoutputbitsofrandomnumber*/random_result_int|=((out_reg4&CENTER_MASK)>>DELTA_C ENTER)<<((DELTA_MANTISSA-1)-((mp&OUTER_COUNT)>> DELTA_COUNT)); /*swaptheinputandoutputregisters*/in_reg1=out_reg1;in_reg2=out_reg2;in_reg3=out_reg3;in_reg4=out_reg4;in_reg5=out_reg5;in_reg6=out_reg6;in_reg7=out_reg7;/*clearoutputregisters*/out_reg1=out_reg2=out_reg3=out_reg4=out_reg5=out_re g6=out_reg7=0; }/*savelaststatepointtostaticmemory*/last_reg1=in_reg1;last_reg2=in_reg2;last_reg3=in_reg3;last_reg4=in_reg4;last_reg5=in_reg5;last_reg6=in_reg6;last_reg7=in_reg7;random_result=(double)random_result_int;random_result/=(double)MAX_MANTISSA;/*ensurethatres ultisnormalizedfrom0to1*/ return(random_result); }#else/*32-bit*/doublerule30_rng(unsignedlongintseed){ registerunsignedlongintrule=RULE30;/*theruletoenfor ce*/ registerunsignedlongintin_reg1=0,/*inputregisters*/ in_reg2=0,in_reg3=0; registerunsignedlongintout_reg1=0,/*outputregisters */ out_reg2=0,out_reg3=0; registerunsignedlongintmp=0;/*multi-purposeregister :*/ /*-theright-most8bitsarefortheinnerloopcounter*//*-thenext16bitsarefortheouterloopcounter*//*-theleft-mostbitisforcarries*/ staticunsignedlongintlast_reg1,/*staticmemoryaddrst ostoreresultsfromthecurrentrun*/ last_reg2,last_reg3; doublerandom_result=0;/*returnadoublefrom0.0to1.0*/unsignedlonglongintrandom_result_int=0;/*integerver sionoftheaboveforbooleanops*/ /*startwithinitialconfig*/if(seed){ in_reg1=in_reg2=in_reg3=seed; }else{ /*alreadyseeded-restorestatefrommemory*/in_reg1=last_reg1;in_reg2=last_reg2;in_reg3=last_reg3; }for((mp&=OUTER_ZERO);((mp&OUTER_COUNT)>>DELTA_COUNT )>(in_reg1&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); out_reg2|=((rule>>(in_reg2&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); 246

PAGE 261

out_reg3|=((rule>>(in_reg3&CELL_MASK))&RHS_ONE)<<(m p&INNER_COUNT); /*rotateallinputregistersonebittotheright,preservec arry*/ mp&=LHS_ZERO;/*clearthecarrybit*/mp|=((in_reg3&RHS_ONE)<<(WORDSIZE-1));/*setcarrybit ifneeded*/ in_reg3>>=RHS_ONE;in_reg3|=((in_reg2&RHS_ONE)<<(WORDSIZE-1));in_reg2>>=RHS_ONE;in_reg2|=((in_reg1&RHS_ONE)<<(WORDSIZE-1));in_reg1>>=RHS_ONE;in_reg1|=mp&LHS_ONE; }/*nowmustrotateoutputregistersonebittotheleft*/mp&=LHS_ZERO;/*clearthecarrybit*/mp|=out_reg1&LHS_ONE;/*setthecarrybitifneeded*/out_reg1<<=RHS_ONE;out_reg1|=((out_reg2&LHS_ONE)>>(WORDSIZE-1));out_reg2<<=RHS_ONE;out_reg2|=((out_reg3&LHS_ONE)>>(WORDSIZE-1));out_reg3<<=RHS_ONE;out_reg3|=((mp&LHS_ONE)>>(WORDSIZE-1)); /*setoutputbitsofrandomsequence*/random_result_int|=((out_reg2&CENTER_MASK)>>DELTA_C ENTER)<<((DELTA_MANTISSA-1)-((mp&OUTER_COUNT)>> DELTA_COUNT)); /*swaptheinputandoutputregisters*/in_reg1=out_reg1;in_reg2=out_reg2;in_reg3=out_reg3;/*cleartheoutputregisters*/out_reg1=out_reg2=out_reg3=0; }/*savethelaststatepointinstaticmemory*/last_reg1=in_reg1;last_reg2=in_reg2;last_reg3=in_reg3;random_result=(double)random_result_int;random_result/=(double)MAX_MANTISSA;/*ensurethatres ultisnormalizedfrom0to1*/ return(random_result); }#endif/*WORDSIZE==64*//*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include/*checkwhetherapoint(x,y,z)lieswithinanemptycavity* / /*ifso,return1*/intis_point_empty(system_t*system,doublex,doubley,d oublez){ inti,j,k;intincavity;doubler;incavity=0;for(i=0;icavity_grid_size;i++){ for(j=0;jcavity_grid_size;j++){ for(k=0;kcavity_grid_size;k++){ if(!system->cavity_grid[i][j][k].occupancy){ r=pow((x-system->cavity_grid[i][j][k].pos[0]),2.0);r+=pow((y-system->cavity_grid[i][j][k].pos[1]),2.0) ; r+=pow((z-system->cavity_grid[i][j][k].pos[2]),2.0) ; r=sqrt(r);if(rcavity_radius) incavity=1; } }/*endi*/ }/*endj*/ }/*endk*/return(incavity); }/*totalvolumeofaccessiblecavitiesviaMonteCarlointeg ration*/ voidcavity_volume(system_t*system){ intthrow,hits,num_darts;intp,q;doublepos_vec[3],grid_vec[3];doublefraction_hits;/*goodruleofthumbis1per10A^3*/num_darts=system->pbc->volume*DARTSCALE;/*throwrandomdartsandcountthenumberofhits*/ 247

PAGE 262

for(throw=0,hits=0;throwpbc->basis[p][q]*grid_vec[q]; /*checkiftherandompointlieswithinanemptycavity*/if(is_point_empty(system,pos_vec[0],pos_vec[1],pos_ vec[2]))++hits; }/*determinethepercentageoffreecavityspace*/fraction_hits=((double)hits)/((double)num_darts);system->cavity_volume=fraction_hits*system->pbc->vo lume;/*normalizew.r.t.thecellvolume*/ }/*probabilityoffindinganemptycavityonthegrid*/voidcavity_probability(system_t*system){ inti,j,k;doubleprobability;inttotal_points;/*totalnumberofpotentialcavities*/total_points=system->cavity_grid_size*system->cavit y_grid_size*system->cavity_grid_size; /*findthenumberofopencavities*/system->cavities_open=0;for(i=0;icavity_grid_size;i++) for(j=0;jcavity_grid_size;j++) for(k=0;kcavity_grid_size;k++) if(!system->cavity_grid[i][j][k].occupancy)++system ->cavities_open; /*theoverallprobabilityratio*/probability=((double)system->cavities_open)/((doubl e)total_points); /*updatetheobservable*/system->nodestats->cavity_bias_probability=probabil ity; }/*allocatethegrid*/voidsetup_cavity_grid(system_t*system){ inti,j;system->cavity_grid=calloc(system->cavity_grid_size ,sizeof(cavity_t**)); for(i=0;icavity_grid_size;i++){ system->cavity_grid[i]=calloc(system->cavity_grid_s ize,sizeof(cavity_t*)); for(j=0;jcavity_grid_size;j++) system->cavity_grid[i][j]=calloc(system->cavity_gri d_size,sizeof(cavity_t)); } }/*createa3Dhistogramofatomslyingwithinaspherecenter edateachgridpoint*/ voidcavity_update_grid(system_t*system){ inti,j,k,G;intp,q;molecule_t*molecule_ptr;atom_t*atom_ptr;doublegrid_component[3];doublegrid_vector[3];doubler;G=system->cavity_grid_size;/*clearthegrid*/for(i=0;icavity_grid[i][j][k].occupancy=0;for(p=0;p<3;p++) system->cavity_grid[i][j][k].pos[p]=0; } } }/*loopoverthegrid,binaspherewhenneeded*/for(i=0;ipbc->basis[p][q]*grid_compo nent[q]; /*putintorealcoordinates*/for(p=0;p<3;p++) 248

PAGE 263

for(q=0;q<3;q++) grid_vector[p]-=0.5*system->pbc->basis[p][q]; /*ifanatomiccoordinatelieswithinaspherecenteredonth egridpoint,thenbinit*/ for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ /*getthedisplacementfromthegridpoint*/for(p=0,r=0;p<3;p++) r+=(grid_vector[p]-atom_ptr->wrapped_pos[p])*(grid_ vector[p]atom_ptr->wrapped_pos[p]); r=sqrt(r);/*insidethesphere?*/if(rcavity_radius)++system->cavity_grid[i] [j][k].occupancy; }/*foratom*/ }/*formolecule*//*storethelocationofthisgridpoint*/for(p=0;p<3;p++) system->cavity_grid[i][j][k].pos[p]=grid_vector[p]; }/*fork*/ }/*forj*/ }/*fori*//*updatethecavityinsertionprobabilityestimate*/cavity_probability(system);/*updatetheaccessibleinsertionvolume*/cavity_volume(system); }#ifdefDEBUGvoidtest_cavity_grid(system_t*system){ inti,j,k,G;G=system->cavity_grid_size;printf("\n");for(i=0;icavity_grid[i][j][k].occupancy) ; }printf("\n"); }printf("\n");fflush(stdout); }#endif/*DEBUG*//*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include/*theprimequantityofinterest*/voidboltzmann_factor(system_t*system,doubleinitial_ energy,doublefinal_energy){ doubledelta_energy;doublefugacity;delta_energy=final_energy-initial_energy;if(system->h2_fugacity||system->co2_fugacity) fugacity=system->fugacity; else fugacity=system->pressure; if(system->ensemble==ENSEMBLE_UVT){ /*ifbiased_movenotset,nocavityavailablesodonormalev aluationbelow*/ if(system->cavity_bias&&system->checkpoint->biased_ move){ /*modifiedmetropolisfunction*/if(system->checkpoint->movetype==MOVETYPE_INSERT){/ *INSERT*/ system->nodestats->boltzmann_factor= (system->cavity_volume*system->avg_nodestats->cavit y_bias_probability*fugacity*ATM2REDUCED/(system->te mperature*system->observables->N))*exp (-delta_energy/system->temperature); }elseif(system->checkpoint->movetype==MOVETYPE_REMO VE){/*REMOVE*/ system->nodestats->boltzmann_factor=(system->temper ature*(system->observables->N+ 1))/(system->cavity_volume*system->avg_nodestats->c avity_bias_probability*fugacity*ATM2REDUCED)*exp(-d elta_energy/system->temperature); }else{/*DISPLACE*/ system->nodestats->boltzmann_factor=exp(-delta_ener gy/system->temperature); } }else{ if(system->checkpoint->movetype==MOVETYPE_INSERT){/ *INSERT*/ system->nodestats->boltzmann_factor= (system->pbc->volume*fugacity*ATM2REDUCED/(system-> temperature*system->observables->N))*exp(-delta_ene rgy/system->temperature); }elseif(system->checkpoint->movetype==MOVETYPE_REMO VE){/*REMOVE*/ system->nodestats->boltzmann_factor=(system->temper ature*(system->observables->N+ 1))/(system->pbc->volume*fugacity*ATM2REDUCED)*exp( -delta_energy/system->temperature); 249

PAGE 264

}else{/*DISPLACE*/ system->nodestats->boltzmann_factor=exp(-delta_ener gy/system->temperature); } } }elseif(system->ensemble==ENSEMBLE_NVT){ system->nodestats->boltzmann_factor=exp(-delta_ener gy/system->temperature); }elseif(system->ensemble==ENSEMBLE_NVE){ system->nodestats->boltzmann_factor=pow((system->to tal_energy-final_energy),3.0*system->N/2.0); system->nodestats->boltzmann_factor/=pow((system->t otal_energy-initial_energy),3.0*system->N/2.0); } }/*keeptrackofwhichspecificmoveswereaccepted*/voidregister_accept(system_t*system){ ++system->nodestats->accept;switch(system->checkpoint->movetype){ caseMOVETYPE_INSERT: ++system->nodestats->accept_insert;break; caseMOVETYPE_REMOVE: ++system->nodestats->accept_remove;break; caseMOVETYPE_DISPLACE: ++system->nodestats->accept_displace;break; caseMOVETYPE_ADIABATIC: ++system->nodestats->accept_adiabatic;break; } }/*keeptrackofwhichspecificmoveswererejected*/voidregister_reject(system_t*system){ ++system->nodestats->reject;switch(system->checkpoint->movetype){ caseMOVETYPE_INSERT: ++system->nodestats->reject_insert;break; caseMOVETYPE_REMOVE: ++system->nodestats->reject_remove;break; caseMOVETYPE_DISPLACE: ++system->nodestats->reject_displace;break; caseMOVETYPE_ADIABATIC: ++system->nodestats->reject_adiabatic;break; } }/*implementstheMarkovchain*/intmc(system_t*system){ inti,j,msgsize;doubleinitial_energy,final_energy,delta_energy;observables_t*observables_mpi;avg_nodestats_t*avg_nodestats_mpi;char*snd_strct,*rcv_strct; #ifdefMPI MPI_Datatypemsgtype; #endif/*MPI*/ /*allocatethestatisticsstructures*/observables_mpi=calloc(1,sizeof(observables_t));avg_nodestats_mpi=calloc(1,sizeof(avg_nodestats_t)) ; if(!(observables_mpi&&avg_nodestats_mpi)){ error("MC:couldn'tallocatespaceforstatistics\n");return(-1); }/*ifMPInotdefined,thencomputemessagesizelikedis*/msgsize=sizeof(observables_t)+sizeof(avg_nodestats_ t); if(system->calc_hist) msgsize+=system->n_histogram_bins*sizeof(int); #ifdefMPI MPI_Type_contiguous(msgsize,MPI_BYTE,&msgtype);MPI_Type_commit(&msgtype); #endif/*MPI*/ /*allocateMPIstructures*/snd_strct=calloc(msgsize,1);if(!snd_strct){ error("MC:couldn'tallocateMPImessagesendspace!\n");return(-1); }if(!rank){ rcv_strct=calloc(size,msgsize);if(!rcv_strct){ error("MC:rootcouldn'tallocateMPImessagereceivespac e!\n"); return(-1); } }/*clearourstatistics*/clear_nodestats(system->nodestats); 250

PAGE 265

clear_node_averages(system->avg_nodestats);clear_observables(system->observables);clear_root_averages(system->avg_observables);/*updatethegridforthefirsttime*/if(system->cavity_bias)cavity_update_grid(system);/*determinetheinitialnumberofatomsinthesimulation*/system->checkpoint->N_atom=num_atoms(system);system->checkpoint->N_atom_prev=system->checkpoint>N_atom; /*gettheinitialenergyofthesystem*/initial_energy=energy(system);/*beabitforgivingoftheinitialstate*/if(!finite(initial_energy)){ initial_energy=MAXVALUE;system->observables->energy=MAXVALUE; }/*settheinitialvalues*/track_ar(system->nodestats);update_nodestats(system->nodestats,system->avg_node stats); update_root_averages(system,system->observables,sys tem->avg_nodestats,system->avg_observables); /*ifroot,opennecessaryoutputfiles*/if(!rank){ output("MC:initialvalues:\n");write_averages(system->avg_observables);if(open_files(system)<0){ error("MC:couldnotopenfiles\n");return(-1); } }/*savetheinitialstate*/checkpoint(system);/*mainMCloop*/for(i=1;i<=system->numsteps;i++){ /*restorethelastacceptedenergy*/initial_energy=system->observables->energy;/*perturbthesystem*/make_move(system);/*calculatetheenergychange*/final_energy=energy(system);delta_energy=final_energy-initial_energy;/*treatabadcontactasareject*/if(!finite(final_energy)){ system->observables->energy=MAXVALUE;system->nodestats->boltzmann_factor=0; }else{ boltzmann_factor(system,initial_energy,final_energy ); }/*Metropolisfunction*/if(get_rand()nodestats->boltzmann_factor){ /*ACCEPT*/ /*checkpoint*/checkpoint(system);register_accept(system);/*SA*/if(system->simulated_annealing)system->temperature* =system->simulated_annealing_schedule; }else{/*REJECT*/ /*restorefromlastcheckpoint*/restore(system);register_reject(system); }/*tracktheacceptance_rate*/track_ar(system->nodestats);/*eachnodecalculatesit'sstats*/update_nodestats(system->nodestats,system->avg_node stats); /*dothiseverycorrelationtime,andattheveryend*/if(!(i%system->corrtime)||(i==system->numsteps)){ #ifdefQM_ROTATION /*solvefortherotationalenergylevels*/if(system->quantum_rotation)quantum_system_rotation al_energies(system); #endif/*QM_ROTATION*/ /*copyobservablesandavgstothempisendbuffer*//*histogramarrayisattheendofthemessage*/if(system->calc_hist){ zero_grid(system->grids->histogram->grid,system);population_histogram(system); }/*zerothesendbuffer*/memset(snd_strct,0,msgsize);memcpy(snd_strct,system->observables,sizeof(observa bles_t)); memcpy((snd_strct+sizeof(observables_t)),system->av g_nodestats,sizeof(avg_nodestats_t)); if(system->calc_hist) mpi_copy_histogram_to_sendbuffer(snd_strct+sizeof(o bservables_t)+sizeof(avg_nodestats_t), system->grids->histogram->grid,system); 251

PAGE 266

if(!rank)memset(rcv_strct,0,size*msgsize); #ifdefMPI MPI_Gather(snd_strct,1,msgtype,rcv_strct,1,msgtype, 0,MPI_COMM_WORLD); #else memcpy(rcv_strct,snd_strct,msgsize); #endif/*MPI*/ /*headnodecollectsallobservablesandaverages*/if(!rank){ for(j=0;jcalc_hist) mpi_copy_rcv_histogram_to_data(rcv_strct+j*msgsize+ sizeof(observables_t)+ sizeof(avg_nodestats_t),system->grids->histogram->g rid,system); /*collecttheaverages*/update_root_averages(system,observables_mpi,avg_nod estats_mpi,system->avg_observables); if(system->calc_hist)update_root_histogram(system);if(system->file_pointers.fp_energy)write_observable s(system->file_pointers.fp_energy, observables_mpi); }/*XXX-thisneedstobefixed,currentlyonlywritingtheroo tnode'sstates*/ if(system->file_pointers.fp_traj)write_states(syste m->file_pointers.fp_traj,system->molecules); /*writetheaveragestostdout*/if(system->file_pointers.fp_histogram) write_histogram(system->file_pointers.fp_histogram, system->grids->avg_histogram->grid,system); if(write_performance(i,system)<0){ error("MC:couldnotwriteperformancedatatostdout\n");return(-1); }if(write_averages(system->avg_observables)<0){ error("MC:couldnotwritestatisticstostdout\n");return(-1); }if(write_molecules(system,system->pdb_restart)<0){ error("MC:couldnotwriterestartstatetodisk\n");return(-1); } }/*!rank*/ }/*corrtime*/ }/*mainloop*//*writeoutput,closeanyopenfiles*/free(snd_strct);if(!rank){ if(write_molecules(system,system->pdb_output)<0){ error("MC:couldnotwritefinalstatetodisk\n");return(-1); }close_files(system);free(observables_mpi);free(avg_nodestats_mpi);free(rcv_strct); }return(0); }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*//*hereinliesleepingdemons*//*itrulyhatethisfuckingfile,butdontseeabetterwayJB* / #include/*makeanexactcopyofsrc*/molecule_t*copy_molecule(system_t*system,molecule_t *src){ inti,j;molecule_t*dst;atom_t*atom_dst_ptr,*prev_atom_dst_ptr,*atom_src_pt r; pair_t*pair_dst_ptr,*prev_pair_dst_ptr,*pair_src_pt r; /*allocatethestartofthenewlists*/dst=calloc(1,sizeof(molecule_t));/*copymoleculeattributes*/dst->id=src->id;strcpy(dst->moleculetype,src->moleculetype);dst->mass=src->mass;dst->frozen=src->frozen;dst->adiabatic=src->adiabatic;memcpy(dst->com,src->com,3*sizeof(double));memcpy(dst->wrapped_com,src->wrapped_com,3*sizeof(d ouble)); #ifdefQM_ROTATION if(system->quantum_rotation){ dst->quantum_rotational_energies=calloc(system->qua ntum_rotation_level_max,sizeof(double)); 252

PAGE 267

dst->quantum_rotational_eigenvectors=calloc(system>quantum_rotation_level_max,sizeof(complex_t*)); for(i=0;iquantum_rotation_level_max;i++) dst->quantum_rotational_eigenvectors[i]=calloc((sys tem->quantum_rotation_l_max+ 1)*(system->quantum_rotation_l_max+1),sizeof(comple x_t)); dst->quantum_rotational_eigensymmetry=calloc(system ->quantum_rotation_level_max,sizeof(int)); memcpy(dst->quantum_rotational_energies,src->quantu m_rotational_energies, system->quantum_rotation_level_max*sizeof(double)); for(i=0;iquantum_rotation_level_max;i++){ for(j=0;j<(system->quantum_rotation_l_max+1)*(syste m->quantum_rotation_l_max+1);j++){ dst->quantum_rotational_eigenvectors[i][j].real=src ->quantum_rotational_eigenvectors[i][j].real; dst->quantum_rotational_eigenvectors[i][j].imaginar y=src->quantum_rotational_eigenvectors[i][j].imagin ary; } }memcpy(dst->quantum_rotational_eigensymmetry,src->q uantum_rotational_eigensymmetry, system->quantum_rotation_level_max*sizeof(int)); } #endif/*QM_ROTATION*/ dst->next=NULL;/*newatomslist*/dst->atoms=calloc(1,sizeof(atom_t));prev_atom_dst_ptr=dst->atoms;for(atom_dst_ptr=dst->atoms,atom_src_ptr=src->atoms ;atom_src_ptr;atom_dst_ptr=atom_dst_ptr->next,atom_ src_ptr= atom_src_ptr->next){ atom_dst_ptr->id=atom_src_ptr->id;strcpy(atom_dst_ptr->atomtype,atom_src_ptr->atomtyp e); atom_dst_ptr->frozen=atom_src_ptr->frozen;atom_dst_ptr->adiabatic=atom_src_ptr->adiabatic;atom_dst_ptr->mass=atom_src_ptr->mass;atom_dst_ptr->charge=atom_src_ptr->charge;atom_dst_ptr->polarizability=atom_src_ptr->polariza bility; atom_dst_ptr->epsilon=atom_src_ptr->epsilon;atom_dst_ptr->sigma=atom_src_ptr->sigma;memcpy(atom_dst_ptr->pos,atom_src_ptr->pos,3*sizeof (double)); memcpy(atom_dst_ptr->wrapped_pos,atom_src_ptr->wrap ped_pos,3*sizeof(double)); memcpy(atom_dst_ptr->ef_static,atom_src_ptr->ef_sta tic,3*sizeof(double)); memcpy(atom_dst_ptr->ef_induced,atom_src_ptr->ef_in duced,3*sizeof(double)); memcpy(atom_dst_ptr->mu,atom_src_ptr->mu,3*sizeof(d ouble)); memcpy(atom_dst_ptr->old_mu,atom_src_ptr->old_mu,3* sizeof(double)); memcpy(atom_dst_ptr->new_mu,atom_src_ptr->new_mu,3* sizeof(double)); atom_dst_ptr->pairs=calloc(1,sizeof(pair_t));pair_dst_ptr=atom_dst_ptr->pairs;prev_pair_dst_ptr=pair_dst_ptr;for(pair_src_ptr=atom_src_ptr->pairs;pair_src_ptr;p air_src_ptr=pair_src_ptr->next){ pair_dst_ptr->rd_energy=pair_src_ptr->rd_energy;pair_dst_ptr->es_real_energy=pair_src_ptr->es_real_ energy; pair_dst_ptr->es_self_intra_energy=pair_src_ptr->es _self_intra_energy; pair_dst_ptr->frozen=pair_src_ptr->frozen;pair_dst_ptr->rd_excluded=pair_src_ptr->rd_excluded ; pair_dst_ptr->es_excluded=pair_src_ptr->es_excluded ; pair_dst_ptr->charge=pair_src_ptr->charge;pair_dst_ptr->epsilon=pair_src_ptr->epsilon;pair_dst_ptr->lrc=pair_src_ptr->lrc;pair_dst_ptr->sigma=pair_src_ptr->sigma;pair_dst_ptr->r=pair_src_ptr->r;pair_dst_ptr->rimg=pair_src_ptr->rimg;pair_dst_ptr->next=calloc(1,sizeof(pair_t));prev_pair_dst_ptr=pair_dst_ptr;pair_dst_ptr=pair_dst_ptr->next; }prev_pair_dst_ptr->next=NULL;free(pair_dst_ptr);/*handleanemptylist*/if(!atom_src_ptr->pairs)atom_dst_ptr->pairs=NULL;prev_atom_dst_ptr=atom_dst_ptr;atom_dst_ptr->next=calloc(1,sizeof(atom_t)); }prev_atom_dst_ptr->next=NULL;free(atom_dst_ptr);return(dst); }/*performageneralrandomtranslation*/voidtranslate(molecule_t*molecule,pbc_t*pbc,doubles cale){ atom_t*atom_ptr;doubletrans_x,trans_y,trans_z;doubleboxlength;trans_x=scale*get_rand()*pbc->cutoff;trans_y=scale*get_rand()*pbc->cutoff;trans_z=scale*get_rand()*pbc->cutoff;if(get_rand()<0.5)trans_x*=-1.0;if(get_rand()<0.5)trans_y*=-1.0;if(get_rand()<0.5)trans_z*=-1.0;molecule->com[0]+=trans_x;molecule->com[1]+=trans_y;molecule->com[2]+=trans_z; 253

PAGE 268

for(atom_ptr=molecule->atoms;atom_ptr;atom_ptr=atom _ptr->next){ atom_ptr->pos[0]+=trans_x;atom_ptr->pos[1]+=trans_y;atom_ptr->pos[2]+=trans_z; } }/*performageneralrandomrotation*/voidrotate(molecule_t*molecule,pbc_t*pbc,doublescal e){ atom_t*atom_ptr;doublealpha,beta,gamma;/*Eulerangles*/doublerotation_matrix[3][3];doublecom[3];inti,ii,n;double*new_coord_array;/*gettherandomizedEulerangles*/alpha=scale*get_rand()*2.0*M_PI;if(get_rand()<0.5)a lpha*=-1.0; beta=scale*get_rand()*M_PI;if(get_rand()<0.5)beta*= -1.0; gamma=scale*get_rand()*2.0*M_PI;if(get_rand()<0.5)g amma*=-1.0; /*countthenumberofatomsinamolecule,andallocatenewco ordsarray*/ for(atom_ptr=molecule->atoms,n=0;atom_ptr;atom_ptr= atom_ptr->next) ++n; new_coord_array=calloc(n*3,sizeof(double));/*savethecomcoordinate*/com[0]=molecule->com[0];com[1]=molecule->com[1];com[2]=molecule->com[2];/*translatethemoleculetotheorigin*/for(atom_ptr=molecule->atoms;atom_ptr;atom_ptr=atom _ptr->next){ atom_ptr->pos[0]-=com[0];atom_ptr->pos[1]-=com[1];atom_ptr->pos[2]-=com[2]; }/*constructthe3Drotationmatrix*/rotation_matrix[0][0]=cos(alpha)*cos(beta)*cos(gamm a)-sin(alpha)*sin(gamma); rotation_matrix[0][1]=sin(alpha)*cos(beta)*cos(gamm a)+cos(alpha)*sin(gamma); rotation_matrix[0][2]=-sin(beta)*cos(gamma);rotation_matrix[1][0]=-cos(alpha)*cos(beta)*sin(gam ma)-sin(alpha)*cos(gamma); rotation_matrix[1][1]=-sin(alpha)*cos(beta)*sin(gam ma)+cos(alpha)*cos(gamma); rotation_matrix[1][2]=sin(beta)*sin(gamma);rotation_matrix[2][0]=cos(alpha)*sin(beta);rotation_matrix[2][1]=sin(alpha)*sin(beta);rotation_matrix[2][2]=cos(beta);/*matrixmultiply*/for(atom_ptr=molecule->atoms,i=0;atom_ptr;atom_ptr= atom_ptr->next,i++){ ii=i*3;new_coord_array[ii+0]=rotation_matrix[0][0]*atom_pt r->pos[0]+rotation_matrix[0][1]*atom_ptr->pos[1]+ rotation_matrix[0][2]*atom_ptr->pos[2]; new_coord_array[ii+1]=rotation_matrix[1][0]*atom_pt r->pos[0]+rotation_matrix[1][1]*atom_ptr->pos[1]+ rotation_matrix[1][2]*atom_ptr->pos[2]; new_coord_array[ii+2]=rotation_matrix[2][0]*atom_pt r->pos[0]+rotation_matrix[2][1]*atom_ptr->pos[1]+ rotation_matrix[2][2]*atom_ptr->pos[2]; }/*setthenewcoordinatesandthentranslatebackfromtheor igin*/ for(atom_ptr=molecule->atoms,i=0;atom_ptr;atom_ptr= atom_ptr->next,i++){ ii=i*3;atom_ptr->pos[0]=new_coord_array[ii+0];atom_ptr->pos[1]=new_coord_array[ii+1];atom_ptr->pos[2]=new_coord_array[ii+2];atom_ptr->pos[0]+=com[0];atom_ptr->pos[1]+=com[1];atom_ptr->pos[2]+=com[2]; }/*freeourtemporaryarray*/free(new_coord_array); }/*performa1Dtranslationwithoutperiodicboundaries*/voiddisplace_1D(system_t*system,molecule_t*molecule ,doublescale){ atom_t*atom_ptr;doubletrans;trans=scale*get_rand();if(get_rand()<0.5)trans*=-1.0;for(atom_ptr=molecule->atoms;atom_ptr;atom_ptr=atom _ptr->next) atom_ptr->pos[0]+=trans; molecule->com[0]+=trans; }/*performarandomtranslation/rotationofamolecule*/voiddisplace(molecule_t*molecule,pbc_t*pbc,doubletr ans_scale,doublerot_scale){ translate(molecule,pbc,trans_scale);rotate(molecule,pbc,rot_scale); } 254

PAGE 269

/*applywhatwasalreadydeterminedincheckpointing*/voidmake_move(system_t*system){ inti,j,k,p,q;cavity_t*cavities_array;intcavities_array_counter,random_index;doublecom[3],rand[3];molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;/*updatethecavitygridpriortomakingamove*/if(system->cavity_bias){ cavity_update_grid(system);system->checkpoint->biased_move=0; }if(system->checkpoint->movetype==MOVETYPE_INSERT){/ *insertamoleculeatarandompositionandorientation*/ /*umbrellasampling*/if(system->cavity_bias&&system->cavities_open){ /*doingabiasedmove-thisflaglet'smc.cknowaboutit*/system->checkpoint->biased_move=1;/*makeanarrayofpossibleinsertionpoints*/cavities_array=calloc(system->cavities_open,sizeof( cavity_t)); for(i=0,cavities_array_counter=0;icavity_g rid_size;i++){ for(j=0;jcavity_grid_size;j++){ for(k=0;kcavity_grid_size;k++){ if(!system->cavity_grid[i][j][k].occupancy){ for(p=0;p<3;p++) cavities_array[cavities_array_counter].pos[p]= system->cavity_grid[i][j][k].pos[p]; ++cavities_array_counter; } }/*endk*/ }/*endj*/ }/*endi*//*insertrandomlyatoneofthefreecavitypoints*/random_index=(system->cavities_open-1)-(int)rint((( double)(system->cavities_open-1))*get_rand()); for(p=0;p<3;p++) com[p]=cavities_array[random_index].pos[p]; /*freetheinsertionarray*/free(cavities_array); }else{ /*insertthemoleculetoarandomlocationwithintheunitce ll*/ for(p=0;p<3;p++) rand[p]=0.5-get_rand(); for(p=0;p<3;p++) for(q=0,com[p]=0;q<3;q++) com[p]+=system->pbc->basis[p][q]*rand[q]; }/*processtheinsertedmolecule*/for(atom_ptr=system->checkpoint->molecule_backup->a toms;atom_ptr;atom_ptr=atom_ptr->next){ /*movethemoleculebacktotheoriginandtheassignittocom */ for(p=0;p<3;p++) atom_ptr->pos[p]+=com[p]-system->checkpoint->molecu le_backup->com[p]; }/*updatethemolecularcom*/for(p=0;p<3;p++) system->checkpoint->molecule_backup->com[p]=com[p]; /*giveitarandomorientation*/rotate(system->checkpoint->molecule_backup,system-> pbc,1.0); /*insertintothelist*/if(!system->checkpoint->head){/*ifwe'reatthestartof thelist*/ system->molecules=system->checkpoint->molecule_back up; }else{ system->checkpoint->head->next=system->checkpoint-> molecule_backup; }system->checkpoint->molecule_backup->next=system->c heckpoint->molecule_altered; /*setnewalteredandtailtoreflecttheinsertion*/system->checkpoint->molecule_altered=system->checkp oint->molecule_backup; system->checkpoint->tail=system->checkpoint->molecu le_altered->next; system->checkpoint->molecule_backup=NULL;update_pairs_insert(system); }elseif(system->checkpoint->movetype==MOVETYPE_REMO VE){/*removearandomlychosenmolecule*/ if(system->cavity_bias){ if(get_rand()avg_observables->cav ity_bias_probability), ((double)system->cavity_grid_size*system->cavity_gr id_size*system->cavity_grid_size))) system->checkpoint->biased_move=0; else 255

PAGE 270

system->checkpoint->biased_move=1; }/*remove'altered'fromthelist*/if(!system->checkpoint->head){/*handlethecasewherew e'reremovingfromthestartofthelist*/ system->checkpoint->molecule_altered=system->molecu les; system->molecules=system->molecules->next; }else{ system->checkpoint->head->next=system->checkpoint-> tail; }free_molecule(system,system->checkpoint->molecule_a ltered); update_pairs_remove(system); }elseif(system->checkpoint->movetype==MOVETYPE_DISP LACE){ /*changecoordsof'altered'*/if(system->rd_anharmonic) displace_1D(system,system->checkpoint->molecule_alt ered,system->move_probability); else displace(system->checkpoint->molecule_altered,syste m->pbc,system->move_probability,system->rot_probabi lity); }elseif(system->checkpoint->movetype==MOVETYPE_ADIA BATIC){ /*changecoordsof'altered'*/displace(system->checkpoint->molecule_altered,syste m->pbc,system->adiabatic_probability,1.0); } }/*thisfunction(a)determineswhatmovewillbemadenextti memake_move()iscalledand(b)backupsupthestatetoberes toreupon rejection*/voidcheckpoint(system_t*system){ inti_exchange,i_adiabatic;intnum_molecules_exchange,num_molecules_adiabatic,a ltered; doublenum_molecules_exchange_double,num_molecules_a diabatic_double; molecule_t**ptr_array_exchange,**ptr_array_adiabati c; molecule_t*molecule_ptr,*prev_molecule_ptr;/*savethecurrentobservables*/memcpy(system->checkpoint->observables,system->obse rvables,sizeof(observables_t)); /*countthenumberofexchangeablemolecules*/for(molecule_ptr=system->molecules,num_molecules_ex change=0;molecule_ptr;molecule_ptr=molecule_ptr->ne xt){ if(!(molecule_ptr->frozen||molecule_ptr->adiabatic) )++num_molecules_exchange; }/*countthenumberofadiabaticmolecules*/for(molecule_ptr=system->molecules,num_molecules_ad iabatic=0;molecule_ptr;molecule_ptr=molecule_ptr->n ext){ if(molecule_ptr->adiabatic)++num_molecules_adiabati c; }/*gothruagain,makeanarrayofalleligiblemolecules*/ptr_array_exchange=calloc(num_molecules_exchange,si zeof(molecule_t*)); ptr_array_adiabatic=calloc(num_molecules_adiabatic, sizeof(molecule_t*)); for(molecule_ptr=system->molecules,i_exchange=0,i_a diabatic=0;molecule_ptr;molecule_ptr=molecule_ptr-> next){ if(!(molecule_ptr->frozen||molecule_ptr->adiabatic) ){ ptr_array_exchange[i_exchange]=molecule_ptr;++i_exchange; }if(molecule_ptr->adiabatic){ ptr_array_adiabatic[i_adiabatic]=molecule_ptr;++i_adiabatic; } }/*determinewhatkindofmovetodo*/if(system->ensemble==ENSEMBLE_UVT){/*UVT*/ if(get_rand()insert_probability){/*doapart icleinsertion/deletionmove*/ if(get_rand()<0.5){/*INSERT*/ system->checkpoint->movetype=MOVETYPE_INSERT; }else{/*REMOVE*/ system->checkpoint->movetype=MOVETYPE_REMOVE; } }else{/*DISPLACE*/ if(num_molecules_adiabatic&&(get_rand()<0.5)) system->checkpoint->movetype=MOVETYPE_ADIABATIC;/*f ortheadiabaticmolefraction*/ else system->checkpoint->movetype=MOVETYPE_DISPLACE; } }elseif((system->ensemble==ENSEMBLE_NVT)||(system-> ensemble==ENSEMBLE_NVE)){ system->checkpoint->movetype=MOVETYPE_DISPLACE; }/*ifwehaveanyadiabaticmolecules,thenwehavetodosomes pecialstuff*/ /*randomlypicka(moveable)atom*/ if(system->checkpoint->movetype==MOVETYPE_ADIABATIC ){ --num_molecules_adiabatic;num_molecules_adiabatic_double=(double)num_molecule s_adiabatic; altered=num_molecules_adiabatic-(int)rint(num_molec ules_adiabatic_double*get_rand()); system->checkpoint->molecule_altered=ptr_array_adia batic[altered]; }else{ --num_molecules_exchange; 256

PAGE 271

num_molecules_exchange_double=(double)num_molecules _exchange; altered=num_molecules_exchange-(int)rint(num_molecu les_exchange_double*get_rand()); system->checkpoint->molecule_altered=ptr_array_exch ange[altered]; }/*freeourtemporaryeligibilitylists*/free(ptr_array_exchange);if(ptr_array_adiabatic)free(ptr_array_adiabatic);/*nevercompletelyemptythelist*/if(!num_molecules_exchange&&system->checkpoint->mov etype==MOVETYPE_REMOVE) system->checkpoint->movetype=MOVETYPE_DISPLACE; /*determinetheheadandtailoftheselectedmolecule*/for(molecule_ptr=system->molecules,prev_molecule_pt r=NULL;molecule_ptr;molecule_ptr=molecule_ptr->next ){ if(molecule_ptr==system->checkpoint->molecule_alter ed){ system->checkpoint->head=prev_molecule_ptr;system->checkpoint->tail=molecule_ptr->next; }prev_molecule_ptr=molecule_ptr; }/*ifwehaveamoleculealreadybackedup(fromapreviousacc ept),goaheadandfreeit*/ if(system->checkpoint->molecule_backup)free_molecul e(system,system->checkpoint->molecule_backup); /*backupthestatethatwillbealtered*/system->checkpoint->molecule_backup=copy_molecule(s ystem,system->checkpoint->molecule_altered); }/*thisfunction(a)undoeswhatmake_move()didand(b)dete rminesthenextmovesequencebycallingcheckpoint()*/ voidrestore(system_t*system){ molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*prev_pair_ptr,*pair_ptr;/*restoretheremainingobservables*/memcpy(system->observables,system->checkpoint->obse rvables,sizeof(observables_t)); /*restorestatebyundoingthestepsofmake_move()*/if(system->checkpoint->movetype==MOVETYPE_INSERT){ /*takealteredoutofthelist*/if(!system->checkpoint->head){/*handlethecasewherew einsertedattheheadofthelist*/ system->molecules=system->molecules->next; }else{ system->checkpoint->head->next=system->checkpoint-> tail; }unupdate_pairs_insert(system);free_molecule(system,system->checkpoint->molecule_a ltered); }elseif(system->checkpoint->movetype==MOVETYPE_REMO VE){ /*putbackupbackintothelist*/if(!system->checkpoint->head){ system->molecules=system->checkpoint->molecule_back up; }else{ system->checkpoint->head->next=system->checkpoint-> molecule_backup; }system->checkpoint->molecule_backup->next=system->c heckpoint->tail; unupdate_pairs_remove(system);system->checkpoint->molecule_backup=NULL; }elseif((system->checkpoint->movetype==MOVETYPE_DIS PLACE)||(system->checkpoint->movetype==MOVETYPE_ADI ABATIC)){ /*linkthebackupintotheworkinglistagain*/if(!system->checkpoint->head) system->molecules=system->checkpoint->molecule_back up; else system->checkpoint->head->next=system->checkpoint-> molecule_backup; system->checkpoint->molecule_backup->next=system->c heckpoint->tail; free_molecule(system,system->checkpoint->molecule_a ltered); system->checkpoint->molecule_backup=NULL; }/*establishthepreviouscheckpointagain*/checkpoint(system); }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#includeintpimc(system_t*system){ return(0); }#ifdefXXX/************************************************** ******************************/ 257

PAGE 272

/**//*PathintegralMonteCarlocalculationforsingularatomi csystems*/ /**//*Thiscodecalculatesthepathintegralfora1selectronar oundanexternal*/ /*potentialgeneratedbyZprotonsatthecartesianorigin. Thecalculated*/ /*observablesarethetotalenergyandthecoordinatesofth eTrotterbeads.*/ /**//*compilation:*//*gcc-oatomic_pimcatomic_pimc.c-lm*//**//*usage:./pimc*/ /*=atomicnumber*//*=Trotternumberofbeads*//*=temperatureofthesystem(K)*//*=scaleforthebeadmove*//*=numberofMCstepstoperform*//*=samplinginterval*//**//*Thepseudo-potentialallowstheuseof~100Trotterbeads perfermion,but*/ /*thesamplingefficiencycouldbymuchbetterbyanticipat ingthetrue*/ /*wavefunctionnodesalaCeperley(RecentAdv.inQMMethod sII,2002)and*/ /*focusingthesamplingthere.*//**//*@2007JonathanBelof*//*SpaceResearchGroup*//*DepartmentofChemistry*//*UniversityofSouthFlorida*//************************************************** ******************************/ /*setthenucleus*/#defineCOORDS_OUTPUT_FILENAME"output.coords"/*xmovf ormattedoutputofcoordinates*/ #defineENERGY_OUTPUT_FILENAME"output.energy"/*energ youtputforplotting*/ #defineXMOV_SET_FILENAME"output.set"/*forxmovviewin g*/ #defineXMOV_PROTON_TOP_FILENAME"proton.top"/*forxmo vviewing*/ #defineXMOV_ELECTRON_TOP_FILENAME"electron.top"/*fo rxmovviewing*/ #include#include#include#include#include#include#include#include/*conversions*/#defineKPSA1.202717 /*numberofamu'sin1KPSAmassunit*/ #defineH_OVER_K47.9923862/*Planck'sconstantdividedb yboltzmann'sconstant(Kps)*/ #defineH_OVER_K_SQUARED2303.26913/*aboveconstant,sq uared*/ #defineHBAR_OVER_K7.63822547/*Planck'sbardividedbyb oltzmann'sconstant(Kps)*/ #defineHBAR_OVER_K_SQUARED58.3424884/*theaboveconst ant,squared*/ #defineBOLTZMANNS_CONSTANT1.38650e-23/*Boltzmann'sc onstant*/ #defineK_TO_EV8.65385313e-5/*ConversionfactorforK-> eV*/ /*physicalconstants*/#defineBOHR_RADIUS0.529177210818/*Bohrradiusinangst roms*/ #defineELECTRON_CHARGE408.781604283/*inreducedunits ofsqrt(K*A)*/ #defineELECTRON_MASS6.597860309e-4/*electronmassinK PSA(0.00054857961673g/mol)*/ #definePROTON_MASS1.211466984/*protonmassinKPSA(1.0 07275181g/mol)*/ /*pseudo-potentialswitchingdistance*/#defineSWITCHING0.5*BOHR_RADIUS/*datastructureforaquantumparticle*/structparticle_t{ doublemass;/*particlemass*/inttrotter;/*numberofbeadsintheringpolymer*/structbead_t*bead_list;/*circularlinkedlistofbeads* / };/*datastructurefortheTrotterbeadsonthecyclicpolymer */ structbead_t{ doublex,y,z;/*coordinates*/structbead_t*next;/*ptrtothenextbead*/ };/*globalcopyoftheparticlestateforsaving/restoringac rossfunctions*/ structparticle_t*saved_particle_array;/*initializethepseudoRNG*/voidseed_random_number(void){ srand48(time(NULL)); }/*returnsadoublefrom0.0to1.0*/doubleget_random_number(){ return(drand48()); }/*takessystemparametersasinput,returnsanarrayofinit ializedparticles*/ structparticle_t*initialize_system(inttrotter){ inti;structparticle_t*particle_array=NULL;/*particlearra ypointer*/ structbead_t*current_bead_ptr;/*currentworkingbeadp ointer*/ doublerandom_theta,random_phi;/*randomangles*//*allocatetheparticlearray*/particle_array=calloc(sizeof(structparticle_t),1);/ *asingleparticle*/ if(!particle_array){ fprintf(stderr,"initialize_system:couldn'tallocatep articlearray\n"); 258

PAGE 273

return(NULL); }particle_array[0].mass=ELECTRON_MASS;/*setthepartic lemass*/ particle_array[0].trotter=trotter;/*setthetrotternu mberforthering*/ /*allocatethebeads*/particle_array[0].bead_list=calloc(sizeof(structbea d_t),1);/*startwiththefirstone*/ current_bead_ptr=particle_array[0].bead_list;if(!current_bead_ptr){ fprintf(stderr,"initialize_system:couldn'tallocatef irstbeadelement\n"); return(NULL); }current_bead_ptr->x=BOHR_RADIUS;current_bead_ptr->y=0.0;current_bead_ptr->z=0.0;for(i=0;i<(trotter-1);i++){/*allocatetherestofthebe ads*/ current_bead_ptr->next=calloc(sizeof(structbead_t), 1); current_bead_ptr=current_bead_ptr->next;if(!current_bead_ptr){ fprintf(stderr,"initialize_system:couldn'tallocateb eadnumber%d\n",(i+1)); return(NULL); }current_bead_ptr->x=BOHR_RADIUS;current_bead_ptr->y=0.0;current_bead_ptr->z=0.0; }current_bead_ptr->next=particle_array[0].bead_list; /*connectthecircle*/ /*donesettinguptheparticles*//*setupthespaceforsaving/restoringthesystemstate*/saved_particle_array=calloc(sizeof(structparticle_t ),1); if(!saved_particle_array){ fprintf(stderr,"initialize_system:couldn'tallocates avedparticlearray\n"); return(NULL); }saved_particle_array[0].bead_list=calloc(sizeof(str uctbead_t),1); current_bead_ptr=saved_particle_array[0].bead_list;if(!current_bead_ptr){ fprintf(stderr,"initialize_system:couldn'tallocatef irstsavedbeadelement\n"); return(NULL); }for(i=0;i<(trotter-1);i++){ current_bead_ptr->next=calloc(sizeof(structbead_t), 1); current_bead_ptr=current_bead_ptr->next;if(!current_bead_ptr){ fprintf(stderr,"initialize_system:couldn'tallocateb eadnumber%d\n",(i+1)); return(NULL); } }current_bead_ptr->next=saved_particle_array[0].bead _list; /*seedtheRNG*/seed_random_number();return(particle_array); }/*calculatethecoulombicenergyduetotheprotonattheori gin,includeapseudo-potential*/ doubleget_external_potential(structparticle_t*parti cle_array,doubleZ,doubleswitching){ inti;doubler,external_energy;structbead_t*cur_ptr;cur_ptr=particle_array[0].bead_list;for(i=0,external_energy=0.0;ix*cur_ptr->x+cur_ptr->y*cur_ptr->y+ cur_ptr->z*cur_ptr->z); if(rnext; }external_energy/=((double)particle_array[0].trotter ); return(external_energy); }/*calculatethepathintegralharmonicenergyfortheringp olymer*/ doubleget_internal_potential(structparticle_t*parti cle_array,doubletemperature){ inti;structbead_t*cur_ptr,*nxt_ptr;doubleinternal_energy;doubledx,dy,dz,displacement_squared;/*gettheringpolymerenergy*/cur_ptr=particle_array[0].bead_list;nxt_ptr=cur_ptr->next;for(i=0,internal_energy=0.0;ix-nxt_ptr->x;dy=cur_ptr->y-nxt_ptr->y;dz=cur_ptr->z-nxt_ptr->z;displacement_squared=dx*dx+dy*dy+dz*dz;internal_energy+=displacement_squared;cur_ptr=cur_ptr->next;nxt_ptr=cur_ptr->next; }internal_energy*=(((double)particle_array[0].trotte r)*particle_array[0].mass*temperature*temperature)/ (2.0*HBAR_OVER_K_SQUARED); return(internal_energy); }/*getthetotalenergyforthesystem*/ 259

PAGE 274

doubleget_energy(structparticle_t*particle_array,do ubleZ,doubletemperature){ doubleenergy;energy=get_external_potential(particle_array,Z,SWIT CHING); energy+=get_internal_potential(particle_array,tempe rature); return(energy); }/*makearandomtrialmove*/voidmake_move(structparticle_t*particle_array,doubl escale){ inti;structbead_t*cur_ptr;/*moveeachbeadbyarandomamount*/cur_ptr=particle_array[0].bead_list;for(i=0;ix+=scale*(0.5-get_random_number());cur_ptr->y+=scale*(0.5-get_random_number());cur_ptr->z+=scale*(0.5-get_random_number());cur_ptr=cur_ptr->next; } }/*MCacceptroutine,storestheacceptedcoordinates*/voidmc_accept(structparticle_t*particle_array){ inti;structbead_t*saved_ptr,*current_ptr;/*savetheacceptedconfiguration*/saved_particle_array[0].trotter=particle_array[0].t rotter; saved_particle_array[0].mass=particle_array[0].mass ; current_ptr=particle_array[0].bead_list;saved_ptr=saved_particle_array[0].bead_list;for(i=0;ix=current_ptr->x;saved_ptr->y=current_ptr->y;saved_ptr->z=current_ptr->z;current_ptr=current_ptr->next;saved_ptr=saved_ptr->next; } }/*MCrejectroutine,restorethelastacceptedcoordinates */ voidmc_reject(structparticle_t*particle_array){ inti;structbead_t*saved_ptr,*current_ptr;/*restorethelastacceptedconfiguration*/particle_array[0].trotter=saved_particle_array[0].t rotter; particle_array[0].mass=saved_particle_array[0].mass ; current_ptr=particle_array[0].bead_list;saved_ptr=saved_particle_array[0].bead_list;for(i=0;ix=saved_ptr->x;current_ptr->y=saved_ptr->y;current_ptr->z=saved_ptr->z;current_ptr=current_ptr->next;saved_ptr=saved_ptr->next; } }/*writethesystemcoordinatestoafile*/voidwrite_coords(structparticle_t*particle_array,FI LE*fp_coords){ inti;structbead_t*cur_ptr;/*printtheprotoncoords*/fprintf(fp_coords,"0.00.00.0\n");/*printtheelectron'sbeads*/cur_ptr=particle_array[0].bead_list;for(i=0;ix,cur_ptr>y,cur_ptr->z);/*outputcoords*/ cur_ptr=cur_ptr->next; }/*printartificialperiodicboundary*/fprintf(fp_coords,"%lg0.00.00.0%lg0.00.00.0%lg\n",4 *BOHR_RADIUS,4*BOHR_RADIUS,4*BOHR_RADIUS); }/*writethesystemenergytoafile*/voidwrite_energy(doubleenergy,FILE*fp_energy){ fprintf(fp_energy,"%lg\n",energy); }/*performthepathintegralmontecarlocalculation-theme at'npotatos*/ intdo_pimc(structparticle_t*particle_array,doubleZ, doubletemperature,doublescale,intnum_steps,intcorr_ time){ inti,j;/*MCstepcounter*/doubleinitial_energy;/*energybeforemakingMCmove*/ 260

PAGE 275

doublefinal_energy;/*energyaftermakingMCmove*/doubledelta_energy;/*energychangeduetotheMCmove*/doubleboltzmann;/*boltzmannfactor*/doubleaccepted_energy;/*acceptedenergytobeaveraged* / doubleaccepted_energy_squared;/*acceptedenergysquar ed*/ doubleradius;/*beadradiusfromtheproton*/doubleaccepted_radius;/*acceptedvalueforaveraging*/doubleaverage_radius;/*simulationaverageradius*/doubleaverage_energy=0;/*averageacceptedenergy*/doubleaverage_energy_squared=0;/*averagesquareofthe acceptedenergy*/ doubleaverage_boltzmann=0;/*averageboltzmannfactor* / doubleaverage_factor=0;/*numericalfactorusedforther unningaverages*/ intaccepts=0,rejects=0;/*keeptrackofacceptancerate* / FILE*fp_coords,*fp_energy;/*filepointersforoutput*/FILE*fp_set,*fp_proton_top,*fp_electron_top;/*usedf orxmovmovieoutput*/ structbead_t*cur_ptr;/*usedforradiuscalculation*/if(!particle_array||(num_steps<=0)){ fprintf(stderr,"do_pimc:invalidinputparameterspasse d\n"); return(-1); }/*setthetemperature*/if(temperature<0.0){ fprintf(stderr,"do_pimc:invalidtemperaturespecified \n"); return(-1); }/*opentheoutputfilesforwriting*/fp_coords=fopen(COORDS_OUTPUT_FILENAME,"w");fp_energy=fopen(ENERGY_OUTPUT_FILENAME,"w");if(!fp_coords||!fp_energy){ fprintf(stderr,"do_pimc:couldn'topenoutputfilesforw riting\n"); return(-1); }/*writexmovheadertocoordsfile*/fprintf(fp_coords,"#%d10.001\n",(particle_array[0]. trotter+1)); /*outputthexmovsetandtopfiles*/fp_set=fopen(XMOV_SET_FILENAME,"w");fprintf(fp_set,"~mol_def[\\mol_parm_file{proton.top }\\mol_therm_opt{none}\\nmol{1}\\mol_index{1}]\n"); fprintf(fp_set,"~mol_def[\\mol_parm_file{electron.t op}\\mol_therm_opt{none}\\nmol{%d}\\mol_index{2}]\n ", particle_array[0].trotter); fp_proton_top=fopen(XMOV_PROTON_TOP_FILENAME,"w");fprintf(fp_proton_top,"~mol_name_def[\\mol_name{pro ton}\\natom{1}\\nbond{0}\\nbondx{0}]\n"); fprintf(fp_proton_top,"~atom_def[\\atom_typ{P}\\ato m_ind{1}\\mass{1.0}\\charge{0.0}\\alpha{0.000}]\n") ; fp_electron_top=fopen(XMOV_ELECTRON_TOP_FILENAME,"w "); fprintf(fp_electron_top,"~mol_name_def[\\mol_name{e lectron}\\natom{1}\\nbond{0}\\nbondx{0}]\n"); fprintf(fp_electron_top,"~atom_def[\\atom_typ{E}\\a tom_ind{1}\\mass{0.0001}\\charge{0.0}\\alpha{0.000} ]\n"); fclose(fp_set);fclose(fp_proton_top);fclose(fp_elec tron_top); /*getthefirstenergyandautomaticallyacceptit*/initial_energy=get_energy(particle_array,Z,temperat ure); mc_accept(particle_array);accepted_energy=get_external_potential(particle_arr ay,Z,SWITCHING); accepted_energy_squared=accepted_energy*accepted_en ergy; /*gettheinitialradius*/cur_ptr=particle_array[0].bead_list;for(j=0,accepted_radius=0.0;jx*cur_ptr->x+cur_ptr->y*cur_pt r->y+cur_ptr->z*cur_ptr->z); accepted_radius+=radius;cur_ptr=cur_ptr->next; }accepted_radius/=((double)particle_array[0].trotter ); /*thisisthemainloop*/for(i=0;ix*cur_ptr->x+cur_ptr->y*cur_pt r->y+cur_ptr->z*cur_ptr->z); accepted_radius+=radius;cur_ptr=cur_ptr->next; }accepted_radius/=((double)particle_array[0].trotter ); }else{/******REJECT******/ mc_reject(particle_array);++rejects; }if(!(i%corr_time)){ /*writeoutthecoordinates*/write_coords(particle_array,fp_coords);/*writeoutthetotalenergy*/write_energy(accepted_energy*K_TO_EV,fp_energy); 261

PAGE 276

}/*keeparunningaverageoftheenergy*/average_factor=((double)i)/((double)(i+1));average_energy=average_energy*average_factor+(accep ted_energy/((double)(i+1))); average_energy_squared=average_energy_squared*avera ge_factor+(accepted_energy_squared/((double)(i+1))) ; average_boltzmann=average_boltzmann*average_factor+ (boltzmann/((double)(i+1))); average_radius=average_radius*average_factor+(accep ted_radius/((double)(i+1))); }/*outputusefulstatstostdout*/printf("\n\n*************************************** ******************\n"); printf("**********temperature=%.2f(K)\n",temperatur e); printf("**********acceptancerate=%.3f\n",((double)a ccepts)/((double)i)); printf("**********averageboltzmannfactor=%.5f\n",av erage_boltzmann); printf("**********averageenergy=%.3f(eV)\n",average _energy*K_TO_EV); printf("**********averageelectronradius=%.3f(A)\n", average_radius); printf("**********energysigma=%.3f(eV)\n",K_TO_EV*s qrt(average_energy_squared-average_energy*average_e nergy)); printf("******************************************* **************\n\n"); /*gracefullycloseourfilepointerstreams*/fclose(fp_coords);fclose(fp_energy);return(0); }/*cleansuptheparticlearray*/voidfree_particle(structparticle_t*particle_array){ inti;structbead_t*current_bead_ptr,**free_array;free_array=calloc(sizeof(structbead_t*),particle_ar ray[0].trotter); current_bead_ptr=particle_array[0].bead_list;for(i=0;inext; }for(i=0;i\n",progname); fprintf(stderr,"\t\t\t\t=atomicnumber\n");fprintf(stderr,"\t\t\t\t=Trotternumberofbeads \n"); fprintf(stderr,"\t\t\t\t=temperatureofthesyst em(K)\n"); fprintf(stderr,"\t\t\t\t=beadmovescalingpara meter\n"); fprintf(stderr,"\t\t\t\t=numberofMCstepstope rform\n"); fprintf(stderr,"\t\t\t\t=intervalofconfigurat ionsampling\n\n"); exit(1); }intmain(intargc,char**argv){ inti;/*counter*/intnum_steps,corr_time;/*numberofMCstepstodoandcorr elationtime*/ inttrotter;/*Trotternumberofbeads*/doubletemperature;/*temperatureofthesystem(K)*/doublescale;/*amounttoscalethebeadmovesby*/structparticle_t*particle_array;/*particlearray,cur rentlyjustasingleparticle*/ doubleZ;/*atomicnumber*//*readcmdlineargs*/if(argc!=7) usage(argv[0]); printf("%s:inputinvokation=",argv[0]);for(i=0;i
PAGE 277

fprintf(stderr,"%s:ERROR:invalidbeadscalingspecifie d\n",argv[0]); exit(1); }/*getthenumberofMCstepstoperform*/num_steps=atoi(argv[5]);if(num_steps<=0){ fprintf(stderr,"%s:ERROR:invalidnumberofMCstepsspec ified\n",argv[0]); exit(1); }/*getthecorrelationintervalforsampling*/corr_time=atoi(argv[6]);if(corr_time<=0){ fprintf(stderr,"%s:ERROR:invalidcorrelationtimespec ified\n",argv[0]); exit(1); }particle_array=initialize_system(trotter);if(!particle_array){ fprintf(stderr,"%s:ERROR:couldn'tinitializethesyste m\n",argv[0]); exit(1); }/*startthepathintegralmontecarlo*/if(do_pimc(particle_array,Z,temperature,scale,num_s teps,corr_time)<0){ fprintf(stderr,"%s:ERROR:pathintegralMCloopdied\n", argv[0]); exit(1); }free_particle(particle_array);exit(0); }#endif/*XXX*//*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*//*thisfileisrathersloppy,butgotthejobdone*/#include#defineSCALE_CHARGE0.0#defineSCALE_EPSILON0.1#defineSCALE_SIGMA0.01#defineSCALE_R0.001#defineTEMPERATURE500.0#defineMIN_TEMPERATURE4.0#defineSCHEDULE0.9#defineEQUIL1000#defineENERGY_TOTAL0#defineENERGY_ES1#defineENERGY_RD2#defineENERGY_POLAR3/*calculatetheenergyforthesurfacescan-sameasfunctio nenergy()butwithoutobservables*/ doublesurface_energy(system_t*system,intenergy_type ){ molecule_t*molecule_ptr;doublepotential_energy,rd_energy,coulombic_energy,p olar_energy; /*zerotheinitialvalues*/potential_energy=0;rd_energy=0;coulombic_energy=0;polar_energy=0;/*getthepairwisetermsnecessaryfortheenergycalculati on*/ pairs(system);switch(energy_type){ caseENERGY_TOTAL: if(!(system->sg||system->rd_only))coulombic_energy= coulombic_nopbc(system->molecules); if(system->sg){ rd_energy=sg_nopbc(system->molecules); }else{ rd_energy=lj_nopbc(system->molecules); }if(system->polarization)polar_energy=polar(system);break; caseENERGY_ES: if(!(system->sg||system->rd_only))coulombic_energy= coulombic_nopbc(system->molecules); break; caseENERGY_RD: if(system->sg){ rd_energy=sg_nopbc(system->molecules); }else{ rd_energy=lj_nopbc(system->molecules); }break; caseENERGY_POLAR: if(system->polarization)polar_energy=polar(system);break; } 263

PAGE 278

/*sumthetotalpotentialenergy*/potential_energy=rd_energy+coulombic_energy+polar_e nergy; return(potential_energy); }/*rotateamoleculeaboutthreeEulerangles-sameasnormal functionbutforasinglemolandwithoutrandomangles*/ voidmolecule_rotate(molecule_t*molecule,doublealpha ,doublebeta,doublegamma){ atom_t*atom_ptr;doublerotation_matrix[3][3];doublecom[3];inti,ii,n;double*new_coord_array;/*countthenumberofatomsinamolecule,andallocatenewco ordsarray*/ for(atom_ptr=molecule->atoms,n=0;atom_ptr;atom_ptr= atom_ptr->next) ++n; new_coord_array=calloc(n*3,sizeof(double));/*savethecomcoordinate*/com[0]=molecule->com[0];com[1]=molecule->com[1];com[2]=molecule->com[2];/*translatethemoleculetotheorigin*/for(atom_ptr=molecule->atoms;atom_ptr;atom_ptr=atom _ptr->next){ atom_ptr->pos[0]-=com[0];atom_ptr->pos[1]-=com[1];atom_ptr->pos[2]-=com[2]; }/*constructthe3Drotationmatrix*/rotation_matrix[0][0]=cos(gamma)*cos(beta)*cos(alph a)-sin(gamma)*sin(alpha); rotation_matrix[0][1]=sin(gamma)*cos(beta)*cos(alph a)+cos(gamma)*sin(alpha); rotation_matrix[0][2]=-sin(beta)*cos(alpha);rotation_matrix[1][0]=-cos(gamma)*cos(beta)*sin(alp ha)-sin(gamma)*cos(alpha); rotation_matrix[1][1]=-sin(gamma)*cos(beta)*sin(alp ha)+cos(gamma)*cos(alpha); rotation_matrix[1][2]=sin(beta)*sin(alpha);rotation_matrix[2][0]=cos(gamma)*sin(beta);rotation_matrix[2][1]=sin(gamma)*sin(beta);rotation_matrix[2][2]=cos(beta);/*matrixmultiply*/for(atom_ptr=molecule->atoms,i=0;atom_ptr;atom_ptr= atom_ptr->next,i++){ ii=i*3;new_coord_array[ii+0]=rotation_matrix[0][0]*atom_pt r->pos[0]+rotation_matrix[0][1]*atom_ptr->pos[1]+ rotation_matrix[0][2]*atom_ptr->pos[2]; new_coord_array[ii+1]=rotation_matrix[1][0]*atom_pt r->pos[0]+rotation_matrix[1][1]*atom_ptr->pos[1]+ rotation_matrix[1][2]*atom_ptr->pos[2]; new_coord_array[ii+2]=rotation_matrix[2][0]*atom_pt r->pos[0]+rotation_matrix[2][1]*atom_ptr->pos[1]+ rotation_matrix[2][2]*atom_ptr->pos[2]; }/*setthenewcoordinatesandthentranslatebackfromtheor igin*/ for(atom_ptr=molecule->atoms,i=0;atom_ptr;atom_ptr= atom_ptr->next,i++){ ii=i*3;atom_ptr->pos[0]=new_coord_array[ii+0];atom_ptr->pos[1]=new_coord_array[ii+1];atom_ptr->pos[2]=new_coord_array[ii+2];atom_ptr->pos[0]+=com[0];atom_ptr->pos[1]+=com[1];atom_ptr->pos[2]+=com[2]; }/*freeourtemporaryarray*/free(new_coord_array); }/*calculatetheisotropicpotentialenergysurfaceofamol ecule*/ intsurface(system_t*system){ inti;intavg_counter;doubleavg_factor;doubler,pe_es,pe_rd,pe_polar,pe_total;doublepe_total_avg,pe_es_avg,pe_rd_avg,pe_polar_avg ; doublealpha_origin,beta_origin,gamma_origin;doublealpha_move,beta_move,gamma_move;/*outputthepotentialenergycurve*/if(system->surf_preserve){/*preservetheorientationa ndonlycalculatebasedondisplacement*/ for(r=system->surf_min;r<=system->surf_max;r+=syste m->surf_inc){ /*calculatetheenergy*/surface_dimer_geometry(system,r,0.0,0.0,0.0,0.0,0.0 ,0.0); if(system->surf_decomp){ pe_es=surface_energy(system,ENERGY_ES);pe_rd=surface_energy(system,ENERGY_RD);pe_polar=surface_energy(system,ENERGY_POLAR);printf("%.5f%.5f%.5f%.5f\n",r,pe_es,pe_rd,pe_polar) ; fflush(stdout); }else{ pe_total=surface_energy(system,ENERGY_TOTAL);printf("%.5f%.5f\n",r,pe_total);fflush(stdout); 264

PAGE 279

} } }else{/*defaultistodoisotropicaveraging*/ for(r=system->surf_min;r<=system->surf_max;r+=syste m->surf_inc){ /*zerotheaveragesforthisrvalue*/avg_counter=0;pe_total_avg=0;pe_es_avg=0;pe_rd_avg=0;pe_polar_avg=0;/*averageovertheangles*/for(alpha_origin=0;alpha_origin<=2.0*M_PI;alpha_ori gin+=system->surf_ang){ for(beta_origin=0;beta_origin<=M_PI;beta_origin+=sy stem->surf_ang){ for(gamma_origin=0;gamma_origin<=2.0*M_PI;gamma_ori gin+=system->surf_ang){ for(alpha_move=0;alpha_move<=2.0*M_PI;alpha_move+=s ystem->surf_ang){ for(beta_move=0;beta_move<=M_PI;beta_move+=system-> surf_ang){ for(gamma_move=0;gamma_move<=2.0*M_PI;gamma_move+=s ystem->surf_ang) { ++avg_counter;avg_factor=((double)(avg_counter-1))/((double)(avg_ counter)); surface_dimer_geometry(system,r,alpha_origin,beta_o rigin, gamma_origin,alpha_move,beta_move,gamma_move); if(system->surf_decomp){ pe_es=surface_energy(system,ENERGY_ES);pe_rd=surface_energy(system,ENERGY_RD);pe_polar=surface_energy(system,ENERGY_POLAR);pe_es_avg=pe_es_avg*avg_factor+ (pe_es/((double)avg_counter)); pe_rd_avg=pe_rd_avg*avg_factor+ (pe_rd/((double)avg_counter)); pe_polar_avg=pe_polar_avg*avg_factor+ (pe_polar/((double)avg_counter)); }else{ pe_total=surface_energy(system,ENERGY_TOTAL);pe_total_avg=pe_total_avg*avg_factor+ (pe_total/((double)avg_counter)); } }/*endgamma_move*/ }/*endbeta_move*/ }/*endalpha_move*/ }/*endgamma_origin*/ }/*endbeta_origin*/ }/*endalpha_origin*/if(system->surf_decomp){ printf("%.5f%.5f%.5f%.5f\n",r,pe_es_avg,pe_rd_avg,p e_polar_avg); fflush(stdout); }else{ printf("%.5f%.5f\n",r,pe_total_avg);fflush(stdout); } }/*endr*/ }return(0); }/*setthedistanceandanglesforaparticulardimerorienta tion*/ intsurface_dimer_geometry(system_t*system,doubler,d oublealpha_origin,doublebeta_origin,doublegamma_ori gin,doublealpha_move, doublebeta_move,doublegamma_move){ inti;molecule_t*molecule_origin,*molecule_move;atom_t*atom_ptr;/*makesurethatthereareonlytwomolecules*/molecule_origin=system->molecules;molecule_move=molecule_origin->next;if(!molecule_move){ error("SURFACE:theinputPDBhasonlyasinglemolecule\n" ); return(-1); }if(molecule_move->next){ error("SURFACE:theinputPDBmustcontainexactlytwomole cules\n"); return(-1); }/*relocatebothmoleculestotheorigin*/for(atom_ptr=molecule_origin->atoms;atom_ptr;atom_p tr=atom_ptr->next) for(i=0;i<3;i++) atom_ptr->pos[i]-=molecule_origin->com[i]; for(i=0;i<3;i++) molecule_origin->com[i]=0; 265

PAGE 280

for(atom_ptr=molecule_move->atoms;atom_ptr;atom_ptr =atom_ptr->next) for(i=0;i<3;i++) atom_ptr->pos[i]-=molecule_move->com[i]; for(i=0;i<3;i++) molecule_move->com[i]=0; /*relocatethemoveablemoleculerdistanceawayalongthex axis*/ molecule_move->com[0]=r;molecule_move->com[1]=0;molecule_move->com[2]=0;for(atom_ptr=molecule_move->atoms;atom_ptr;atom_ptr =atom_ptr->next) for(i=0;i<3;i++) atom_ptr->pos[i]+=molecule_move->com[i]; /*applytherotationtothesecondmolecule*/molecule_rotate(molecule_origin,alpha_origin,beta_o rigin,gamma_origin); molecule_rotate(molecule_move,alpha_move,beta_move, gamma_move); return(0); }intsurface_dimer_parameters(system_t*system,param_t *params){ molecule_t*molecule_ptr;atom_t*atom_ptr;param_t*param_ptr;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(param_ptr=params;param_ptr;param_ptr=param_ptr>next){ if(!strcasecmp(atom_ptr->atomtype,param_ptr->atomty pe)){ atom_ptr->charge=param_ptr->charge;atom_ptr->epsilon=param_ptr->epsilon;atom_ptr->sigma=param_ptr->sigma;if(atom_ptr->pos[param_ptr->axis]>0.0) atom_ptr->pos[param_ptr->axis]+=param_ptr->dr; else atom_ptr->pos[param_ptr->axis]-=param_ptr->dr; } } } }return(0); }voidsurface_curve(system_t*system,doubler_min,doubl er_max,doubler_inc,double*curve){ inti;doubler;for(r=r_min,i=0;r<=r_max;r+=r_inc,i++){ surface_dimer_geometry(system,r,0.0,0.0,0.0,0.0,0.0 ,0.0); curve[i]=surface_energy(system,ENERGY_TOTAL); } }/*fitpotentialenergyparametersviasimulatedannealing */ /*XXX-requirethattherandomseedsbeset,erroronmemorya lloc*/ intsurface_fit(system_t*system){ inti,N,nsteps;FILE*fp_fit;charlinebuf[MAXLINE];double*r_input,*EOE_input,*PAR_input,*T_input,*X_in put; double*EOE_output,*PAR_output,*T_output,*X_output;double*EOE_global,*PAR_global,*T_global,*X_global;atom_t*atom_ptr;param_t*param_ptr,*params,*prev_param_ptr;doubler,r_min,r_max,r_inc;doublecurrent_error,last_error,global_minimum;doubletemperature=TEMPERATURE;charlast_atomtype[MAXLINE];doubleghost_charge;/*readinthenumberoflines*/fp_fit=fopen(system->fit_input,"r");for(N=0;fgets(linebuf,MAXLINE,fp_fit);N++);fclose(fp_fit);/*allocateourfunctions*/r_input=calloc(N,sizeof(double));EOE_input=calloc(N,sizeof(double));PAR_input=calloc(N,sizeof(double));T_input=calloc(N,sizeof(double));X_input=calloc(N,sizeof(double));EOE_output=calloc(N,sizeof(double));PAR_output=calloc(N,sizeof(double));T_output=calloc(N,sizeof(double));X_output=calloc(N,sizeof(double));EOE_global=calloc(N,sizeof(double));PAR_global=calloc(N,sizeof(double));T_global=calloc(N,sizeof(double));X_global=calloc(N,sizeof(double)); 266

PAGE 281

/*readinthe4curves*/fp_fit=fopen(system->fit_input,"r");for(i=0;imolecules->atoms;atom_ptr;atom _ptr=atom_ptr->next){ /*XXX-uncommentforquadrupolefitting*//*if(strcasecmp(atom_ptr->atomtype,last_atomtype)){ */ if(strcasecmp(atom_ptr->atomtype,last_atomtype)&&(( atom_ptr->epsilon!=0.0)&&(atom_ptr->sigma!=0.0))){ strcpy(param_ptr->atomtype,atom_ptr->atomtype);param_ptr->charge=atom_ptr->charge;param_ptr->epsilon=atom_ptr->epsilon;param_ptr->sigma=atom_ptr->sigma;for(i=0;i<3;i++){ if(fabs(atom_ptr->pos[i])>=0.001){ param_ptr->axis=i; } }param_ptr->last_charge=param_ptr->charge;param_ptr->last_epsilon=param_ptr->epsilon;param_ptr->last_sigma=param_ptr->sigma;param_ptr->next=calloc(1,sizeof(param_t));prev_param_ptr=param_ptr;param_ptr=param_ptr->next;strcpy(last_atomtype,atom_ptr->atomtype); } }prev_param_ptr->next=NULL;free(param_ptr);for(param_ptr=params;param_ptr;param_ptr=param_ptr>next){ for(atom_ptr=system->molecules->atoms;atom_ptr;atom _ptr=atom_ptr->next) if(!strcasecmp(param_ptr->atomtype,atom_ptr->atomty pe)) ++param_ptr->ntypes; }printf("temperature=%f,sq_error=%f\n",temperature,c urrent_error); for(param_ptr=params;param_ptr;param_ptr=param_ptr>next){ printf("\tatomtype%sq=%feps=%fsig=%fdr=%f\n",param_ ptr->atomtype,param_ptr->charge/E2REDUCED, param_ptr->epsilon,param_ptr->sigma,param_ptr->dr); }fflush(stdout);global_minimum=current_error;last_error=current_error;for(i=0;iMIN_TEMPERATURE;++nsteps){ /*randomlyperturbtheparameters*/ 267

PAGE 282

for(param_ptr=params;param_ptr;param_ptr=param_ptr>next){ param_ptr->epsilon+=SCALE_EPSILON*(0.5-get_rand());if(param_ptr->epsilon<0.0)param_ptr->epsilon=param_ ptr->last_epsilon; param_ptr->sigma+=SCALE_SIGMA*(0.5-get_rand());if(param_ptr->sigma<0.0)param_ptr->sigma=param_ptr>last_sigma; if((param_ptr->ntypes>1)&&strcasecmp(param_ptr->ato mtype,"H2E")) param_ptr->dr=SCALE_R*(0.5-get_rand()); else param_ptr->dr=0; if(!strcasecmp(param_ptr->atomtype,"H2G")){ ghost_charge=param_ptr->charge+SCALE_CHARGE*(0.5-ge t_rand()); param_ptr->charge=ghost_charge; }elseif(!strcasecmp(param_ptr->atomtype,"H2E")){ param_ptr->charge=-0.5*ghost_charge;/*XXX-singleLJsiteonly*/param_ptr->epsilon=0.0;param_ptr->sigma=0.0; } }/*applythetrialparameters*/surface_dimer_parameters(system,params);/*EOE*/surface_dimer_geometry(system,r_min,0.0,0.0,0.0,0.0 ,0.0,0.0); surface_curve(system,r_min,r_max,r_inc,EOE_output);/*PAR*/surface_dimer_geometry(system,r_min,0.5*M_PI,0.0,0. 0,0.5*M_PI,0.0,0.0); surface_curve(system,r_min,r_max,r_inc,PAR_output);/*T*/surface_dimer_geometry(system,r_min,0.0,0.0,0.0,0.5 *M_PI,0.0,0.0); surface_curve(system,r_min,r_max,r_inc,T_output);/*X*/surface_dimer_geometry(system,r_min,0.0,0.0,0.0,0.0 ,0.5*M_PI,0.0); surface_curve(system,r_min,r_max,r_inc,X_output);/*resettotheorigin*/surface_dimer_geometry(system,0.0,1.5*M_PI,0.0,0.0, 0.0,0.5*M_PI,0.0); /*accumulatethesquarederror*/for(i=0,current_error=0;inext){ param_ptr->last_charge=param_ptr->charge;param_ptr->last_epsilon=param_ptr->epsilon;param_ptr->last_sigma=param_ptr->sigma;param_ptr->last_dr=param_ptr->dr; }last_error=current_error;if(nsteps>=EQUIL){ temperature=temperature*SCHEDULE;/*schedule*/nsteps=0;printf("temperature=%f,sq_error=%f\n",temperature,c urrent_error); for(param_ptr=params;param_ptr;param_ptr=param_ptr>next){ printf("\tatomtype%sq=%feps=%fsig=%fdr=%f\n",param_ ptr->atomtype, param_ptr->charge/E2REDUCED,param_ptr->epsilon,para m_ptr->sigma,param_ptr->dr); }fflush(stdout);/*outputthenewglobalminimum*/if(current_errornext){ param_ptr->charge=param_ptr->last_charge; 268

PAGE 283

param_ptr->epsilon=param_ptr->last_epsilon;param_ptr->sigma=param_ptr->last_sigma;param_ptr->dr=param_ptr->last_dr; } } }/*outputthefitcurves*/for(i=0;i/*calculatethefieldwithperiodicboundaries*/voidthole_field(system_t*system){ intp;molecule_t*molecule_ptr;atom_t*atom_ptr;/*zerothefieldvectors*/for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next) for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next) for(p=0;p<3;p++)atom_ptr->ef_static[p]=0; /*calculatetheelectrostaticfield*/if(system->polar_ewald){ thole_field_real(system);thole_field_recip(system);thole_field_self(system); }else thole_field_nopbc(system); }/*calculatethefieldwithoutewaldsummation*/voidthole_field_nopbc(system_t*system){ molecule_t*molecule_ptr;atom_t*atom_ptr,**atom_array;pair_t*pair_ptr;intp;doubler,damping;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next){ if(!pair_ptr->frozen){ r=pair_ptr->rimg;/*exponentialfielddamping*/if(system->field_damp==0.0) damping=1.0; else damping=1.0-exp(-pow(r/system->field_damp,3.0)); /*includeself-inductionifkeywordpolar_selfisset*/if((!pair_ptr->es_excluded||system->polar_self)&&(r pbc->cutoff)){ for(p=0;p<3;p++){ atom_ptr->ef_static[p]+=damping*pair_ptr->charge*pa ir_ptr->dimg[p]/(r*r*r); pair_ptr->atom->ef_static[p]-=damping*atom_ptr->cha rge*pair_ptr->dimg[p]/(r*r*r); } } } } } } }/*realspacesum*/voidthole_field_real(system_t*system){ molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;intp;doublealpha;doublefield_value; 269

PAGE 284

alpha=system->ewald_alpha;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next){ if(!pair_ptr->frozen){ if(!pair_ptr->es_excluded){ field_value=erfc(alpha*pair_ptr->rimg)+ 2.0*alpha*pair_ptr->rimg*exp(-alpha*alpha*pair_ptr>rimg*pair_ptr->rimg)/sqrt(M_PI); for(p=0;p<3;p++){ atom_ptr->ef_static[p]+= pair_ptr->charge*field_value*pair_ptr->dimg[p]/(pai r_ptr->rimg*pair_ptr->rimg*pair_ptr->rimg); pair_ptr->atom->ef_static[p]-= atom_ptr->charge*field_value*pair_ptr->dimg[p]/(pai r_ptr->rimg*pair_ptr->rimg*pair_ptr->rimg); } } }/*!frozen*/ }/*pair*/ }/*atom*/ }/*molecule*/ }/*fourierspacesum*/voidthole_field_recip(system_t*system){ inti,N,r,p,q;intkmax;doublealpha,gaussian;doublevector_product_i,vector_product_j;doubleSF_sin,SF_cos;intnorm,l[3];intk_squared,k[3];molecule_t*molecule_ptr;atom_t*atom_ptr,**atom_array;pair_t*pair_ptr;/*ourconvergenceparameters*/alpha=system->ewald_alpha;kmax=system->ewald_kmax;/*generateanarrayofatomptrs*/for(molecule_ptr=system->molecules,N=0,atom_array=N ULL;molecule_ptr;molecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next,N++){ atom_array=realloc(atom_array,sizeof(atom_t*)*(N+1) ); atom_array[N]=atom_ptr; } }/*calculatethefieldvectorforeachnuclearcoordinate*/for(i=0;ipbc->reciprocal_basis[p][q]*2.0*M_PI* ((double)l[q]); k_squared+=k[p]*k[p]; }/*comparethenorm*/if((norm<=kmax*kmax)&&(k_squared>0.0)){ /*ourgaussiancenteredonthecharge*/gaussian=exp(-k_squared/(4.0*alpha*alpha))/k_square d; /*thestructurefactor*/SF_sin=0;SF_cos=0;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ /*makesureit'snotafrozen-frozeninteraction*/if(!(atom_ptr->frozen&&atom_array[i]->frozen)){ /*innerproductofj-thpositionvectorandk-vector*/for(p=0,vector_product_j=0;p<3;p++) vector_product_j+=k[p]*atom_ptr->pos[p]; SF_sin+=atom_ptr->charge*sin(vector_product_j);SF_cos+=-atom_ptr->charge*cos(vector_product_j); }/*!frozen*/ }/*atom*/ }/*molecule*//*innerproductofi-thpositionvectorandk-vector*/for(p=0,vector_product_i=0;p<3;p++) 270

PAGE 285

vector_product_i+=k[p]*atom_array[i]->pos[p]; /*thei-thtermsoutsideoftheSFsum*/SF_sin*=cos(vector_product_i);SF_cos*=sin(vector_product_i);/*projectthefieldcomponents*/for(r=0;r<3;r++) atom_array[i]->ef_static[r]+=-4.0*M_PI*k[r]*gaussia n*(SF_sin+ SF_cos)/system->pbc->volume; }/*endifnorm*/ }/*endforn*/ }/*endform*/ }/*endforl*/ }/*endi*/free(atom_array); }/*selfinteractionterm*/voidthole_field_self(system_t*system){ molecule_t*molecule_ptr;atom_t*atom_ptr;pair_t*pair_ptr;intp;doublealpha;doublefield_value;alpha=system->ewald_alpha;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ for(pair_ptr=atom_ptr->pairs;pair_ptr;pair_ptr=pair _ptr->next){ if(!pair_ptr->frozen){ if(pair_ptr->es_excluded){ field_value=erf(alpha*pair_ptr->r)2.0*alpha*pair_ptr->r*exp(-alpha*alpha*pair_ptr->r* pair_ptr->r)/sqrt(M_PI); for(p=0;p<3;p++){ atom_ptr->ef_static[p]-= pair_ptr->charge*field_value*pair_ptr->d[p]/(pair_p tr->r*pair_ptr->r*pair_ptr->r); pair_ptr->atom->ef_static[p]+= atom_ptr->charge*field_value*pair_ptr->d[p]/(pair_p tr->r*pair_ptr->r*pair_ptr->r); } } }/*!frozen*/ }/*pair*/ }/*atom*/ }/*molecule*/ }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include/*iterativesolverofthedipolefieldtensor*//*returnsthenumberofiterationsrequired*/intthole_iterative(system_t*system){ inti,j,ii,jj,N,p,q,sorted;intiteration_counter,keep_iterating;doubleerror;molecule_t*molecule_ptr;atom_t*atom_ptr,**atom_array;int*ranked_array,ranked,tmp,index;/*generateanarrayofatomptrs*/for(molecule_ptr=system->molecules,N=0,atom_array=N ULL;molecule_ptr;molecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next,N++){ atom_array=realloc(atom_array,sizeof(atom_t*)*(N+1) ); atom_array[N]=atom_ptr; } }/*arrayforranking*/ranked_array=calloc(N,sizeof(int));for(i=0;i
PAGE 286

for(p=0;p<3;p++){ /*setthefirstguesstoalpha*E*/atom_array[i]->mu[p]=atom_array[i]->polarizability* atom_array[i]->ef_static[p]; if(!system->polar_sor)atom_array[i]->mu[p]*=system>polar_gamma; } }/*ifZODIDisenabled,thenstophereandjustreturnthealph a*Edipoles*/ if(system->polar_zodid)return(0);/*iterativesolverofthedipolefieldequations*/for(iteration_counter=0,keep_iterating=1;keep_itera ting;iteration_counter++){ /*divergencedetection*//*ifwefailtoconverge,thenreturndipolesasalpha*E*/if(iteration_counter>=MAX_ITERATION_COUNT){ for(i=0;imu[p]=atom_array[i]->polarizability* atom_array[i]->ef_static[p]; free(atom_array);return(iteration_counter); }/*savethecurrentdipolesetandcleartheinducedfieldvec tors*/ for(i=0;iold_mu[p]=atom_array[i]->mu[p];atom_array[i]->ef_induced[p]=0;atom_array[i]->ef_induced_change[p]=0; } }/*contractthedipoleswiththefieldtensor*/for(i=0;ief_induced[p]-= system->A_matrix[ii+p][jj+q]*atom_array[j]->mu[q]; } }/*endj*//*dipoleisthesumofthestaticandinducedparts*/for(p=0;p<3;p++){ atom_array[index]->new_mu[p]=atom_array[index]->pol arizability*(atom_array[index]->ef_static[p]+ atom_array[index]->ef_induced[p]); /*Gauss-Seidel*/if(system->polar_gs||system->polar_gs_ranked) atom_array[index]->mu[p]=atom_array[index]->new_mu[ p]; } }/*endi*//*getthedipoleRRMS*/for(i=0;idipole_rrms=0;for(p=0;p<3;p++) atom_array[i]->dipole_rrms+=pow((atom_array[i]->new _mu[p]-atom_array[i]->old_mu[p]),2.0); /*normalize*/atom_array[i]->dipole_rrms/=pow(atom_array[i]->new_ mu[0],2.0)+pow(atom_array[i]->new_mu[1],2.0)+ pow(atom_array[i]->new_mu[2],2.0); atom_array[i]->dipole_rrms=sqrt(atom_array[i]->dipo le_rrms); }/*determineifwearedone...*/if(system->polar_precision==0.0){/*...byfixediterat ion...*/ if(iteration_counter==system->polar_max_iter) keep_iterating=0; else keep_iterating=1; }else{/*...orbydipoleprecision*/ /*immediatelyreiterateifanycomponentbroketolerance, otherwisewearedone*/ for(i=0,keep_iterating=0;inew_mu[p]-atom_array[i]-> old_mu[p]),2.0); if(error>pow(system->polar_precision*DEBYE2SKA,2.0) )keep_iterating=1; 272

PAGE 287

} } }/*contractoncemoreforthenextinducedfield*/if(system->polar_palmo){ /*calculatechangeininducedfieldduetothisiteration*/for(i=0;ief_induced_change[p]-= system->A_matrix[ii+p][jj+q]*atom_array[j]->mu[q]; } }for(p=0;p<3;p++) atom_array[index]->ef_induced_change[p]-=atom_array [index]->ef_induced[p]; }/*endi*/ }/*palmo*//*rankthedipolesbybubblesort*/if(system->polar_gs_ranked){ for(i=0;irank_metricrank_metric){ sorted=0;tmp=ranked_array[j];ranked_array[j]=ranked_array[j+1];ranked_array[j+1]=tmp; } }if(sorted)break; } }/*savethedipolesforthenextpass*/for(i=0;ipolar_sor) atom_array[i]->mu[p]=system->polar_gamma*atom_array [i]->new_mu[p]+(1.0system->polar_gamma)*atom_array[i]->old_mu[p]; elseif(system->polar_esor) atom_array[i]->mu[p]=(1.0-exp(-system->polar_gamma* iteration_counter))*atom_array[i]->new_mu[p] +exp(-system->polar_gamma*iteration_counter)*atom_a rray[i]->old_mu[p]; else atom_array[i]->mu[p]=atom_array[i]->new_mu[p]; } } }/*endkeepiterating*/free(atom_array);free(ranked_array);/*returntheiterationcount*/return(iteration_counter); }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#includevoidprint_matrix(intN,double**matrix){ inti,j;printf("\n");for(i=0;i
PAGE 288

doublev,s;/*generateanarrayofatomptrs*/for(molecule_ptr=system->molecules,N=0,atom_array=N ULL;molecule_ptr;molecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next,N++){ atom_array=realloc(atom_array,sizeof(atom_t*)*(N+1) ); atom_array[N]=atom_ptr; } }/*zerooutthematrix*/for(i=0;i<3*N;i++) for(j=0;j<3*N;j++) system->A_matrix[i][j]=0; /*setthediagonalblocks*/for(i=0;ipolarizability!=0.0) system->A_matrix[ii+p][ii+p]=1.0/atom_array[i]->pol arizability; else system->A_matrix[ii+p][ii+p]=MAXVALUE; } }/*calculateeachTijtensorcomponentforeachdipolepair* / for(i=0;i<(N-1);i++){ ii=i*3;for(j=(i+1),pair_ptr=atom_array[i]->pairs;jnext){ jj=j*3;/*inversedisplacements*/r3=pow(pair_ptr->rimg,-3.0);r5=pow(pair_ptr->rimg,-5.0);/*setthedampingfunction*/if(system->damp_type==DAMPING_LINEAR){/*lineardampi ng*/ s=(system->polar_damp)*pow((atom_array[i]->polariza bility*atom_array[j]->polarizability),(1.0/6.0)); v=pair_ptr->rimg/s;if(pair_ptr->rimgdamp_type==DAMPING_EXPONENTIAL){/*e xponentialdamping*/ damping_term1=1.0exp(-system->polar_damp*pair_ptr->rimg)*(0.5*system ->polar_damp*system->polar_damp*pair_ptr->r2img+sys tem->polar_damp*pair_ptr->rimg+ 1.0); damping_term2=1.0exp(-system->polar_damp*pair_ptr->rimg)*(system->po lar_damp*system->polar_damp*system->polar_damp*pair _ptr->r3img/6.0+ 0.5*system->polar_damp*system->polar_damp*pair_ptr>r2img+system->polar_damp*pair_ptr->rimg+1.0); }/*buildthetensor*/for(p=0;p<3;p++){ for(q=0;q<3;q++){ system->A_matrix[ii+p][jj+q]=-3.0*pair_ptr->dimg[p] *pair_ptr->dimg[q]*damping_term2*r5; /*additionaldiagonalterm*/if(p==q) system->A_matrix[ii+p][jj+q]+=damping_term1*r3; } }/*setthelowerhalfofthetensorcomponent*/for(p=0;p<3;p++) for(q=0;q<3;q++) system->A_matrix[jj+p][ii+q]=system->A_matrix[ii+p] [jj+q]; }/*endj*/ }/*endi*/free(atom_array); }/*returnsthecurrentnumberofatomsinthesystem*/intnum_atoms(system_t*system){ intN_atoms;molecule_t*molecule_ptr;atom_t*atom_ptr;/*countthenumberofatomsinthesysteminitially*/for(molecule_ptr=system->molecules,N_atoms=0;molecu le_ptr;molecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next){ 274

PAGE 289

++N_atoms; } }return(N_atoms); }/*foruvtruns,resizetheA(andB)matrices*/voidthole_resize_matrices(system_t*system){ inti,N,dN;/*determinehowthenumberofatomshaschangedandreallocm atrices*/ system->checkpoint->N_atom_prev=system->checkpoint>N_atom; system->checkpoint->N_atom=num_atoms(system);N=3*system->checkpoint->N_atom;dN=3*(system->checkpoint->N_atom-system->checkpoint ->N_atom_prev); if(!dN)return;if(dN<0){ for(i=N;i<(N-dN);i++)free(system->A_matrix[i]);system->A_matrix=realloc(system->A_matrix,N*sizeof( double*)); for(i=0;iA_matrix[i]=realloc(system>A_matrix[i],N*sizeof(double)); if(!system->polar_iterative){ for(i=N;i<(N-dN);i++)free(system->B_matrix[i]);system->B_matrix=realloc(system->B_matrix,N*sizeof( double*)); for(i=0;iB_matrix[i]=realloc(system>B_matrix[i],N*sizeof(double)); } }elseif(dN>0){ system->A_matrix=realloc(system->A_matrix,N*sizeof( double*)); for(i=(N-dN);iA_matrix[i]=calloc(N,s izeof(double)); for(i=0;i<(N-dN);i++)system->A_matrix[i]=realloc(sy stem->A_matrix[i],N*sizeof(double)); if(!system->polar_iterative){ system->B_matrix=realloc(system->B_matrix,N*sizeof( double*)); for(i=(N-dN);iB_matrix[i]=calloc(N,s izeof(double)); for(i=0;i<(N-dN);i++)system->B_matrix[i]=realloc(sy stem->B_matrix[i],N*sizeof(double)); } } }/*inverttheAmatrix*/voidthole_bmatrix(system_t*system){ intN;molecule_t*molecule_ptr;atom_t*atom_ptr;/*countthenumberofatoms*/N=0;for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next) for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next) ++N; invert_matrix(3*N,system->A_matrix,system->B_matrix ); }/*getthedipolesbyvectormatrixmultiply*/voidthole_bmatrix_dipoles(system_t*system){ inti,j,ii,p,N;molecule_t*molecule_ptr;atom_t*atom_ptr,**atom_array;double*mu_array,*field_array;/*generateanarrayofatomptrs*/for(molecule_ptr=system->molecules,N=0,atom_array=N ULL;molecule_ptr;molecule_ptr=molecule_ptr->next){ for(atom_ptr=molecule_ptr->atoms;atom_ptr;atom_ptr= atom_ptr->next,N++){ atom_array=realloc(atom_array,sizeof(atom_t*)*(N+1) ); atom_array[N]=atom_ptr; } }/*allocateworkingarrays*/mu_array=calloc(3*N,sizeof(double));field_array=calloc(3*N,sizeof(double));/*copythefieldin*/for(i=0;ief_static[p]; }/*multiplythesupervectorwiththeBmatrix*/for(i=0;i<3*N;i++) for(j=0;j<3*N;j++) mu_array[i]+=system->B_matrix[i][j]*field_array[j]; /*copythedipolesout*/for(i=0;i
PAGE 290

ii=i*3;for(p=0;p<3;p++) atom_array[i]->mu[p]=mu_array[ii+p]; }/*freetheworkingarrays*/free(atom_array);free(mu_array);free(field_array); }/*numericalrecipesroutinesforinvertingageneralmatri x*/ #defineTINY1.0e-20voidLU_decomp(double**a,intn,int*indx,double*d){ inti,j,k,imax=0;doublebig,dum,sum,temp,*vv;vv=(double*)malloc(n*sizeof(double));*d=1.0;for(i=0;ibig)big=temp; /*notebigcannotbezero*/ if(big==0.0){ printf("LU_decomp:matrixtoinvertcan'tbesingular!\n" ); exit(0); }vv[i]=1.0/big; }for(j=0;j=big){ big=dum;imax=i; } }if(j!=imax){ for(k=0;k=0;i--){ sum=b[i];for(j=i+1;j
PAGE 291

for(j=0;j/*calculatethemolecularpolarizabilitytensorfromtheB matrix*/ voidthole_polarizability_tensor(system_t*system){ inti,j,ii,jj,N;intp,q;doubleisotropic;N=system->checkpoint->N_atom;/*clearthepolarizabilitytensor*/for(p=0;p<3;p++) for(q=0;q<3;q++) system->C_matrix[p][q]=0; /*sumtheblocktermsforthe3x3moleculartensor*/for(p=0;p<3;p++){ for(q=0;q<3;q++){ for(i=0;iC_matrix[p][q]+=system->B_matrix[ii+p][jj+q ]; } } } }/*gettheisotropicterm*/for(p=0,isotropic=0;p<3;p++) isotropic+=system->C_matrix[p][p]; isotropic/=3.0;printf("POLARIZATION:polarizabilitytensor(A^3):\n") ;fflush(stdout); printf("##########################\n");for(p=0;p<3;p++){ for(q=0;q<3;q++) printf("%.3f",system->C_matrix[p][q]); printf("\n"); }printf("##########################\n");printf("isotropic=%.3f\n",isotropic); }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include/*supportthefirst5sphericalharmonics,theyarehard-co dedbutnecessaryforgaussianquadratureintegration*/ /*(doingsomethingslicklikeafuncptrarray[l][m]wouldb ejustasugly)*/ doublerotational_basis(inttype,intl,intm,doublethet a,doublephi){ intm_abs;doublelegendre,Ylm;/*calculatetheprefactor*legendrepart*/m_abs=abs(m);if(l==0){ legendre=(1.0/2.0)*sqrt(1.0/M_PI); }elseif(l==1){ if(m_abs==0) legendre=(1.0/2.0)*sqrt(3.0/M_PI)*cos(theta); elseif(m_abs==1) legendre=-1.0*(1.0/2.0)*sqrt(3.0/(2.0*M_PI))*sin(th eta); }elseif(l==2){ if(m_abs==0) legendre=(1.0/4.0)*sqrt(5.0/M_PI)*(3.0*pow(cos(thet a),2.0)-1.0); elseif(m_abs==1) legendre=-1.0*(1.0/2.0)*sqrt(15.0/(2.0*M_PI))*(sin( theta)*cos(theta)); elseif(m_abs==2) 277

PAGE 292

legendre=(1.0/4.0)*sqrt(15.0/(2.0*M_PI))*pow(sin(th eta),2.0); }elseif(l==3){ if(m_abs==0) legendre=(1.0/4.0)*sqrt(7.0/M_PI)*(5.0*pow(cos(thet a),3.0)-3.0*cos(theta)); elseif(m_abs==1) legendre=-1.0*(1.0/8.0)*sqrt(21.0/M_PI)*sin(theta)* (5.0*pow(cos(theta),2.0)-1.0); elseif(m_abs==2) legendre=(1.0/4.0)*sqrt(105.0/(2.0*M_PI))*pow(sin(t heta),2.0)*cos(theta); elseif(m_abs==3) legendre=-1.0*(1.0/8.0)*sqrt(35.0/M_PI)*pow(sin(the ta),3.0); }elseif(l==4){ if(m_abs==0) legendre=(3.0/16.0)*sqrt(1.0/M_PI)*(35.0*pow(cos(th eta),4.0)-30.0*pow(cos(theta),2.0)+3.0); elseif(m_abs==1) legendre=-1.0*(3.0/8.0)*sqrt(5.0/M_PI)*sin(theta)*( 7.0*pow(cos(theta),3.0)-3.0*cos(theta)); elseif(m_abs==2) legendre=(3.0/8.0)*sqrt(5.0/(2.0*M_PI))*pow(sin(the ta),2.0)*(7.0*pow(cos(theta),2.0)-1.0); elseif(m_abs==3) legendre=-1.0*(3.0/8.0)*sqrt(35.0/M_PI)*pow(sin(the ta),3.0)*cos(theta); elseif(m_abs==4) legendre=(3.0/16.0)*sqrt(35.0/(2.0*M_PI))*pow(sin(t heta),4.0); }elseif(l==5){ if(m_abs==0) legendre=(1.0/16.0)*sqrt(11.0/M_PI)*(63.0*pow(cos(t heta),5.0)-70*pow(cos(theta),3.0)+15*cos(theta)); elseif(m_abs==1) legendre=-1.0*(1.0/16.0)*sqrt(165.0/(2.0*M_PI))*sin (theta)*(21.0*pow(cos(theta),4.0)-14.0*pow(cos(thet a),2.0)+ 1.0); elseif(m_abs==2) legendre=(1.0/8.0)*sqrt(1155.0/(2.0*M_PI))*pow(sin( theta),2.0)*(3.0*pow(cos(theta),3.0)-cos(theta)); elseif(m_abs==3) legendre=-1.0*(1.0/32.0)*sqrt(385.0/M_PI)*pow(sin(t heta),3.0)*(9.0*pow(cos(theta),2.0)-1.0); elseif(m_abs==4) legendre=(3.0/16.0)*sqrt(385.0/(2.0*M_PI))*pow(sin( theta),4.0)*cos(theta); elseif(m_abs==5) legendre=-1.0*(3.0/32.0)*sqrt(77.0/M_PI)*pow(sin(th eta),5.0); }elseif(l==6){ if(m_abs==0) legendre=(1.0/32.0)*sqrt(13.0/M_PI)*(231.0*pow(cos( theta),6.0)-315.0*pow(cos(theta),4.0)+ 105.0*pow(cos(theta),2.0)-5.0); elseif(m_abs==1) legendre=-1.0*(1.0/16.0)*sqrt(273.0/(2.0*M_PI))*(33 .0*pow(cos(theta),5.0)-30.0*pow(cos(theta),3.0)+ 5.0*cos(theta)); elseif(m_abs==2) legendre=(1.0/64.0)*sqrt(1365.0/M_PI)*pow(sin(theta ),2.0)*(33.0*pow(cos(theta),4.0)-18.0*pow(cos(theta ),2.0) +1.0); elseif(m_abs==3) legendre=-1.0*(1.0/32.0)*sqrt(1365.0/M_PI)*pow(sin( theta),3.0)*(11.0*pow(cos(theta),3.0)-3.0*cos(theta )); elseif(m_abs==4) legendre=(3.0/32.0)*sqrt(91.0/(2.0*M_PI))*pow(sin(t heta),4.0)*(11.0*pow(cos(theta),2.0)-1.0); elseif(m_abs==5) legendre=-1.0*(3.0/32.0)*sqrt(1001.0/M_PI)*pow(sin( theta),5.0)*cos(theta); elseif(m_abs==6) legendre=(1.0/64.0)*sqrt(3003.0/M_PI)*pow(sin(theta ),6.0); }elseif(l==7){ if(m_abs==0) legendre=(1.0/32.0)*sqrt(15.0/M_PI)*(429.0*pow(cos( theta),7.0)-693.0*pow(cos(theta),5.0)+ 315.0*pow(cos(theta),3.0)-35.0*cos(theta)); elseif(m_abs==1) legendre=-1.0*(1.0/64.0)*sqrt(105.0/(2.0*M_PI))*sin (theta)*(429.0*pow(cos(theta),6.0)-495.0*pow(cos(th eta), 4.0)+135.0*pow(cos(theta),2.0)-5.0); elseif(m_abs==2) legendre=(3.0/64.0)*sqrt(35.0/M_PI)*pow(sin(theta), 2.0)*(143.0*pow(cos(theta),5.0)-110.0*pow(cos(theta ),3.0) +15.0*cos(theta)); elseif(m_abs==3) legendre=-1.0*(3.0/64.0)*sqrt(35.0/(2.0*M_PI))*pow( sin(theta),3.0)*(143.0*pow(cos(theta),4.0)66.0*pow(cos(theta),2.0)+3.0); elseif(m_abs==4) legendre=(3.0/32.0)*sqrt(385.0/(2.0*M_PI))*pow(sin( theta),4.0)*(13.0*pow(cos(theta),3.0)-3.0*cos(theta )); elseif(m_abs==5) legendre=-1.0*(3.0/64.0)*sqrt(385.0/(2.0*M_PI))*pow (sin(theta),5.0)*(13.0*pow(cos(theta),2.0)-1.0); elseif(m_abs==6) legendre=(3.0/64.0)*sqrt(5005.0/M_PI)*pow(sin(theta ),6.0)*cos(theta); elseif(m_abs==7) legendre=-1.0*(3.0/64.0)*sqrt(715.0/(2.0*M_PI))*pow (sin(theta),6.0); }elseif(l==8){ if(m_abs==0) legendre=(1.0/256.0)*sqrt(17.0/M_PI)*(6435.0*pow(co s(theta),8.0)-12012.0*pow(cos(theta),6.0)+ 6930.0*pow(cos(theta),4.0)-1260.0*pow(cos(theta),2. 0)+35.0); elseif(m_abs==1) legendre=-1.0*(3.0/64.0)*sqrt(17.0/(2.0*M_PI))*sin( theta)*(715.0*pow(cos(theta),7.0)-1001.0*pow(cos(th eta), 5.0)+385.0*pow(cos(theta),3.0)-35.0*cos(theta)); elseif(m_abs==2) legendre=(3.0/128.0)*sqrt(595.0/M_PI)*pow(sin(theta ),2.0)*(143.0*pow(cos(theta),6.0)-143.0*pow(cos(the ta), 4.0)+33.0*pow(cos(theta),2.0)-1.0); elseif(m_abs==3) legendre=-1.0*(1.0/64.0)*sqrt(19635.0/(2.0*M_PI))*p ow(sin(theta),3.0)*(39.0*pow(cos(theta),5.0)26.0*pow(cos(theta),3.0)+3.0*cos(theta)); elseif(m_abs==4) legendre=(3.0/128.0)*sqrt(1309.0/(2.0*M_PI))*pow(si n(theta),4.0)*(65.0*pow(cos(theta),4.0)26.0*pow(cos(theta),2.0)+1.0); elseif(m_abs==5) legendre=-1.0*(3.0/64.0)*sqrt(17017.0/(2.0*M_PI))*p ow(sin(theta),5.0)*(5.0*pow(cos(theta),3.0)-cos(the ta)); elseif(m_abs==6) legendre=(1.0/128.0)*sqrt(7293.0/M_PI)*pow(sin(thet a),6.0)*(15.0*pow(cos(theta),2.0)-1.0); elseif(m_abs==7) 278

PAGE 293

legendre=-1.0*(3.0/64.0)*sqrt(12155.0/(2.0*M_PI))*p ow(sin(theta),7.0)*cos(theta); elseif(m_abs==8) legendre=(3.0/256.0)*sqrt(12155.0/(2.0*M_PI))*pow(s in(theta),8.0); }/*tackonthee^{i*m*phi}*/if(m<0){/*usethefactthatY_l(-m)=(-1)^m*cc(Y_lm)*/ if(type==REAL) Ylm=legendre*cos(fabs((double)m)*phi); elseif(type==IMAGINARY) Ylm=-1.0*legendre*sin(fabs((double)m)*phi); Ylm*=pow(-1.0,fabs((double)m)); }else{ if(type==REAL) Ylm=legendre*cos(((double)m)*phi); elseif(type==IMAGINARY) Ylm=legendre*sin(((double)m)*phi); }return(Ylm); }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include/*returnsthehamiltonianmatrixforthepotentialintegra tedovertheYlmbasis*/ complex_t**rotational_hamiltonian(system_t*system,m olecule_t*molecule,intlevel_max,intl_max){ intdim;inti,j;intli,mi,lj,mj;complex_t**hamiltonian;/*determinethesizeofthesymmetricmatrix*/dim=(l_max+1)*(l_max+1);/*allocateourhamiltonianmatrix*/hamiltonian=calloc(dim,sizeof(complex_t*));for(i=0;i*/hamiltonian[i][j].real=rotational_integrate(system, molecule,REAL,li,mi,lj,mj); hamiltonian[i][j].imaginary=rotational_integrate(sy stem,molecule,IMAGINARY,li,mi,lj,mj); /*storethelowerhalf*/if(i!=j){ hamiltonian[j][i].real=hamiltonian[i][j].real;hamiltonian[j][i].imaginary=-1.0*hamiltonian[i][j]. imaginary; }else{ /*addthekineticparttothediagonalelements*/hamiltonian[i][j].real+=system->quantum_rotation_B* ((double)(li*(li+1))); }/*outputthematrix*/printf("rotmat%d%d%.16lg%.16lgK(%.16lg%.16lgcm^-1)< %d%d|V|%d%d>\n",(i+1),(j+1), hamiltonian[i][j].real,hamiltonian[i][j].imaginary, hamiltonian[i][j].real*K2WN,hamiltonian[i][j].imagi nary*K2WN,li,mi,lj,mj); fflush(stdout); /*advancetheljwhenmjhitsthetop*/if(mj==lj)lj++; }/*forj*//*advancetheliwhenmihitsthetop*/if(mi==li)li++; }/*fori*/printf("\n");fflush(stdout);return(hamiltonian); }/*checkthewavefunctionforgorusymmetry*/intdetermine_rotational_eigensymmetry(molecule_t*mo lecule,intlevel,intl_max){ intsymmetry; 279

PAGE 294

doubletheta,phi;inti,l,m,index;complex_twavefunction[QUANTUM_ROTATION_SYMMETRY_POI NTS]; doublesqmod[QUANTUM_ROTATION_SYMMETRY_POINTS];doublemax_sqmod,max_theta,max_phi;complex_tmax_wavefunction,inv_wavefunction;/*scanafewrandompoints,picktheonewiththelargestsqua reoftherealpart*/ for(i=0,max_sqmod=0;iquantum_rotational_ eigenvectors[level][index].real*rotational_basis(RE AL, l,m,theta,phi); /*getthesquaremodulus*/sqmod[i]=wavefunction[i].real*wavefunction[i].real;/*ifwehaveanewmax,savethedomainpoint*/if(sqmod[i]>max_sqmod){ max_sqmod=sqmod[i];max_theta=theta;max_phi=phi; } }/*checkthesymmetryatthemaximum*/max_wavefunction.real=0;inv_wavefunction.real=0;for(l=0,index=0;l<=l_max;l++){ for(m=-l;m<=l;m++,index++){ /*getthevalueofthewavefunctionatthemaximum*/max_wavefunction.real+=molecule->quantum_rotational _eigenvectors[level][index].real*rotational_basis(R EAL,l,m, max_theta,max_phi); /*getthevalueofit'sinversion*/inv_wavefunction.real+=molecule->quantum_rotational _eigenvectors[level][index].real*rotational_basis(R EAL,l,m, (max_theta+M_PI),(max_phi+M_PI)); } }/*didwechangesign?*/if(max_wavefunction.real*inv_wavefunction.real<0.0) symmetry=QUANTUM_ROTATION_ANTISYMMETRIC; else symmetry=QUANTUM_ROTATION_SYMMETRIC; return(symmetry); }/*gettherotationalenergylevelsofasinglerotorinanext ernalpotential*/ voidquantum_rotational_energies(system_t*system,mol ecule_t*molecule,intlevel_max,intl_max){ complex_t**hamiltonian;inti,j,dim,p;/*variablesneededforzhpevx()*/charjobz,range,uplo;intvl,vu,il,iu,m,ldz,*iwork,*ifail,info;double*hamiltonian_packed,*eigenvalues,abstol,*z,*w ork,*rwork; /*determinethesizeofthesymmetricmatrix*/dim=(l_max+1)*(l_max+1);/*setupthelapackarguments*/hamiltonian_packed=calloc(dim*(dim+1)/2,sizeof(comp lex_t)); eigenvalues=calloc(dim,sizeof(double));z=calloc(dim*dim,sizeof(complex_t));work=calloc((2*dim),sizeof(complex_t));rwork=calloc((7*dim),sizeof(double));iwork=calloc((5*dim),sizeof(int));ifail=calloc(dim,sizeof(int));jobz='V';range='A';uplo='U';vl=0;vu=0;il=0;iu=0;abstol=0;m=0;ldz=dim;info=0;/*buildtherotationalhamiltonian*/hamiltonian=rotational_hamiltonian(system,molecule, level_max,l_max); /*packthelapackarray*/for(j=0,p=0;jquantum_rotationa l_energies[i]=eigenvalues[i]; 280

PAGE 295

/*storetheeigenvectors*/for(i=0,p=0;iquantum_rotational_eigenvectors[i][j].rea l=z[p]; molecule->quantum_rotational_eigenvectors[i][j].ima ginary=z[p+1]; } }/*getthesymmetryofeacheigenvector*/for(i=0;iquantum_rotational_eigensymmetry[i]=deter mine_rotational_eigensymmetry(molecule,i,l_max); /*freeourarrays*/for(i=0;iquantum_rotational_potential_grid[t][p]=s in(theta)*rotational_potential(system,molecule,thet a,phi); }/*fort*/ }/*forp*/ }/*findtherotational1-bodyenergiesforeachmoleculeint hesystem*/ voidquantum_system_rotational_energies(system_t*sys tem){ inti,j;molecule_t*molecule_ptr;/*gettherotationaleigenspectrumforeachmoveablemolec ule*/ for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ if(!(molecule_ptr->frozen||molecule_ptr->adiabatic) ){ /*generatethenecessarygrids*/quantum_rotational_grid(system,molecule_ptr);/*gettheenergylevels*/quantum_rotational_energies(system,molecule_ptr,sys tem->quantum_rotation_level_max, 281

PAGE 296

system->quantum_rotation_l_max); } }for(molecule_ptr=system->molecules;molecule_ptr;mol ecule_ptr=molecule_ptr->next){ if(!(molecule_ptr->frozen||molecule_ptr->adiabatic) ){ for(i=0;iquantum_rotation_level_max;i++){ printf("molecule#%d(%s)rotationallevel%d=%fK(%fcm^1or%f/B)",molecule_ptr->id, molecule_ptr->moleculetype,i,molecule_ptr->quantum_ rotational_energies[i],molecule_ptr->quantum_rotati onal_energies[i]*KB/(100.0*H*C), molecule_ptr->quantum_rotational_energies[i]/system ->quantum_rotation_B); if(molecule_ptr->quantum_rotational_eigensymmetry[i ]==QUANTUM_ROTATION_SYMMETRIC) printf("***symmetric***"); elseif(molecule_ptr->quantum_rotational_eigensymmet ry[i]==QUANTUM_ROTATION_ANTISYMMETRIC) printf("***antisymmetric***"); printf("\n"); }for(i=0;iquantum_rotation_level_max;i++){ printf("molecule#%d(%s)eigenvecrotlevel%d\n",molecu le_ptr->id,molecule_ptr->moleculetype,i); for(j=0;j<(system->quantum_rotation_l_max+1)*(syste m->quantum_rotation_l_max+1);j++) printf("\tj=%d%.16e%.16e\n",j,molecule_ptr->quantum _rotational_eigenvectors[i][j].real, molecule_ptr->quantum_rotational_eigenvectors[i][j] .imaginary); printf("\n"); } } } }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include/*Gauss-Legendreintegrator*//*abscissas+weightscourtesyofAbramowitz&Stegun,"Han dbookofMathematicalFunctions",9thEd.,p.916*/ doublerotational_integrate(system_t*system,molecule _t*molecule,inttype,intli,intmi,intlj,intmj){ intt,p;doubletheta,phi,theta_weight,phi_weight;doubleYi_real,Yj_real,Yi_img,Yj_img;doublepotential,integrand,integral;/*N=16*/doubleroots[QUANTUM_ROTATION_GRID]={-0.989400934991 649932596, -0.944575023073232576078,-0.865631202387831743880,-0.755404408355003033895,-0.617876244402643748447,-0.458016777657227386342,-0.281603550779258913230,-0.095012509837637440185, 0.095012509837637440185,0.281603550779258913230,0.458016777657227386342,0.617876244402643748447,0.755404408355003033895,0.865631202387831743880,0.944575023073232576078,0.989400934991649932596}; doubleweights[QUANTUM_ROTATION_GRID]={0.02715245941 1754094852, 0.062253523938647892863,0.095158511682492784810,0.124628971255533872052,0.149595988816576732081,0.169156519395002538189,0.182603415044923588867,0.189450610455068496285,0.189450610455068496285,0.182603415044923588867,0.169156519395002538189,0.149595988816576732081,0.124628971255533872052,0.095158511682492784810,0.062253523938647892863,0.027152459411754094852}; #ifdefXXX /*N=8*/doubleroots[QUANTUM_ROTATION_GRID]={-0.960289856497 536,-0.796666477413627,-0.525532409916329,-0.183434 642495650, 0.183434642495650,0.525532409916329,0.7966664774136 27,0.960289856497536}; doubleweights[QUANTUM_ROTATION_GRID]={0.10122853629 0376,0.222381034453374,0.313706645877887,0.36268378 3378362, 0.362683783378362,0.313706645877887,0.2223810344533 74,0.101228536290376,}; /*N=32*/doubleroots[QUANTUM_ROTATION_GRID]={-0.997263861849 481563545,-0.985611511545268335400,-0.9647622555875 06430774, -0.934906075937739689171, -0.896321155766052123965,-0.849367613732569970134,0.794483795967942406963, 282

PAGE 297

-0.732182118740289680387, -0.663044266930215200975,-0.587715757240762329041,0.506899908932229390024, -0.421351276130635345364, -0.331868602282127649780,-0.239287362252137074545,0.144471961582796493485, -0.048307665687738316235, 0.048307665687738316235,0.144471961582796493485,0.2 39287362252137074545, 0.331868602282127649780, 0.421351276130635345364,0.506899908932229390024,0.5 87715757240762329041, 0.663044266930215200975, 0.732182118740289680387,0.794483795967942406963,0.8 49367613732569970134, 0.896321155766052123965, 0.934906075937739689171,0.964762255587506430774,0.9 85611511545268335400, 0.997263861849481563545}; doubleweights[QUANTUM_ROTATION_GRID]={0.00701861000 9470096600,0.016274394730905670605,0.02539206530926 2059456, 0.034273862913021433103, 0.042835898022226680657,0.050998059262376176196,0.0 58684093478535547145, 0.065822222776361846838, 0.072345794108848506225,0.078193895787070306472,0.0 83311924226946755222, 0.087652093004403811143, 0.091173878695763884713,0.093844399080804565639,0.0 95638720079274859419, 0.096540088514727800567, 0.096540088514727800567,0.095638720079274859419,0.0 93844399080804565639, 0.091173878695763884713, 0.087652093004403811143,0.083311924226946755222,0.0 78193895787070306472, 0.072345794108848506225, 0.065822222776361846838,0.058684093478535547145,0.0 50998059262376176196, 0.042835898022226680657, 0.034273862913021433103,0.025392065309262059456,0.0 16274394730905670605, 0.007018610009470096600};#endif/*XXX*/ integral=0;for(p=0;pquantum_rotational_potential_gr id[t][p]; integrand*=potential;integral+=phi_weight*theta_weight*integrand; }/*fort*/ }/*forp*/integral*=0.5*M_PI*M_PI;return(integral); }/*@2007,JonathanBelofSpaceResearchGroupDepartmentofChemistryUniversityofSouthFlorida*/#include/*alignthemoleculewiththex-axisforinitialization*/voidalign_molecule(molecule_t*molecule){ atom_t*atom_ptr;doublerotation_matrix[3][3];doublecom[3];inti,ii,n;double*new_coord_array;doubletheta,phi;/*countthenumberofatomsinthemolecule,andallocatenew coordsarray*/ for(atom_ptr=molecule->atoms,n=0;atom_ptr;atom_ptr= atom_ptr->next)++n; new_coord_array=calloc(n*3,sizeof(double));/*savethecomcoordinate*/com[0]=molecule->com[0];com[1]=molecule->com[1];com[2]=molecule->com[2];/*translatethemoleculetotheorigin*/for(atom_ptr=molecule->atoms;atom_ptr;atom_ptr=atom _ptr->next){ atom_ptr->pos[0]-=com[0];atom_ptr->pos[1]-=com[1];atom_ptr->pos[2]-=com[2]; 283

PAGE 298

}/*makesurethatouratomchosenforfindingthepolarcoords doesn'thappentobeattheorigin*/ for(atom_ptr=molecule->atoms;atom_ptr;atom_ptr=atom _ptr->next) if(!((atom_ptr->pos[0]==0.0)&&(atom_ptr->pos[1]==0. 0)&&(atom_ptr->pos[2]==0.0)))break; /*getthecurrentpolarcoordinates*/if(atom_ptr->pos[2]==0.0) theta=0.0; else theta=acos(atom_ptr->pos[2]/sqrt(atom_ptr->pos[0]*a tom_ptr->pos[0]+atom_ptr->pos[1]*atom_ptr->pos[1]+ atom_ptr->pos[2]*atom_ptr->pos[2])); if((atom_ptr->pos[1]/atom_ptr->pos[0])>MAXDOUBLE) phi=atan(MAXDOUBLE); else{ phi=atan(fabs(atom_ptr->pos[1]/atom_ptr->pos[0]));if((atom_ptr->pos[1]/atom_ptr->pos[0])<0.0)phi*=-1. 0; }/*formtheinverserotationmatrixandmultiply*/theta*=-1.0;phi*=-1.0;rotation_matrix[0][0]=cos(phi)*cos(theta);rotation_matrix[0][1]=-sin(phi);rotation_matrix[0][2]=cos(phi)*(-sin(theta));rotation_matrix[1][0]=sin(phi)*cos(theta);rotation_matrix[1][1]=cos(phi);rotation_matrix[1][2]=sin(phi)*(-sin(theta));rotation_matrix[2][0]=sin(theta);rotation_matrix[2][1]=0;rotation_matrix[2][2]=cos(theta);for(atom_ptr=molecule->atoms,i=0;atom_ptr;atom_ptr= atom_ptr->next,i++){ ii=i*3;new_coord_array[ii+0]=rotation_matrix[0][0]*atom_pt r->pos[0]+rotation_matrix[0][1]*atom_ptr->pos[1]+ rotation_matrix[0][2]*atom_ptr->pos[2]; new_coord_array[ii+1]=rotation_matrix[1][0]*atom_pt r->pos[0]+rotation_matrix[1][1]*atom_ptr->pos[1]+ rotation_matrix[1][2]*atom_ptr->pos[2]; new_coord_array[ii+2]=rotation_matrix[2][0]*atom_pt r->pos[0]+rotation_matrix[2][1]*atom_ptr->pos[1]+ rotation_matrix[2][2]*atom_ptr->pos[2]; }/*setthenewcoordinatesandthentranslatebackfromtheor igin*/ for(atom_ptr=molecule->atoms,i=0;atom_ptr;atom_ptr= atom_ptr->next,i++){ ii=i*3;atom_ptr->pos[0]=new_coord_array[ii+0];atom_ptr->pos[1]=new_coord_array[ii+1];atom_ptr->pos[2]=new_coord_array[ii+2];atom_ptr->pos[0]+=com[0];atom_ptr->pos[1]+=com[1];atom_ptr->pos[2]+=com[2]; }/*freeourtemporaryarray*/free(new_coord_array); }/*rotatetheselectedmoleculetoanabsolutesphericalpol arpositionof(theta,phi)*/ voidrotate_spherical(molecule_t*molecule,doublethet a,doublephi){ atom_t*atom_ptr;doublerotation_matrix[3][3];doublecom[3];inti,ii,n;double*new_coord_array;/*countthenumberofatomsinthemolecule,andallocatenew coordsarray*/ for(atom_ptr=molecule->atoms,n=0;atom_ptr;atom_ptr= atom_ptr->next)++n; new_coord_array=calloc(n*3,sizeof(double));/*savethecomcoordinate*/com[0]=molecule->com[0];com[1]=molecule->com[1];com[2]=molecule->com[2];/*translatethemoleculetotheorigin*/for(atom_ptr=molecule->atoms;atom_ptr;atom_ptr=atom _ptr->next){ atom_ptr->pos[0]-=com[0];atom_ptr->pos[1]-=com[1];atom_ptr->pos[2]-=com[2]; }/*formtherotationmatrixandmultiply*/rotation_matrix[0][0]=cos(phi)*cos(theta);rotation_matrix[0][1]=-sin(phi);rotation_matrix[0][2]=cos(phi)*(-sin(theta));rotation_matrix[1][0]=sin(phi)*cos(theta);rotation_matrix[1][1]=cos(phi);rotation_matrix[1][2]=sin(phi)*(-sin(theta));rotation_matrix[2][0]=sin(theta);rotation_matrix[2][1]=0;rotation_matrix[2][2]=cos(theta);for(atom_ptr=molecule->atoms,i=0;atom_ptr;atom_ptr= atom_ptr->next,i++){ ii=i*3;new_coord_array[ii+0]=rotation_matrix[0][0]*atom_pt r->pos[0]+rotation_matrix[0][1]*atom_ptr->pos[1]+ rotation_matrix[0][2]*atom_ptr->pos[2]; new_coord_array[ii+1]=rotation_matrix[1][0]*atom_pt r->pos[0]+rotation_matrix[1][1]*atom_ptr->pos[1]+ rotation_matrix[1][2]*atom_ptr->pos[2]; new_coord_array[ii+2]=rotation_matrix[2][0]*atom_pt r->pos[0]+rotation_matrix[2][1]*atom_ptr->pos[1]+ 284

PAGE 299

rotation_matrix[2][2]*atom_ptr->pos[2]; }/*setthenewcoordinatesandthentranslatebackfromtheor igin*/ for(atom_ptr=molecule->atoms,i=0;atom_ptr;atom_ptr= atom_ptr->next,i++){ ii=i*3;atom_ptr->pos[0]=new_coord_array[ii+0];atom_ptr->pos[1]=new_coord_array[ii+1];atom_ptr->pos[2]=new_coord_array[ii+2];atom_ptr->pos[0]+=com[0];atom_ptr->pos[1]+=com[1];atom_ptr->pos[2]+=com[2]; }/*freeourtemporaryarray*/free(new_coord_array); }/*hinderedpotentialofsin(theta)^2*//*usedfortesting,comparedwithCurl,Hopkins,Pitzer,JC P(1968)48:4064*/ doublehindered_potential(doubletheta){ return(pow(sin(theta),2.0)); }/*putthemoleculeina(theta,phi)orientationandreturnt heenergy*/ doublerotational_potential(system_t*system,molecule _t*molecule,doubletheta,doublephi){ intq;molecule_t*molecule_backup;atom_t*atom_backup,*atom_ptr;doublepotential;if(system->quantum_rotation_hindered){ /*useahinderedrotorpotential,usefulfortestingaccura cy*/ potential=system->quantum_rotation_B*system->quantu m_rotation_hindered_barrier*hindered_potential(thet a); }else{ /*backupthemolecularcoordinates*/molecule_backup=copy_molecule(system,molecule);/*alignthemoleculewiththex-axisinitially*/align_molecule(molecule);/*performtherotation*/rotate_spherical(molecule,theta,phi);/*gettheenergyforthisconfiguration*/potential=energy_no_observables(system);/*restoretheoriginalatomiccoordinates*/for(atom_backup=molecule_backup->atoms,atom_ptr=mol ecule->atoms;atom_backup;atom_backup=atom_backup->n ext,atom_ptr =atom_ptr->next) for(q=0;q<3;q++) atom_ptr->pos[q]=atom_backup->pos[q]; /*restorethec.o.m.coordinates*/for(q=0;q<3;q++)molecule->com[q]=molecule_backup->c om[q]; /*freethebackupstructure*/free_molecule(system,molecule_backup); }return(potential); } 285

PAGE 300

AbouttheAuthor JonBelofreceivedhisB.A.inBiochemistry,withaminorinM athematics, fromtheUniversityofSouthFloridaandbegandoctoralwork inPhysicalChemistry withProfessorBrianSpacein2005.Hisdoctoralworkhaving beenfundedbyDOE, NSFandNASA,Jonhasauthorednumerouspapersintheareasof nanomaterials, moleculartheoryandcomputation.Hisresearchisfocusedo ntheapplicationof statisticalphysics,quantummechanicsandthetheory&sim ulationofcondensed mattertowardinterestingproblemsinmaterialsandbiophy sics.Hehasextensive experienceindevelopingsupercomputingapplications,ha vingdevelopedfortheCray XT4,BlueGene/L,SGIAltixandHPCclusters.Priortopursui nghisdoctorate,Jon workedasaninformationsecurityconsultantfornumerousF ortune500companies andgovernmentagenciesincludingtheNSA,theU.S.Army,FC C,HUDandDOJ.


xml version 1.0 encoding UTF-8 standalone no
record xmlns http:www.loc.govMARC21slim xmlns:xsi http:www.w3.org2001XMLSchema-instance xsi:schemaLocation http:www.loc.govstandardsmarcxmlschemaMARC21slim.xsd
leader nam 2200421Ka 4500
controlfield tag 001 002069479
005 20100422122029.0
007 cr mnu|||uuuuu
008 100422s2009 flu s 000 0 eng d
datafield ind1 8 ind2 024
subfield code a E14-SFE0003272
035
(OCoLC)608505691
040
FHM
c FHM
049
FHMM
090
QD31.2 (Online)
1 100
Belof, Jonathan L.
0 245
Theory and simulation of metal-organic materials and biomolecules
h [electronic resource] /
by Jonathan L. Belof.
260
[Tampa, Fla] :
b University of South Florida,
2009.
500
Title from PDF of title page.
Document formatted into pages; contains 285 pages.
Includes vita.
502
Dissertation (Ph.D.)--University of South Florida, 2009.
504
Includes bibliographical references.
516
Text (Electronic dissertation) in PDF format.
3 520
ABSTRACT: The emerging field of nanomaterials has raised a number of fascinating scientific questions that remain unanswered. Molecular theory and computer simulation are key tools to unlocking future discoveries in materials science, and various computational techniques and results toward this goal are elucidated here. High-performance computing methods (utilizing the latest supercomputers and codes) have been developed to explore and predict the chemistry and physical properties of systems as diverse as Metal-Organic Frameworks, discrete nanocubes, photoswitch molecules, porphyrins and several interesting enzymes. In addition, highlights of fundamental statistical physics, such as the Feynman-Hibbs effective partition function and generalized ensemble theory, are expounded and upon from the perspective of both research and pedagogy.
538
Mode of access: World Wide Web.
System requirements: World Wide Web browser and PDF reader.
590
Advisor: Brian Space, Ph.D.
653
Nanomaterials
Metal-organic frameworks
Condensed matter
Statistical mechanics
Computer simulation
Monte Carlo
Molecular dynamics
690
Dissertations, Academic
z USF
x Chemistry
Doctoral.
773
t USF Electronic Theses and Dissertations.
4 856
u http://digital.lib.usf.edu/?e14.3272