Vous êtes sur la page 1sur 6

PythonBasedKineticMonteCarloSimulationTool

ZaiweiZhang,R.EdwinGarca
Nowadays,scholarsareworkingonnanoscalemoreandmorefrequently.Atthatscale, descriptionscouldbehardtomadesincemostofnanomaterialscannotbeseenatnormallife. Therefore,programsimulationofnanoscaledmaterialsaremoreandmoreneeded. ProjectGoals: Myresearchprojectisdevelopingasimulationtoolforthediffusionreactionsindifferenttypes ofmaterials.MymainresponsibilityistocreateaGraphicUserInterfaceofthetoolandgenerate graphicalresultssothatuserscanhavemoreunderstandingontheoutput.Therefore,myresearch interestsmainlyfocusedonGraphicUserInterfacedesign,ComputationOptimizing,or HumanMachineInterfacing. ResearchMethods: TocreatetheGraphicUserInterface,IusedtheVirtualKineticsofMaterialsLaboratory createdbyProf.Garcia,AlexBartolandDavidR.ElyfromSchoolofMaterialsEngineeringatPurdue University.Thesoftwareispythonbasedandisusedtogetinputsimulationdatafromtheuser. However,therearenomethodstodisplaygraphicaloutputsbyusingtheVirtualKineticsofMaterials Laboratorysoftware.Therefore,GTK+toolkithasbeenusedtocreateanothergraphicuserinterface todisplaythegraphicaloutputs.GTK+isanopensourcesoftwarespecializedincreatingGraphicUser Interface. Forthediffusionsimulationbetweendifferentmaterials,materialpropertiesneedtobedefined firstsothattheprogramcancreatethecorrespondinglatticeandproceedthesimulation.Therefore,I createamenufortheprogram,andifclickingthemenubuttonsinthepulldownmenu,thereisa separatewindowforeachmenu.Inthefirstwindow,therewillbesliderbarsorpulldownmenutoget inputinformationfromuser.Alltherequiredinputinthefirstwindowarewhatneededtocreatethe latticeaccordingtotheinputmaterialproperty.Inthesecondwindow,therewillbecontrolstogetthe informationofthesimulationenvironment,suchastemperatureandnumberofstepsofthesimulation. Userwillbeabletostartthesimulationandgeneratealltheoutputsinthesecondwindow.Bydoing this,usercanbeinformedwiththeorderofthesimulationstep,andhaveamuchclearersenseofhow thesimulationwillberunning.Also,therewillbelesspotentialerrorsdonebyusersbydoingthat.Since thesimulationmaytakealongtime,theoutputimagewillbeupdatedasnewsimulationresultsarrived. Togetarealtimeupdatedplot,GTK+toolkithasbeenusedtocreatetheoutputframeandtocreate themainlooptocontinuesthesimulation. KeyResults:

Figure1.GraphicUserInterfaceofthesimulationtool ThetwowindowsaboveistheGraphicUserInterfaceofthesimulationtool.Thefirstwindowis thefirstoutputwindowofthefirstoptioninthepulldownmenu,whilethesecondwindowisthesecond outputwindowofthesecondoptioninthepulldownmenu.Asseenabove,theinputcontrolsinthefirst windowaremainlyrelatedtothesizeofthelatticeandmaterialsused.Thoseinformationwillbeusedto createthelattice.However,theinputcontrolsinthesecondwindowaremainlyrelatedtothesimulation environment.Thoseinformationareusedinsimulatingtheexperiment.Thereisanoptioninthesecond windowusedtogenerateaGIFfileofalltheoutputpictures.BylookingattheGIFmovie,the simulationresultswillbemoreclearerandpersuasive.

Figure2.Snapshotsoftheoutputimageduringthesimulation Thethreeimagesabovearethreephasesduringthesimulation.Thefirstimageistheoutputin thebeginningofthesimulation,thesecondimageistheoutputinthemiddleofthesimulationandthe thirdimageistheoutputintheendofthesimulation.Asseenabove,theoutputimageisupdatedduring thesimulation. AnalysisandInterpretation: Theoutputsshownintheresultssectionhassuccessfullydisplayedthediffusivitypropertyofthe silvermaterial.Ithasshownaproperresultofthesilverselfdiffusion.

Appendices

Appendix1: Theprogram,whichcontainsthephysicalengineofvacancydiffusionmechanism,hasalready beenprogrammedbyProf.GarciaandDaveR.ElyinMSEdepartmentatPurdue.However,users cannotobservethechangingnumbersofdiffusivitiesduringVacancyDiffusionsimulationsbetween differentmaterials.Also,thereisnoGraphicUserInterfaceforthesimulationtools.Tosolvethe problem,theVirtualKineticsofMaterialsLaboratoryprogramisusedtocreatetheGraphicUser Interface.Also,GTK+toolkithasbeenusedtocreateapopupwindowdisplayingupdateddiffusivities duringthesimulation.Foruserpurpose,thepopupwindowhasbeensettodisplayaplotofdiffusivity versussimulationtime.Duringtheprogrammingprocess,severalproblemswerefoundandsolvedby usingGTK+mainloopandfunctionsinMatplotlibplottinglibrary. Themainchallenge,whichiscreateanupdatedimagewiththerealtimeupdatedinformation, wassolvedbyusingtheGTK+mainloop.Bydoingthat,thefunctionpointerofthesimulationfunction intheprogramhasbeenpassedtotheGTK+mainloop.TheGTK+enginewillrunthefunction automaticallyuntilthereisaFalsevaluereturned.Aslongasthefunctionisrunning,theset_data functionwillbeusedtoupdatethenewlineofdataintheplottingfunction.Theplottingfunctionisusing thematplotliblibrary.Thematplotlibreturnsanobjectreferenceaftereachplottingfunctionbeingcalled, whichallowsmetocontrolthelineobject.Bydoingthat,Iamabletoupdatethelinedrawntoreflect thenewvalues. Appendix2: Thefigure1hasshownthefinalGraphicalUserInterface.Theprogramhasthefollowingmain features: Beabletogenerateamodelforacubiclatticewiththethreedimensionalmeasurementsenteredby usersandthematerialchosenbyusers Simulationtemperatureiscontrolledbyusers Numberofhopsduringthesimulationiscontrolledbyusers BeabletogenerateaGIFfilebasedonallthepicturesgeneratedduringthesimulation UserscanclearallthematerialsgeneratedduringthesimulationbyclicktheRunbuttonbesidethe ResetTag Simulationresultswillbedisplayedgraphicallyduringtheruntimesimulation Also,asshownabove,thefigure2isthemainoutputofthesimulationtool.Itsarealtimeplot simulation.Thefollowingpicturesaresomeoutputpicturesgeneratedbythesimulationtool.

Appendix3(References): 1.Ely,D.R.,&Garcia,E.R.(2013).KMCUserManualVersion0.1. 2.Tosi,S(2009).MatplotlibforPythonDevelopers.Birmingham,UK:PacktPublishingLtd.

Vous aimerez peut-être aussi