|
from pathlib import Path |
|
|
|
from manim import Scene, ThreeDScene, config |
|
|
|
from manim_chemistry import (BohrAtom, GraphMolecule, MElementObject, |
|
MMoleculeObject, Orbital, PeriodicTable, |
|
ThreeDMolecule, sdf_parser) |
|
|
|
script_path = Path(__file__).absolute().parent |
|
files_path = script_path / "element_files" |
|
|
|
|
|
|
|
class Draw2DMorphine(Scene): |
|
|
|
config.renderer = "cairo" |
|
|
|
def construct(self): |
|
morphine = MMoleculeObject.from_mol_file(filename=files_path / "morphine.mol") |
|
self.add(morphine) |
|
|
|
|
|
class Draw2DMorphineSDF(Scene): |
|
config.renderer = "cairo" |
|
|
|
def construct(self): |
|
parts = sdf_parser(file=files_path / "morphine.sdf") |
|
atoms, bonds = parts[0] |
|
morphine = MMoleculeObject(atoms, bonds) |
|
self.add(morphine) |
|
|
|
|
|
|
|
class DrawGraphMorphine(Scene): |
|
|
|
config.renderer = "cairo" |
|
|
|
def construct(self): |
|
self.add(GraphMolecule.build_from_mol(mol_file=files_path / "morphine.mol")) |
|
|
|
|
|
class DrawLabeledGraphMorphine(Scene): |
|
|
|
config.renderer = "cairo" |
|
|
|
def construct(self): |
|
self.add( |
|
GraphMolecule.build_from_mol( |
|
mol_file=files_path / "morphine.mol", label=True |
|
) |
|
) |
|
|
|
|
|
|
|
class Draw3DMorphine(ThreeDScene): |
|
|
|
config.renderer = "opengl" |
|
|
|
def construct(self): |
|
self.add( |
|
ThreeDMolecule.from_mol_file( |
|
filename=files_path / "morphine3d.mol", |
|
source_csv=files_path / "Elementos.csv", |
|
) |
|
) |
|
self.wait() |
|
|
|
|
|
|
|
class DrawCarbonElement(Scene): |
|
|
|
config.renderer = "cairo" |
|
|
|
def construct(self): |
|
self.add( |
|
MElementObject.from_csv_file_data( |
|
filename=files_path / "Elementos.csv", atomic_number=6 |
|
) |
|
) |
|
|
|
|
|
|
|
class DrawPeriodicTable(Scene): |
|
|
|
config.renderer = "cairo" |
|
|
|
def construct(self): |
|
self.add(PeriodicTable(data_file=files_path / "Elementos.csv")) |
|
|
|
|
|
|
|
class DrawPOrbital(ThreeDScene): |
|
|
|
config.renderer = "opengl" |
|
|
|
def construct(self): |
|
self.add(Orbital(l=1, m=-1)) |
|
|
|
|
|
|
|
class BohrDiagram(Scene): |
|
|
|
config.renderer = "cairo" |
|
|
|
def construct(self): |
|
self.add(BohrAtom()) |
|
|