コード例 #1
0
from molecular_builder import create_bulk_crystal, carve_geometry, write
from molecular_builder.geometry import BoxGeometry

atoms = create_bulk_crystal("silicon_carbide_3c", [100, 100, 100])

geometry = BoxGeometry([50, 50, 50], [70, 70, 70])

carve_geometry(atoms, geometry, side="out")

write(atoms, "box.data")
write(atoms, "box.png", camera_dir=[3, 2, -1])
コード例 #2
0
from molecular_builder import create_bulk_crystal, carve_geometry, fetch_prepared_system
from molecular_builder.geometry import BerkovichGeometry, CylinderGeometry

slab = fetch_prepared_system("vashishta_1990_like_amorphous_silica/quench_950K")
slab.cell[2,2] = 80 # Expand cell in z direction to fit indenter 

indenter = create_bulk_crystal("diamond", (144, 144, 80), round="down")
carve_geometry(indenter, BerkovichGeometry((75, 75, 40)), side="out")
carve_geometry(indenter, CylinderGeometry((75, 75, 50), 60, 200, orientation=(0,0,1)), side="out")

atoms = slab+indenter

atoms.write("indenter_and_glass.data", format="lammps-data")
コード例 #3
0
from ase.io import read
from molecular_builder import carve_geometry, write
from molecular_builder.geometry import ProceduralSurfaceGeometry

atoms = read("block.data", format="lammps-data", style="molecular")


# Define function to add
def f(x, y):
    if x < 100:
        return x / 100
    else:
        return 1 - (x - 100) / 100


# Carve out geometry from beta-cristobalite
geometry = ProceduralSurfaceGeometry(point=(100, 100, 40),
                                     normal=(0, 0, 1),
                                     thickness=20,
                                     method='simplex',
                                     scale=3,
                                     octaves=2,
                                     seed=16591,
                                     threshold=0,
                                     repeat=True,
                                     f=f)
num_carved = carve_geometry(atoms, geometry, side="out")

write(atoms, "add_function.data")
write(atoms, "add_function.png", camera_dir=[0, 1, -1])
コード例 #4
0
from molecular_builder import create_bulk_crystal, carve_geometry
from molecular_builder.geometry import PlaneGeometry

atoms = create_bulk_crystal("alpha_quartz", [120, 120, 120])

geometry = PlaneGeometry([60, 60, 60], [1, 0, 0],
                         periodic_boundary_condition=(True, True, True))

num_carved, carved = carve_geometry(atoms,
                                    geometry,
                                    side="in",
                                    return_carved=True)

atoms.write("block_inside_plane.data", format="lammps-data")
carved.write("block_outside_plane.data", format="lammps-data")
コード例 #5
0
c = 5.51891759  # length of triclinic unit cell in c-dir (and z-dir)
angle = 60
h = b * np.sin(np.deg2rad(angle))  # length of triclinic unit cell in y-dir

numcellsx = -(-xlen // a)   # number of cells in x-dir, rounded up
numcellsy = -(-ylen // h)   # number of cells in y-dir, rounded up
numcellsz = -(-zlen // c)   # number of cells in z-dir, rounded up

lengthx = numcellsx * a     # actual length in x-dir
lengthy = numcellsy * h     # actual length in y-dir
lengthz = numcellsz * c     # actual length in z-dir

lengthnoise = np.asarray((lengthx, lengthy, lengthz))
scalenoise = lengthnoise / scale

# Create bulk of alpha-quartz
quartz = create_bulk_crystal("alpha_quartz", (xlen, ylen, zlen))

# Carve out geometry from alpha-quartz
surface_geometry = ProceduralSurfaceGeometry(point=(xlen/2, ylen/2, zlen/2),
                                             normal=(0, 0, 1),
                                             thickness=noise_thickness,
                                             octaves=octaves,
                                             scale=scalenoise,
                                             pbc=lengthnoise,
                                             angle=angle,
                                             method='perlin',
                                             threshold=0)
carve_geometry(quartz, surface_geometry, side="in")
quartz.write("quartz.data", format="lammps-data")
コード例 #6
0
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)])
コード例 #7
0
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])
コード例 #8
0
import numpy as np
from molecular_builder import fetch_prepared_system, carve_geometry
from molecular_builder.geometry import SphereGeometry
from pack_water import PackWater
from pack_water.geometry import BoxGeometry, Fixed
import ase

# Fetch amorphous silica
silica = 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 * 30
    geometry = SphereGeometry([x, y, z],
                              r,
                              periodic_boundary_condition=(True, True, True))
    tmp_carved = carve_geometry(silica, geometry, side="in")
    print(f"tmp carved: {tmp_carved}")

# Write amorphous silica with voids to pdb-filetype
silica.write("amorphous_void.pdb", format="proteindatabank")

# Fill voids with water
packer = PackWater(filetype="pdb")
packer.append(Fixed("amorphous_void.pdb", 0, 0, 0, number=1))
packer.append(BoxGeometry(0, 0, 0, 358, 143.2, 143.2, density=0.998))
packer(outfile="water.data")
コード例 #9
0
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")
コード例 #10
0
from molecular_builder import create_bulk_crystal, carve_geometry, fetch_prepared_system
from molecular_builder.geometry import SphereGeometry
import numpy as np

atoms = fetch_prepared_system("amorphous_silica_1")

num_spheres = 20

geometries = [
    SphereGeometry(np.asarray([i * 357, j * 143, k * 143]),
                   r * 30,
                   periodic_boundary_condition=(True, True, True))
    for i, j, k, r in np.random.uniform(size=(num_spheres, 4))
]

num_carved = 0
for geometry in geometries:
    tmp_carved = carve_geometry(atoms, geometry, side="in")
    print(f"tmp carved: {tmp_carved}")
    num_carved += tmp_carved

print(f"Carved out {num_carved} atoms")

atoms.write("block_with_holes.data", format="lammps-data")