コード例 #1
0
ファイル: quick_sim.py プロジェクト: jc-roth/rcfdtdpy
# ================
# SETUP SIMULATION
# ================
# Constants
c0 = 1  # um/ps
di = 0.3  # 0.3 um
dn = di / c0  # (0.3 um) / (300 um/ps) = 0.001 ps = 1 fs
epsilon0 = 1
mu0 = 1
# Define bounds
i0 = -100  # -100 um
i1 = 1100  # 1100 um
n0 = -300  # (1 fs) * (-300 um) / (0.3 um/step) = (1 fs) * (-1,000 steps) = -1,000 fs = -1 ps
n1 = 5100  # (1 fs) * (5100 um) / (0.3 um/step) = (1 fs) * (17,000 steps) = 17,000 fs = 17 ps
# Calculate dimensions
nlen, ilen = Sim.calc_dims(n0, n1, dn, i0, i1, di)
print('nlen=%i, ilen=%i' % (nlen, ilen))
# Create a arrays that hold the value of the center of each cell
t = np.linspace(n0 + dn / 2, n1 + dn / 2, nlen, endpoint=False) * (
    10 / 3)  # Multiply by 10/3 to get from um -> fs
z = np.linspace(i0 + di / 2, i1 + di / 2, ilen, endpoint=False)

# =============
# SETUP CURRENT
# =============
# Set current location
cp_loc_val = -50  # -250 um
cp_time_val = 0  # 0 fs
# Find current indicies
cp_loc_ind = np.argmin(np.abs(np.subtract(z, cp_loc_val)))
cp_time_ind = np.argmin(np.abs(np.subtract(t, cp_time_val)))
コード例 #2
0
from matplotlib.ticker import MaxNLocator
import matplotlib.gridspec as gridspec

# Constants
c0 = 3e8  # um/ps
di = 0.03e-6  # 0.03 um
dn = di / c0  # (0.03 um) / (3e8 m/s) = 0.1 fs
epsilon0 = 8.854187e-12
mu0 = np.divide(1, np.multiply(epsilon0, np.square(c0)))
# Define bounds
i0 = -1e-6  # -1 um
i1 = 2e-6  # 2 um
n0 = -0.5e-12  # -0.5 ps
n1 = 2.5e-12  # 2.5 ps
# Calculate dimensions
nlen, ilen = Sim.calc_dims(n0, n1, dn, i0, i1, di)
# Create a arrays that hold the value of the center of each cell
t = np.linspace(n0 + dn / 2, n1 + dn / 2, nlen, endpoint=False)
z = np.linspace(i0 + di / 2, i1 + di / 2, ilen, endpoint=False)
# Print simulation bounds
print('nlen=%i, ilen=%i' % (nlen, ilen))

cp_loc_val = -0.5e-6  # -0.5 um
cp_time_val = 0  # 0 fs

# Find indicies
cp_loc_ind = np.argmin(np.abs(np.subtract(z, cp_loc_val)))
cp_time_ind = np.argmin(np.abs(np.subtract(t, cp_time_val)))
# Find start and end indicies in time
spread = 3500
cp_time_s = cp_time_ind - spread
コード例 #3
0
from matplotlib.colors import BoundaryNorm
from matplotlib.ticker import MaxNLocator
import matplotlib.gridspec as gridspec
# Constants
c0 = 3e8 # um/ps
di = 0.03e-6 # 0.03 um
dn = di/c0 # (0.03 um) / (3e8 m/s) = 0.1 fs
epsilon0 = 8.854187e-12
mu0 = np.divide(1, np.multiply(epsilon0, np.square(c0)))
# Define bounds
i0 = -1e-6 # -1 um
i1 = 2e-6 # 2 um
n0 = -0.5e-12 # -0.5 ps
n1 = 2.5e-12 # 2.5 ps
# Calculate dimensions
nlen, ilen = Sim.calc_dims(n0, n1, dn, i0, i1, di)
# Create a arrays that hold the value of the center of each cell
t = np.linspace(n0+dn/2, n1+dn/2, nlen, endpoint=False)
z = np.linspace(i0+di/2, i1+di/2, ilen, endpoint=False)
# Print simulation bounds
print('nlen=%i, ilen=%i' % (nlen, ilen))


# Specify the location of our current pulse in time and space

# In[2]:


cp_loc_val = -0.5e-6 # -0.5 um
cp_time_val = 0 # 0 fs
コード例 #4
0
# ## Running the Simulation
#
# Create and run our simulation (or load simulation if one already exists)

# In[10]:

# Create Sim object
tqdmarg = {'desc': 'Executing simulation', 'leave': True}
s = Sim(i0,
        i1,
        di,
        n0,
        n1,
        dn,
        epsilon0,
        mu0,
        'absorbing',
        current,
        material,
        nstore=np.arange(0, nlen, 50),
        istore=[5, ilen - 6])
# Run simulation if simulation save doesn't exist
sim_file = Path(fsave)
if sim_file.is_file():
    # Load results
    dat = np.load(fsave)
    t = dat['t']
    els = dat['els']
    erls = dat['erls']
    hls = dat['hls']
コード例 #5
0
                      ilen,
                      nlen,
                      material_ind_start,
                      material_ind_end,
                      chi,
                      inf_perm,
                      tqdmarg={'desc': 'Calculating chi^m'})
 # Create Sim object
 tqdmarg = {'desc': 'Executing simulation'}
 s = Sim(i0,
         i1,
         di,
         n0,
         n1,
         dn,
         epsilon0,
         mu0,
         'absorbing',
         thzpulse,
         drude_material,
         nstore=np.arange(0, nlen, 50),
         istore=[5, ilen - 6])
 # Run simulation
 s.simulate(tqdmarg)
 # Export visualization
 vis.timeseries(s, z, iunit='um')
 # Export and save arrays
 hls, els, hrls, erls = s.export_ifields()
 chi = drude_material.export_chi()
 np.savez('drude_model_numeric.npz',
          t=t,
コード例 #6
0
# Run pre-simulation analysis
# ---------------------------
# Run simulation if simulation save doesn't exist
sim_file = 'dynamic_material_pre_analysis.npz'
if Path(sim_file).is_file():
    # Load results
    dat = np.load(sim_file)
    els = dat['els']
else:
    # Create Sim object, observe the field at the material start index
    s = Sim(i0,
            i1,
            di,
            n0,
            n1,
            dn,
            epsilon0,
            mu0,
            'absorbing',
            thzpulse,
            istore=[m_z_start_ind])
    # Run simulation
    s.simulate(tqdmarg={
        'desc': 'Executing pre-simulation analysis',
        'leave': True
    })
    hls, els, hrls, erls = s.export_ifields()
    np.savez(sim_file, els=els)

# Determine the temporal index at which the thz pulse is incident on the material
thz_incident_n_ind = np.argmax(np.real(els))