Example #1
0
def make_cone_path(file1, file2, save, N=20):
    save = Path(save)
    container1 = magnes.io.load(str(file1))
    system = container1.extract_system()
    s0 = container1["PATH"][0]
    size = s0.shape
    path = []
    path_len = N - 1
    for n in range(N):
        state = system.field3D()
        theta = np.pi * (1 + n / path_len) * (
            1 - np.linspace(0, 1, size[2])) - np.pi
        phi_0 = 4 * n * (path_len - n) / (path_len * path_len
                                          )  #(0,1) 1 at n=path_len/2
        phi = np.arcsin(phi_0 * (1 - np.linspace(0, 1, size[2])))
        print(
            f'{theta.min() = },{theta.max() = },{np.sin(phi.min()) = },{np.sin(phi.max()) = }'
        )
        x, y, z = cs.sp2cart(r=1, theta=phi, phi=theta)
        s = np.zeros([1, 1, size[2], 1, 3])
        s[0, 0, :, 0, 0] = x
        s[0, 0, :, 0, 1] = y
        s[0, 0, :, 0, 2] = z
        state.upload(s)
        path.append(state)
    path = magnes.Path(path)
    path = path.interpolate(relative_positions=np.linspace(0, 1, N))
    container = magnes.io.container('.npz')
    container.store_system(system)
    container["PATH"] = path.download()
    container.save(str(save))
# Radius of Hydrogen atom
r_H = 53e-12  # m

# Carbon - Hydrogen Bond Length
BL_CH = 160e-12  # m

r_min, r_max = -BL_CH * 2, BL_CH * 2

# Tetrahedral angle (109.4 deg) - 90 deg
tet_theta = -asin(1 / 3)

# Charge Districution for C atom
C_chargeArray = [4 * e] + [-e] * 4

C_chargePosArray = np.array(
    sp2cart([0] + [r_C] * 4, [0, pi / 2] + [tet_theta] * 3,
            [0, 0, -pi / 3, pi / 3, pi])).transpose()

C_ChargeDist = ChargeDistribution(C_chargeArray, C_chargePosArray)

# Array of positions of H atoms
H_PosArray = np.array(
    sp2cart([BL_CH] * 4, [pi / 2] + [tet_theta] * 3,
            [0, -pi / 3, pi / 3, pi])).transpose()

# Array of positions of electron of H atom
# assuming them to be farther away from the C atom
H_e_PosArray = np.array(
    sp2cart([BL_CH + r_H] * 4, [pi / 2] + [tet_theta] * 3,
            [0, -pi / 3, pi / 3, pi])).transpose()

# H atom Dipoles
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.ticker import FormatStrFormatter
import matplotlib.pyplot as plt

a = 38e-12  # m

n_frames = 50
frequency = 10  # Hz
r_min, r_max = a * 10, a * 15

chargeArray = [4 * e] + [-e] * 4

tet_theta = -asin(1 / 3)

chargePosArray = np.array(
    sp2cart([0] + [a] * 4, [0, pi / 2] + [tet_theta] * 3,
            [0, 0, -pi / 3, pi / 3, pi])).transpose()

myChargeDist = ChargeDistribution(chargeArray, chargePosArray)

n_points = 20

r_array = np.linspace(r_min, r_max, n_points)
theta_array = np.linspace(tet_theta, pi / 2, n_points)
phi_array = np.linspace(-pi / 3, pi / 3, n_frames)

V_Tensor = np.zeros((n_frames, n_points, n_points))

print('Started calculating V_Tensor')

for i in range(n_frames):
Example #4
0
print('Started calculating V_Tensor')

for i in range(n_frames) :

    phi = phi_array[i]

    for j in range(n_points) :

        r = r_array[j]

        for k in range(n_points) :

            theta = theta_array[k]

            pos = np.array(sp2cart(r, theta, phi))

            V_Tensor[i][j][k] = myChargeDist.V(pos)

print('Finished calculating V_Tensor')

X, Y = np.meshgrid(r_array, theta_array * 180 / np.pi, indexing='ij')

fig = plt.figure(figsize=(16,10))
ax = fig.gca(projection='3d')
surf = [ ax.plot_surface(X, Y, V_Tensor[0], cmap='magma', rstride=1, cstride=1) ]

def update(i) :

    Axes3D.set_title(ax, label=(r'$\phi$ = ' + str(round(phi_array[i] * 180 / np.pi)) + r'$^o$'))
Example #5
0
    def set_theta_phi(self, theta, phi) :

        self.p = sp2cart(np.linalg.norm(self.p), theta, phi)
        pass
Example #6
0
from electric_multipoles import ChargeDistribution, e
from mayavi.mlab import contour3d
from ai.cs import sp2cart
from math import asin, pi
import numpy as np

a = 38e-12 # m

r_min, r_max = -2*a, 2*a

chargeArray = [4*e] + [-e]*4

tet_theta = - asin(1/3)

chargePosArray = np.array( sp2cart([0] + [a]*4, [0, pi/2] + [tet_theta] * 3, [0, 0, -pi/3, pi/3, pi]) ).transpose()

myChargeDist = ChargeDistribution(chargeArray, chargePosArray)

n_points = 20

x_array = np.linspace(r_min, r_max, n_points)
y_array = np.linspace(r_min, r_max, n_points)
z_array = np.linspace(r_min, r_max, n_points)

V_Tensor = np.zeros((n_points, n_points, n_points))

print('Started calculating V_Tensor')

for i in range(n_points) :

    x = x_array[i]
from electric_multipoles import ChargeDistribution, e
from ai.cs import sp2cart
from math import asin, pi
import numpy as np

a = 38e-12  # m

r_o = np.array([0, 0, 0]) * 1e-10

chargeArray = [4 * e] + [-e] * 4

tet_theta = -asin(1 / 3)

chargePosArray = np.array(
    sp2cart([0] + [a] * 4, [0, pi / 2] + [tet_theta] * 3,
            [0, 0, -pi / 3, pi / 3, pi])).transpose()

myChargeDist = ChargeDistribution(chargeArray, chargePosArray)

print('\nP_e : ')
print(myChargeDist.P_e(r_o))

print('\nq_e : ')
print(myChargeDist.q_e(r_o))

print('\nQ_e : ')
print(myChargeDist.Q_e(r_o))
Example #8
0
r_H = 53e-12  # m

# Carbon - Hydrogen Bond Length
BL_CH = 160e-12  # m

n_frames = 50
r_min, r_max = BL_CH * 10, BL_CH * 15

# Tetrahedral angle (109.4 deg) - 90 deg
tet_theta = -asin(1 / 3)

# Charge Districution for C atom
C_chargeArray = [4 * e] + [-e] * 4

C_chargePosArray = np.array(
    sp2cart([0] + [r_C] * 4, [0, pi / 2] + [tet_theta] * 3,
            [0, 0, -pi / 3, pi / 3, pi])).transpose()

C_ChargeDist = ChargeDistribution(C_chargeArray, C_chargePosArray)

# Array of positions of H atoms
H_PosArray = np.array(
    sp2cart([BL_CH] * 4, [pi / 2] + [tet_theta] * 3,
            [0, -pi / 3, pi / 3, pi])).transpose()

# Array of positions of electron of H atom
# assuming them to be farther away from the C atom
H_e_PosArray = np.array(
    sp2cart([BL_CH + r_H] * 4, [pi / 2] + [tet_theta] * 3,
            [0, -pi / 3, pi / 3, pi])).transpose()

# H atom Dipoles