topoptlab.timestepper module
- topoptlab.timestepper.backward_diff(M: csc_array, K: csc_array, f: ndarray, phi: ndarray, h: float, order: int, **kwargs: Any) Tuple[csc_array, ndarray][source]
Return left hand side (matrix) and right hand side for one timestep evolution of the backward difference. We assume the generic PDE of first order in time
d phi / dt + D phi = f
where phi is the evolution variable (what we want to solve for), D a differential operator purely in space (not time) and f a generic function of space and time. After discretization in space, we convert phi to its discretized equivalent Phi and the equation becomes
M d phi / dt + K Phi = f
with the discretization of the identity operator M (often called mass matrix) and matrix of the discretization of the operator D which we call K.
- Parameters:
M (csc_array) – mass matrix.
K (csc_array) – discretization of operator D (e. g. stiffness matrix).
f (np.ndarray) – generic right hand side function.
phi (np.ndarray) – variable to solve for.
h (int) – time step width.
order (int) – order of BD. must be equal or smaller 6.
- Returns:
lhs (csc_array) – First one is multiplied with the forces and the stiffness matrix, the others on the right hand side with the mass matrix and the history of the function.
rhs (np.ndarray) – vector of the right hand side
- topoptlab.timestepper.bdf_coefficients(k: int, **kwargs: Any) ndarray[source]
Get coefficients for backward differentiation formula BDF. Shamelessly copied from Elmer Solver manual. Also check the formula there to understand what the coefficients mean.
- Parameters:
k (int) – order of BD. must be equal or smaller 6.
- Returns:
coefficients – First one is multiplied with the forces and the stiffness matrix, the others on the right hand side with the mass matrix and the history of the function.
- Return type:
np.ndarray shape (k+1)
- topoptlab.timestepper.bossak(M: csc_array, B: csc_array, K: csc_array, f: ndarray, phi: ndarray, h: float, beta: float, gamma: float, alpha: float = -0.05, a: None | ndarray = None, v: None | ndarray = None, **kwargs: Any) Tuple[csc_array, ndarray][source]
Return left hand side (matrix) and right hand side for one timestep evolution of the Bossak methd. We assume the generic PDE of second order in time
d**2 phi / dt**2 + b * d phi / dt + D phi = f
where phi is the evolution variable (what we want to solve for), b some parameter D a differential operator purely in space (not time) and f a generic function of space and time. After discretization in space, we convert phi to its discretized equivalent Phi and the equation becomes
M d**2 Phi / dt**2 + B d Phi / dt + K Phi = f
with the discretization of the identity operator M (often called mass matrix), the damping matrix B and matrix of the discretization of the operator D which we call K.
- Parameters:
M (csc_array) – mass matrx.
B (csc_array) – damping matrix.
K (csc_array) – discretization of operator D (e. g. stiffness matrix).
f (np.ndarray) – generic right hand side function.
phi (np.ndarray) – variable to solve for.
beta (float) – mixing parameter that determines how much of the new acceleration enters the displacement update. Typically calculated with function bossak_init and should only be set manually by people witha good understanding of the Bossak-method and time integrators.
gamma (float) – mixing parameter for velocity update that determines how much of the new acceleration enters the velocity update. Typically calculated with function bossak_init and should only be set manually by people witha good understanding of the Bossak-method and time integrators.
alpha (float) – Bossak parameter typically between -0.3 and 0. 0 recovers the Newmark beta method.
h (int) – time step width.
a (np.ndarray) – approximate second order derivative in time of phi (acceleration).
v (np.ndarray) – approximate first order derivative in time of phi (velocity).
- Returns:
lhs (csc_array) – First one is multiplied with the forces and the stiffness matrix, the others on the right hand side with the mass matrix and the history of the function.
rhs (np.ndarray) – vector of the right hand side
- topoptlab.timestepper.bossak_init(alpha: float = -0.05, **kwargs: Any) Tuple[float, float][source]
Calculate parameters beta and gamma for the Bossak method:
beta = 1/4 * (1-alpha)**2 gamma = 1/2 - alpha
- Parameters:
alpha (float) – Bossak parameter typically between -0.3 and 0. The more negative, the more damping is done. 0 recovers the Newmark beta method with middle point rule if equal to zero (unconditionally stable in lin. problems).
- Returns:
beta (float) – mixing parameter that determines how much of the new acceleration enters the displacement update.
gamma (float) – mixing parameter for velocity update that determines how much of the new acceleration enters the velocity update.
- topoptlab.timestepper.bossak_update_derivatives(phi: ndarray, phi_old: ndarray, v: ndarray, a: ndarray, alpha: float, beta: float, gamma: float, h: float, **kwargs: Any) Tuple[ndarray, ndarray][source]
Update first and second order derivative (in time) of phi after the phi of the new timestep has been found:
a_new = (beta*h)**(-1) *( * (phi - phi_old)/h - v + (1 - 1/(2*beta)*a) ) v_new = v + h * ( (1-gamma)*a + gamma * a_new )
- Parameters:
phi (np.ndarray) – variable to evolve in time with the Bossak scheme.
phi_old (np.ndarray) – phi of previous timestep.
v (np.ndarray) – approximate first order derivative in time of phi (velocity).
a (np.ndarray) – approximate second order derivative in time of phi (acceleration).
beta (float) – mixing parameter that determines how much of the new acceleration enters the displacement update. Typically calculated with function bossak_init and should only be set manually by people witha good understanding of the Bossak-method and time integrators.
gamma (float) – mixing parameter for velocity update that determines how much of the new acceleration enters the velocity update. Typically calculated with function bossak_init and should only be set manually by people witha good understanding of the Bossak-method and time integrators.
alpha (float) – Bossak parameter typically between -0.3 and 0. 0 recovers the Newmark beta method.
h (int) – time step width.
- Returns:
lhs (csc_array) – First one is multiplied with the forces and the stiffness matrix, the others on the right hand side with the mass matrix and the history of the function.
rhs (np.ndarray) – vector of the right hand side