""" In this example, we pack 10,000 water molecules in a sphere of radius 50 Å and center (50, 50, 50). """ from molecular_builder import pack_water from molecular_builder.geometry import SphereGeometry water = pack_water(nummol=10000, geometry=SphereGeometry((50, 50, 50), 50)) water.write("water_sphere.data", format="lammps-data")
from molecular_builder import pack_water, write from molecular_builder.geometry import BoxGeometry geometry = BoxGeometry((50, 25, 25), (100, 50, 50)) atoms = pack_water(nummol=2000, geometry=geometry) write(atoms, "box.data") write(atoms, "box.png", camera_dir=[1, 2, -1])
import numpy as np L = np.array([80, 60, 80]) atoms = create_bulk_crystal("brucite", L) L = atoms.cell.lengths() geometry = BoxGeometry(center=L / 2, length=[L[0], L[1] / 2 - 3, 4 * L[2] / 5 + 2], periodic_boundary_condition=(True, True, True)) carve_geometry(atoms, geometry, side="out") volume = atoms.cell.volume water_volume = volume - geometry.volume() pack_water(atoms=atoms, volume=water_volume, pbc=2.0, tolerance=1.8) write(atoms, "brucite_in_water.data", bond_specs=("O", "H", 1.02)) write(atoms, "brucite_in_water_perspective.png", bond_specs=("O", "H", 1.02), camera_dir=[1, 0, 0], viewport_type="perspective", size=(480, 640)) write(atoms, "brucite_in_water_orthogonal.png", bond_specs=("O", "H", 1.02), camera_dir=[1, 0, 0], viewport_type="orthogonal", size=(480, 640))
from molecular_builder import create_bulk_crystal, carve_geometry, fetch_prepared_system, write, pack_water from molecular_builder.geometry import BoxGeometry blob = fetch_prepared_system("ch_blob/10nm", type_mapping=[(1, 6), (2, 1)]) blob.positions[:, 2] += 37 slab = fetch_prepared_system( "vashishta_1990_like_amorphous_silica/quench_950K", type_mapping=[(1, 14), (2, 8)]) slab.cell[2, 2] += 105 sodium_chlorate = create_bulk_crystal("sodium_chlorate", size=(slab.cell[0, 0], slab.cell[1, 1], 25), round="down") carve_geometry(sodium_chlorate, BoxGeometry([slab.cell[0, 0] * 3 / 4, slab.cell[1, 1] / 2, 0], [slab.cell[0, 0] / 2, slab.cell[1, 1] + 100, 5]), side="in") sodium_chlorate.translate((0, 0, 118)) atoms = (slab + blob) + sodium_chlorate pack_water(atoms, 10000, pbc=2.0, tolerance=2.0) write(atoms, "sodium_chlorate_hydrocarbon_blob_water.png", camera_dir=(0, 1, 0), viewport_type="orthogonal", bond_specs=[("O", "H", 0.95), ("Si", "O", 1.9)], atom_radii=[("Si", 0.2), ("O", 0.6)])
from molecular_builder import create_bulk_crystal, carve_geometry, write, pack_water from molecular_builder.geometry import CylinderGeometry import numpy as np atoms = create_bulk_crystal("alpha_quartz", [60, 60, 60]) r = 25 l = atoms.cell[0][0] geometry = CylinderGeometry([30, 30, 30], r, 100, orientation=[1, 0, 0]) water_volume = np.pi * r**2 * l carve_geometry(atoms, geometry, side="in") pack_water(atoms, volume=water_volume, pbc=4.0, tolerance=1.5, density=0.8) write(atoms, "alpha_quartz_cylinder_hole_water.data") write(atoms, "alpha_quartz_cylinder_hole_water.png", camera_dir=[3, 1, -1])
""" In this example, we pack 10,000 water molecules in a box with center (50, 25, 25) and length (100Å, 50Å, 50Å). """ from molecular_builder import pack_water from molecular_builder.geometry import BoxGeometry water = pack_water(nummol=10000, geometry=BoxGeometry((50, 25, 25), (100, 50, 50))) water.write("water_box.data", format="lammps-data")
import numpy as np from molecular_builder import fetch_prepared_system, carve_geometry, pack_water from molecular_builder.geometry import SphereGeometry, CubeGeometry # Amorphous silica of size (357, 143, 143) amorph = fetch_prepared_system("amorphous_silica_1") num_spheres = 5 for sphere in range(num_spheres): i, j, k, l = np.random.uniform(size=4) x, y, z, r = i * 357, j * 143, k * 143, l * 30 + 5 geometry = SphereGeometry([x, y, z], r, periodic_boundary_condition=(True, True, True)) tmp_carved = carve_geometry(amorph, geometry, side="in") print(f"tmp carved: {tmp_carved}") water = pack_water(2000, atoms=amorph) #, geometry=CubeGeometry([60,60,60], 130)) system = water + amorph amorph.write("amorph.data", format="lammps-data") water.write("water.data", format="lammps-data") system.write("system.data", format="lammps-data")
""" In this example, we first fetch a block of amorphous silica of size (357Å, 143Å, 143Å). We then carve spheres of random sizes at random locations, and finally pack 10,000 water molecules into the voids. """ from molecular_builder import fetch_prepared_system, carve_geometry, pack_water from molecular_builder.geometry import SphereGeometry import numpy as np # Amorphous silica of size (357, 143, 143) amorph = fetch_prepared_system("amorphous_silica_1") num_spheres = 20 for sphere in range(num_spheres): i, j, k, l = np.random.uniform(size=4) x, y, z, r = i * 357, j * 143, k * 143, l * 50 geometry = SphereGeometry((x, y, z), r, periodic_boundary_condition=(1, 1, 1)) tmp_carved = carve_geometry(amorph, geometry, side="in") print(f"tmp carved: {tmp_carved}") amorph.write("amorph.data", format="lammps-data") # Pack water into voids water = pack_water(nummol=10000, atoms=amorph) system = water + amorph water.write("water.data", format="lammps-data") system.write("system.data", format="lammps-data")