Home Examples Screenshots User manual Bluesky logo YouTube 中文
OghmaNano Simulate organic/Perovskite Solar Cells, OFETs, and OLEDs DOWNLOAD

PyOghma

You can get a long way by manipulating OghmaNano’s JSON configuration files directly from Python (editing sim.json on disk and running oghma_core.exe). However, if you want to run many simulations in parallel to generate large datasets, you quickly end up needing an orchestration layer: creating run directories, cloning input files, launching multiple solver instances, and managing a queue of jobs across CPU cores.

In addition, raw JSON manipulation in Python is not always pleasant: it is easy to make mistakes, and the code can become verbose compared to a higher-level interface that knows about common simulation objects. For this reason, Cai Williams created an API called PyOghma which can be used to manipulate OghmaNano JSON files and run simulations. PyOghma is a stand-alone project, so please direct questions, bug reports, and feature requests to the PyOghma author.

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

       Oghma = po.OghmaNano()
       Results = po.Results()


       source_simulation = "\exapmle\pm6y6\"

      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:

Oghma.clone('NewExperiment0')

Then at the end of the code the following two lines. The first adds the job to the PyOghma job list and the second tells PyOghma to execute all jobs. If there were more than one job, PyOghma would execute multiple jobs across all CPUs until they were finished. If you wanted to run simulations with different values of mobility, you would add each simulation to the jobs list, then call \(run\_jobs\) once to run the jobs across all cores efficiently.

Oghma.add_job(experiment_name)
Oghma.run_jobs()

More information about PyOghma is available on the GitHub page.