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

PyOghma

17.4.1 所述,通过使用 python 直接操作 OghmaNano 的 json 文件可以完成大量工作。然而,使用这种方法很难(并不容易)同时运行多个仿真。而大多数现代 CPU 有 8 个或更多核心,在生成大型数据集时不并行运行多个仿真似乎是一种浪费。此外,在 Python 中操作 json 文件并不直观,也不太“Python 风格”。因此,Cai Williams 编写了一个名为 PyOghma 的 API,可用于操作 OghmaNano 的 json 文件并运行仿真。这是一个独立于 OhgmaNano 的项目,因此关于它的任何问题请直接联系他!

PyOghma 可在 GitHub 上获取,也可通过 pip 安装:

python -m pip install PyOghma

下面给出了一个使用 PyOghma 的示例 [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()

在该示例中,PyOghma 以 po 的形式导入,并通过修改迁移率、陷阱密度、俘获速率和 Urbach 能量等数值来操作一个源 OghmaNano json 文件。原始文件通过如下语句进行克隆:

Oghma.clone('NewExperiment0')

然后在代码末尾是以下两行。第一行将任务添加到 PyOghma 的任务列表中。第二行告诉 PyOghma 执行所有任务。如果有多个任务,PyOghma 会在所有 CPU 上并行执行多个任务,直到全部完成。例如,如果希望在不同迁移率取值下运行仿真,可以将每个仿真都加入任务列表,然后只调用一次 \(run\_jobs\),即可在所有核心上以高效方式运行这些任务。

Oghma.add_job(experiment_name)
Oghma.run_jobs()

关于 PyOghma 的更多信息可在 GitHub 页面上获取。