Three D Molecules¶
- class manim_chemistry.threeD.threedmolecule.ThreeDMolecule(atoms_dict, bonds_dict, source_csv: str | None = None, add_bonds=True, add_atoms=True, *mobjects, **kwargs)[source]¶
Bases:
OpenGLGroup
,AbstractMolecule
Draws a 3D Molecule
Requires using opengl renderer.
Examples:¶
from manim_chemistry import * class ThreeDMoleculeFromFile(Scene): def construct(self): config.renderer = "opengl" molecule = GraphMolecule.molecule_from_file( "../examples/molecule_files/mol_files/acetone_3d.mol" ) self.wait() self.play(Write(molecule)) self.wait()
from manim_chemistry import * class ThreeDMoleculeFromFileWithHydrogens(Scene): def construct(self): config.renderer = "opengl" molecule = ThreeDMolecule.molecule_from_file( "../examples/molecule_files/mol_files/acetone_3d.mol", ignore_hydrogens=False ) self.wait() self.play(Write(molecule)) self.wait()
from manim_chemistry import * class ThreeDMoleculeFromPubChem(Scene): def construct(self): config.renderer = "opengl" molecule = ThreeDMolecule.molecule_from_pubchem(name="acetone") self.wait() self.play(Write(molecule)) self.wait()
from manim_chemistry import * class ThreeDMoleculeFromPubChemThreeD(Scene): def construct(self): config.renderer = "opengl" molecule = ThreeDMolecule.molecule_from_pubchem( name="acetone", three_d=True, ignore_hydrogens=False ) self.wait() self.play(Write(molecule)) self.wait()
- group_class¶
alias of
OpenGLGroup
- static mc_molecule_to_atoms_and_bonds(mc_molecule: MCMolecule)[source]¶
Transforms the structure of a mc_molecule to a (atoms, bonds) tuple with the following structure: - Vertices: {<atom_index>: MCAtom} - Edges: {(<from_atom_index>, <to_atom_index>): MCBond}
- Args:
mc_molecule (MCMolecule): The origin MCMolecule
- Returns:
Tuple[Dict, Dict]: See above.