<jupyter_start><jupyter_text>Trapezoidal Method<jupyter_code>A_in = lambda t: 0
sys = SingleModeSystem(params={"omega_a": 2*np.pi*1, "kappa_a": 2*np.pi*0.001, "kerr_a":2*np.pi*.4}, A_in = A_in)
x_0 = np.array([1,0])
ts = np.linspace(0, 1, 101)
X = sys.trapezoidal(x_0, ts)
fig, ax = plot_full_evolution(X, ts, labels=["$q_a$","$p_a$"])
ax.legend()
A_in = lambda t: 0
sys = SingleModeSystem(params={"omega_a": 2*np.pi*1, "kappa_a": 2*np.pi*0.001, "kerr_a":2*np.pi*.4}, A_in = A_in)
x_0 = np.array([1,0])
ts = np.linspace(0, 1, 101)
X = sys.trapezoidal(x_0, ts, use_gcr=True)
fig, ax = plot_full_evolution(X, ts, labels=["$q_a$","$p_a$"])
ax.legend()<jupyter_output><empty_output><jupyter_text>Forward Euler<jupyter_code>A_in = lambda t: 0
sys = SingleModeSystem(params={"omega_a": 2*np.pi*1, "kappa_a": 2*np.pi*0.001, "kerr_a":2*np.pi*.4}, A_in = A_in)
x_0 = np.array([1,0])
ts = np.linspace(0, 1, 10001)
X = sys.forward_euler(x_0, ts)
fig, ax = plot_full_evolution(X, ts, labels=["$q_a$","$p_a$"])
ax.legend()
u = sys.eval_u(0)
np.allclose(sys.eval_Jf(x_0, u) , sys.eval_Jf_numerical(x_0, u), atol=1e-5)
omega_a = 2*np.pi*1
A_in = lambda t: np.exp(1.0j*(omega_a*t))
sys = SingleModeSystem(params={"omega_a": omega_a, "kappa_a": 2*np.pi*0.001}, A_in = A_in)
x_0 = np.array([0,0])
ts = np.linspace(0, 10, 100001)
X = sys.forward_euler(x_0, ts)
X[1,:] = 10*X[1,:] 
fig, ax = plot_full_evolution(X, ts, labels=["$q_a$","$p_a$"])
ax.legend()
# detuned drive ramp up
omega_a = 2*np.pi*1
delta = 2*np.pi*0.2
A_in = lambda t: np.exp(1j * (omega_a + delta) * t)
sys = SingleModeSystem(params={"omega_a": omega_a, "kappa_a": 2*np.pi*0.001}, A_in = A_in)
x_0 = np.array([0,0])
ts = np.linspace(0, 20, 100001)
X = sys.forward_euler(x_0, ts)
X[1,:] = X[1,:] 
fig, ax = plot_full_evolution(X, ts, labels=["$q_a$","$p_a$"])
ax.legend()
# ramp up on resonance
omega_a = 2*np.pi*1
delta = 2*np.pi*0.0
A_in = lambda t: np.exp(1j*(omega_a +delta)*t) #default A_in is used
sys = SingleModeSystem(params={"omega_a": omega_a, "kappa_a": 2*np.pi*0.1}, A_in = A_in)
x_0 = np.array([0,0])
ts = np.linspace(0, 20, 100001)
X = sys.forward_euler(x_0, ts)
X[1,:] = X[1,:] 
fig, ax = plot_full_evolution(X, ts, labels=["$q_a$","$p_a$"])
ax.legend()
# RWA
omega_a = 2*np.pi*1
delta = 2*np.pi*10
A_in = lambda t: np.cos((omega_a +delta)*t) #default A_in is used
sys = SingleModeSystem(params={"omega_a": omega_a, "kappa_a": 0.001}, A_in = A_in)
x_0 = np.array([1,0])
ts = np.linspace(0, 2, 100001)
X = sys.forward_euler(x_0, ts)
X[1,:] = X[1,:] 
fig, ax = plot_full_evolution(X, ts, labels=["$q_a$","$p_a$"])
ax.legend()<jupyter_output><empty_output><jupyter_text>Linearization<jupyter_code>A_in = lambda t: 0
sys = SingleModeSystem(params={"omega_a": 2*np.pi*1, "kappa_a": 2*np.pi*0.001, "kerr_a": 2*np.pi*0.01}, A_in = A_in)
x_0 = np.array([1,0])
ts = np.linspace(0, 1, 10001)
X = sys.forward_euler(x_0, ts)
fig, ax = plot_full_evolution(X, ts, labels=["$q_a$","$p_a$"])
ax.legend()

X_linear = sys.forward_euler_linear(x_0, ts, x_0, 0)
fig, ax = plot_full_evolution(X_linear, ts, labels=["$q_{a,linear}$","$p_{a,linear}$"])

Delta_X = (X-X_linear)/X
plot_full_evolution(Delta_X[:,:100], ts[:100], labels=["$q_a - q_{a,linear}$","$p_a - p_{a,linear}$"])
ax.legend()<jupyter_output>/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ipykernel_launcher.py:12: RuntimeWarning: invalid value encountered in true_divide
  if sys.path[0] == '':
{'fraction_non_alphanumeric': 0.22270742358078602, 'fraction_numerical': 0.05880640465793304, 'mean_word_length': 6.158333333333333, 'pattern_counts': {'":': 20, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '104326', 'license': 'MIT', 'n_tokens_mistral': 1794, 'n_tokens_neox': 1670, 'n_words': 291, 'path': 'demos/basic/SingleModeSystem.ipynb', 'repo_name': 'Phionx/quantumnetworks', 'size': '3435'}