Claude-skill-registry calc_bode
python-controlを使用して、メカニカルシステムの状態空間モデルから伝達関数(Bode Plot)を計算・表示する
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/calc-bode" ~/.claude/skills/majiayu000-claude-skill-registry-calc-bode && rm -rf "$T"
manifest:
skills/data/calc-bode/SKILL.mdsource content
calc_bode
calc_bodeThis skill builds a state-space model from a mechanical system defined by mass (M), stiffness (K), and damping (C) matrices, and generates a frequency response (Bode Plot) using the
python-control library.
Workflow
-
System Matrix Acquisition:
- Extract the $M$ and $K$ matrices from a physical model or linearization tool.
- Define the damping matrix $C$ as needed (typically proportional to stiffness or using modal damping).
-
State-Space Construction:
- Define the state vector as $x = [q, v]^T$, where $q$ is displacement and $v$ is velocity.
- Transform the system's equation of motion $M \ddot{q} + C \dot{q} + K q = F u$ into the standard state-space form $\dot{x} = Ax + Bu$:
- $A = \begin{bmatrix} 0 & I \ -M^{-1}K & -M^{-1}C \end{bmatrix}$
- $B = \begin{bmatrix} 0 \ M^{-1}F \end{bmatrix}$
-
Application of
:python-control- Import the library:
.import control as ct - Create the system object:
.sys = ct.ss(A, B, C, D)
- Import the library:
-
IO Selection (for MIMO systems):
- Use
to select the desired input/output channel.sys_siso = sys[output_idx, input_idx]
- Use
-
Plotting and Analysis:
- Generate the Bode plot:
.ct.bode_plot(sys_siso, ...) - Utilize flags such as
,Hz=True
, anddB=True
.deg=True - Check stability if necessary via
.sys.poles()
- Generate the Bode plot:
Precautions
- In systems including inverted pendulums, such as the KAGRA top stage, open-loop poles may exist in the unstable region before applying stabilization control.
- Ensure frequency ranges are specified in angular frequency (rad/s) such as
, while specifyingnp.logspace(np.log10(start_hz * 2*np.pi), np.log10(end_hz * 2*np.pi), n_points)
inHz=True
.bode_plot