# forces U_r = lambda r, dr: 0.5 * kappa_r * r**2 T_r = lambda r, dr: 0.5 * m_r * dr**2 U_q = lambda q, dq: 0.5 * kappa_q * q**2 T_q = lambda q, dq: 0.5 * m_q * dq**2 # constraint factor = 1. # g = lambda r, q : factor*q/(1+r**2) - q**3 g = lambda r, q: -factor * sp.sin(0.1 * q) / (1 + r**2) + 0.1 * q # g = lambda r, q : q**2 - 1/(1+(r-0.5)**2) # start within the circle! # g = lambda r, q : q - r # g = lambda r, q : q**2 + r**2 # looks nice and smooth! # g = lambda r, q : # initial distribution r0 = 1. dr0 = 0. Q0 = np.random.normal(loc=2.5, scale=0.3, size=(n, )) t_end = 24 #60 dpms.init_equations(T_r, U_r, T_q, U_q, g) dpms.init_state(r0, dr0, Q0, t_end, n_eval=400) dpms.simulate() dpms.name = "onion" save_plots(plt, dpms, "disc")
# g = lambda r, q : # initial distribution r0 = 1. dr0 = 0 # Q0 = np.random.normal(loc=0.9, scale=1., size=(n,)) # generate grid loc = 2. scale = 1 qgrid_size = 100 qgrid = np.linspace(-5, 7, qgrid_size) rho0 = n * norm.pdf(qgrid, loc=loc, scale=scale) t_end = 60 pms.init_equations(T_r, U_r, T_q, U_q, g) pms.init_meso(r0, dr0, rho0, qgrid, t_end, n_eval=400) pms.simulate_meso(method="Radau", atol=1.e-8, rtol=1.e-8, use_upwind=True) pms.name = "linear" save_plots(plt, pms, "meso", imgtype=".png") save_plots(plt, pms, "meso", imgtype=".eps") # # # # # # # #
m_r = 20. m_q = 10. / n # stiffness kappa_r = 1. kappa_q = 1. / n # forces U_r = lambda r, dr: 0.5 * kappa_r * r**2 T_r = lambda r, dr: 0.5 * m_r * dr**2 U_q = lambda q, dq: 0.5 * kappa_q * q**2 T_q = lambda q, dq: 0.5 * m_q * dq**2 # constraint g = lambda r, q: q + r # initial distribution r0 = 1. dr0 = 0.0 Q0 = np.random.normal(loc=2., scale=1., size=(n, )) t_end = 60 dpms.init_equations(T_r, U_r, T_q, U_q, g) dpms.init_state(r0, dr0, Q0, t_end, n_eval=1000) dpms.simulate() dpms.name = "linear" save_plots(plt, dpms, "disc", imgtype=".png") save_plots(plt, dpms, "disc", imgtype=".eps")
# stiffness kappa_r = 1. kappa_q = 0.0 / n # forces U_r = lambda r, dr: 0.5 * kappa_r * r**2 T_r = lambda r, dr: 0.5 * m_r * dr**2 U_q = lambda q, dq: 0.5 * kappa_q * q**2 T_q = lambda q, dq: 0.5 * m_q * dq**2 # constraint factor = 1. # g = lambda r, q : factor*q/(1+r**2) - q**3 # g = lambda r, q : q**2 - 1/(1+(r-0.5)**2) # start within the circle! # g = lambda r, q : q - r g = lambda r, q: q**2 + (r - 2)**2 # looks nice and smooth! # g = lambda r, q : # initial distribution r0 = 3. dr0 = 0. Q0 = np.random.normal(loc=2, scale=0.2, size=(n, )) t_end = 20 dpms.init_equations(T_r, U_r, T_q, U_q, g) dpms.init_state(r0, dr0, Q0, t_end, n_eval=1000) dpms.simulate(method='BDF') save_plots(plt, dpms, "singular", "disc")
# forces U_r = lambda r, dr: 0.5 * kappa_r * r**2 T_r = lambda r, dr: 0.5 * m_r * dr**2 U_q = lambda q, dq: 0.5 * kappa_q * q**2 T_q = lambda q, dq: 0.5 * m_q * dq**2 # constraint factor = 1. # g = lambda r, q : factor*q/(1+r**2) - q**3 # g = lambda r, q : q**2 - 1/(1+(r-0.5)**2) # start within the circle! # g = lambda r, q : q - r g = lambda r, q: q**2 + (r - 2)**2 # looks nice and smooth! # g = lambda r, q : # initial distribution r0 = 3. dr0 = 0. Q0 = np.random.normal(loc=2., scale=0.2, size=(n, )) t_end = 8 dpms.init_equations(T_r, U_r, T_q, U_q, g) dpms.init_state(r0, dr0, Q0, t_end, n_eval=8000) G_noise = 0.2 * np.concatenate([np.array([0., 0.]), np.ones((n, ))]) dpms.simulate(G=lambda y, t: np.diag(G_noise)) save_plots(plt, dpms, "singular_stoch_new", "disc")
U_q = lambda q, dq: 0.5 * kappa_q * q**2 T_q = lambda q, dq: 0.5 * m_q * dq**2 # constraint factor = 1. # g = lambda r, q : factor*q/(1+r**2) - q**3 # g = lambda r, q : q**2 - 1/(1+(r-0.5)**2) # start within the circle! # g = lambda r, q : q - r g = lambda r, q: q**2 + (r - 2)**2 # looks nice and smooth! # g = lambda r, q : # initial distribution r0 = 3. dr0 = 0. #Q0 = np.random.normal(loc=2, scale=0.75, size=(n,)) t_end = 20 # generate grid loc = 2 scale = 0.2 qgrid_size = 600 qgrid = np.linspace(-1, 4, qgrid_size) rho0 = n * norm.pdf(qgrid, loc=loc, scale=scale) pms.init_equations(T_r, U_r, T_q, U_q, g) pms.init_meso(r0, dr0, rho0, qgrid, t_end, n_eval=1000) pms.simulate_meso(method='Radau', atol=1.e-5, rtol=1.e-5) pms.name = "singular" save_plots(plt, pms, pms.name, "meso")
kappa_q = 0.0 / n # forces U_r = lambda r, dr: 0.5 * kappa_r * r**2 T_r = lambda r, dr: 0.5 * m_r * dr**2 U_q = lambda q, dq: 0.5 * kappa_q * q**2 T_q = lambda q, dq: 0.5 * m_q * dq**2 # constraint factor = 1. # g = lambda r, q : factor*q/(1+r**2) - q**3 g = lambda r, q: -factor * sp.sin(0.1 * q) / (1 + r**2) + 0.1 * q # g = lambda r, q : q**2 - 1/(1+(r-0.5)**2) # start within the circle! # g = lambda r, q : q - r # g = lambda r, q : q**2 + r**2 # looks nice and smooth! # g = lambda r, q : # initial distribution r0 = 1. dr0 = 0. Q0 = np.random.normal(loc=0.9, scale=1., size=(n, )) t_end = 60 dpms.init_equations(T_r, U_r, T_q, U_q, g) dpms.init_state(r0, dr0, Q0, t_end, n_eval=1000) dpms.simulate() u save_plots(plt, dpms, "onion", "disc")