PyOghma
One can get a long way by manipulating the OghmaNano json files directly with python as described in 17.4.1. However, using this approach it is not possible (very easy) to run multiple simulations at the same time. And as most modern CPUs have 8 or more cores it seems a waste not to be running multiple simulations when generating large data sets. Furthermore, manipulating json files in Python is not very intuitive and not very python like. For this reason Cai Williams has written an API called PyOghma which can be used to manipulate OghmaNano json files and also run simulations. This is a stand alone project to OhgmaNano, so direct any questions about this to him!
PyOghma is available on GitHub and also via pip:
python -m pip install PyOghma
An example of using PyOghma is given below [python-example3]:
import PyOghma as po
= po.OghmaNano()
Oghma = po.Results()
Results
= "\exapmle\pm6y6\"
source_simulation
Oghma.set_source_simulation(source_simulation)
experiment_name = 'NewExperiment'
Oghma.set_experiment_name(experiment_name)
mobility = 1e-5
trap_desnsity = 1e-18
trapping_crosssection = 1e-20
recombination_crosssection = 1e-20
urbach_energy = 40e-3
temperature = 300
intensity = 0.5
experiment_name = 'NewExperiment' + str(1)
Oghma.clone('NewExperiment0')
Oghma.Optical.Light.set_light_Intensity(intensity)
Oghma.Optical.Light.update()
Oghma.Thermal.set_temperature(temperature)
Oghma.Thermal.update()
Oghma.Epitaxy.load_existing()
Oghma.Epitaxy.pm6y6.dos.mobility('both', mobility)
Oghma.Epitaxy.pm6y6.dos.trap_density('both', trap_desnsity)
Oghma.Epitaxy.pm6y6.dos.trapping_rate('both', 'free to trap',..
trapping_crosssection)
Oghma.Epitaxy.pm6y6.dos.trapping_rate('both', 'trap to free',..
recombination_crosssection)
Oghma.Epitaxy.pm6y6.dos.urbach_energy('both', urbach_energy)
Oghma.Epitaxy.update()
Oghma.add_job(experiment_name)
Oghma.run_jobs()
In this example PyOghma is imported as po, and a source OghmaNano json file is manipulated by changing the values of mobility, trap density, trapping rate and Urbach Energy. The original file is cloned with the line:
'NewExperiment0') Oghma.clone(
Then at the end of the code the following two lines. The first of which adds the job to the job list in PyOghma. And the second line tells PyOghma to execute all the jobs. If there were more than one job PyOghma would execute multiple jobs across all CPUs, until they were all finished. If for example one wanted to run simulations with different values of mobility, one would add each simulation to the jobs list, then call \(run\_jobs\) once to run the jobs across all cores in an efficient way.
Oghma.add_job(experiment_name)
Oghma.run_jobs()
More information about PyOghma is available on the GitHub page.