예제 #1
0
# Calculate induced electric field
ind.calculate_induced_field(gridrefinement=2,
                            from_density='comp',
                            poissonsolver=poissonsolver,
                            extend_N_cd=3 * np.ones((3, 2), int),
                            deextend=True)

# Save
ind.write('na2_td_field.ind', 'all')
ind.paw = None
td_calc = None
ind = None

# Read data (test also field data I/O)
ind = BaseInducedField(filename='na2_td_field.ind',
                       readmode='field')

# Estimate tolerance (worst case error accumulation)
tol = (iterations * ind.fieldgd.integrate(ind.fieldgd.zeros() + 1.0) *
       max(density_eps, np.sqrt(poisson_eps)))
# tol = 0.038905993684
if do_print_values:
    print('tol = %.12f' % tol)

# Test
val1 = ind.fieldgd.integrate(ind.Ffe_wg[0])
val2 = ind.fieldgd.integrate(np.abs(ind.Fef_wvg[0][0]))
val3 = ind.fieldgd.integrate(np.abs(ind.Fef_wvg[0][1]))
val4 = ind.fieldgd.integrate(np.abs(ind.Fef_wvg[0][2]))
val5 = ind.fieldgd.integrate(ind.Ffe_wg[1])
val6 = ind.fieldgd.integrate(np.abs(ind.Fef_wvg[1][0]))
예제 #2
0
    ax = plt.subplot(1, 1, 1)
    X, Y = np.meshgrid(x, y)
    plt.contourf(X, Y, d_yx, 40)
    plt.colorbar()
    for atom in atoms:
        pos = atom.position
        plt.scatter(pos[2], pos[0], s=50, c='k', marker='o')
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)
    plt.xlim([x[0], x[-1]])
    plt.ylim([y[0], y[-1]])
    ax.set_aspect('equal')


# Read InducedField object
ind = BaseInducedField('na2_td_field.ind', readmode='all')

# Choose array
w = 1  # Frequency index
freq = ind.omega_w[w] * aufrequency_to_eV  # Frequency
box = np.diag(ind.atoms.get_cell())  # Calculation box
d_g = ind.Ffe_wg[w]  # Data array
ng = d_g.shape  # Size of grid
atoms = ind.atoms  # Atoms

do_plot(d_g, ng, box, atoms)
plt.title('Field enhancement @ %.2f eV' % freq)
plt.savefig('na2_td_Ffe.png', bbox_inches='tight')

# Imaginary part of density
d_g = ind.Frho_wg[w].imag
예제 #3
0
    plt.colorbar()
    for atom in atoms:
        pos = atom.position
        plt.scatter(pos[1], pos[0], s=50, c='k', marker='o')
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)
    plt.xlim([x[0], x[-1]])
    plt.ylim([y[0], y[-1]])
    ax.set_aspect('equal')


for fname, name in zip(
    ['cl_field.ind', 'qm_field.ind', 'tot_field.ind'],
    ['Classical subsystem', 'Quantum subsystem', 'Total hybrid system']):
    # Read InducedField object
    ind = BaseInducedField(fname, readmode='all')

    # Choose array
    w = 0  # Frequency index
    freq = ind.omega_w[w] * aufrequency_to_eV  # Frequency
    box = np.diag(ind.atoms.get_cell())  # Calculation box
    d_g = ind.Ffe_wg[w]  # Data array
    ng = d_g.shape  # Size of grid
    atoms = ind.atoms  # Atoms

    do_plot(d_g, ng, box, atoms)
    plt.title('%s\nField enhancement @ %.2f eV' % (name, freq))
    plt.savefig(fname + '_Ffe.png', bbox_inches='tight')

    # Imaginary part of density
    d_g = ind.Frho_wg[w].imag
예제 #4
0
    ax = plt.subplot(1, 1, 1)
    X, Y = np.meshgrid(x, y)
    plt.contourf(X, Y, d_yx, 40)
    plt.colorbar()
    for atom in atoms:
        pos = atom.position
        plt.scatter(pos[2], pos[0], s=50, c='k', marker='o')
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)
    plt.xlim([x[0], x[-1]])
    plt.ylim([y[0], y[-1]])
    ax.set_aspect('equal')


# Read InducedField object
ind = BaseInducedField('na2_casida_field.ind', readmode='all')

# Choose array
w = 1  # Frequency index
freq = ind.omega_w[w] * aufrequency_to_eV  # Frequency
box = np.diag(ind.atoms.get_cell())  # Calculation box
d_g = ind.Ffe_wg[w]  # Data array
ng = d_g.shape  # Size of grid
atoms = ind.atoms  # Atoms

do_plot(d_g, ng, box, atoms)
plt.title('Field enhancement @ %.2f eV' % freq)
plt.savefig('na2_casida_Ffe.png', bbox_inches='tight')

# Imaginary part of density
d_g = ind.Frho_wg[w].imag * 1e-3  # Multiply by kick strength
예제 #5
0
    def equal(x, y, tol):
        new_ref_values.append(x)


ref_values = [
    72404.467117024149, 0.520770766296, 0.520770766299, 0.830247064075,
    72416.234345610734, 0.517294132489, 0.517294132492, 0.824704513888,
    2451.767847927681, 0.088037476748, 0.088037476316, 0.123334033914,
    2454.462292798476, 0.087537484422, 0.087537483971, 0.122592730690,
    76582.089818637178, 0.589941751987, 0.589941751804, 0.869526245360,
    76592.175846021099, 0.586223386358, 0.586223386102, 0.864478308364
]

for fname in ['cl_field.ind', 'qm_field.ind', 'tot_field.ind']:
    ind = BaseInducedField(filename=fname, readmode='field')
    # Estimate tolerance (worst case error accumulation)
    tol = (iterations * ind.fieldgd.integrate(ind.fieldgd.zeros() + 1.0) *
           max(density_eps, np.sqrt(poisson_eps)))
    if do_print_values:
        print('tol = %.12f' % tol)
    for w in range(len(frequencies)):
        val = ind.fieldgd.integrate(ind.Ffe_wg[w])
        equal(val, ref_values.pop(0), tol)
        for v in range(3):
            val = ind.fieldgd.integrate(np.abs(ind.Fef_wvg[w][v]))
            equal(val, ref_values.pop(0), tol)

if do_print_values:
    print('ref_values = [')
    for val in new_ref_values: