pyserep.models
pyserep.models — built-in synthetic FE model generators for testing.
- pyserep.models.euler_beam(n_elements: int = 50, length: float = 1.0, EI: float = 10000.0, rho_A: float = 1.0, fixed_left: bool = True, fixed_right: bool = False) Tuple[csc_matrix, csc_matrix][source]
1D Euler-Bernoulli beam (consistent mass matrix).
DOFs per node: transverse displacement w and rotation θ. Total DOFs: 2 × (n_elements + 1). Fixed BCs applied by row/column zeroing with large diagonal penalty.
- Parameters:
- Returns:
K, M
- Return type:
scipy.sparse.csc_matrix, shape (2*(n_elements+1), …)
- pyserep.models.model_info(K: spmatrix, M: spmatrix, label: str = '') str[source]
Return a one-line description of a (K, M) pair.
- pyserep.models.plate_2d(nx: int = 10, ny: int = 10, lx: float = 1.0, ly: float = 1.0, D: float = 1000.0, rho_h: float = 1.0) Tuple[csc_matrix, csc_matrix][source]
2D rectangular Kirchhoff plate using finite differences.
Simply supported on all four edges. DOFs: transverse displacement w at interior grid points only. Total DOFs: (nx-1) × (ny-1).
- Parameters:
nx (int) – Number of intervals in x and y (interior nodes = nx-1, ny-1).
ny (int) – Number of intervals in x and y (interior nodes = nx-1, ny-1).
lx (float) – Plate dimensions (m).
ly (float) – Plate dimensions (m).
D (float) – Flexural rigidity D = E h³ / (12(1-ν²)) (N·m).
rho_h (float) – Mass per unit area ρ·h (kg/m²).
- Returns:
K, M
- Return type:
Notes
Uses the 13-point biharmonic finite difference stencil for ∇⁴w.
- pyserep.models.random_symmetric_pd(n: int = 50, kappa_K: float = 10000.0, seed: int = 42) Tuple[csc_matrix, csc_matrix][source]
Random symmetric positive-definite (K, M) pair.
Useful for unit testing and algorithm benchmarks where the structural interpretation is irrelevant.
- Parameters:
- Returns:
K, M
- Return type:
scipy.sparse.csc_matrix (dense matrices wrapped in sparse)
- pyserep.models.spring_chain(n: int = 300, k: float = 100000.0, m: float = 1.0, fixed_left: bool = True, fixed_right: bool = False) Tuple[csc_matrix, csc_matrix][source]
1D spring-mass chain.
- Physical model: o–k–o–k–o … –k–o
m m m m
- Parameters:
- Returns:
K, M
- Return type:
Examples
>>> K, M = spring_chain(n=500, k=2e5) >>> K.shape (500, 500)