All projects

Structural dynamics · Case study · private code

DynSolve

A structural dynamics web app in a single HTML file that runs offline. It writes out every step of the calculation.

file
75 KB, just one
systems
up to 8 masses
runs
offline, in the browser
DynSolve, single-degree-of-freedom oscillator, neutral values

The project

DynSolve solves the single-degree-of-freedom (SDOF) oscillator, multi-mass systems and the response spectrum. For every result it shows the formula, the numbers plugged in and the curve.

I open it in a browser. No install, no network.

The problem

For the structural dynamics exam, all documents were allowed, apps included. I chose to write a tool that really computes rather than yet another form: I enter M and K, or give it a graph, and it returns the frequencies, the modes and the responses, with every formula and its substituted numbers. I validated it exercise by exercise against the course solutions.

I wanted to avoid fixed-value Excel sheets and scattered tools.

What it does

Five tabs, from a single spring to the response spectrum

Each tab opens with when to use it, what to enter and what you get back. The advanced modules sit in collapsed blocks.

  • 01

    Home

    I pick the type of problem and land on the right tab. A reference card covers springs in series and in parallel, and how to set up the mass and stiffness matrices.

  • 02

    Free SDOF

    I enter m, k, c and the initial conditions. The tool returns ω0, frequency, period, ξ, the damping regime, x(t) and v(t) with the envelope, and the value at any time I choose. The schematic animates.

  • 03

    Identification

    From a measurement: the logarithmic decrement, or two peaks read off a graph to recover ξ, ω0 and the initial velocity.

  • 04

    Forced SDOF

    Harmonic force, rotating unbalance or base excitation. Amplification, amplitude, phase, transmissibility, resonance, and four curves, including the total response with its transient.

  • 05

    Inverse problems

    Frequency for a given amplitude, resonance mass, ξ, ω0 and k from a resonance peak, and an isolation system sized for a target transmissibility.

  • 06

    Multi-DOF

    Up to 8 masses linked by springs, to each other or to a fixed support. The tool assembles M and K and returns the natural modes, the frequency response, the free and forced responses and the decoupled equations.

  • 07

    Earthquake

    The SIA 261 elastic response spectrum, applied mode by mode: period, spectral acceleration, displacements and equivalent forces, combined by SRSS.

  • 08

    Help

    One page of formulas for free and forced SDOF, multi-DOF systems and the modal basis.

Multi-DOF tab: table of natural modes, worked calculation, the 2 mode shapes and a frequency response with two peaks
Natural modes and frequency response of a 2-mass system. Neutral values.

How it calculates

Textbook formulas, written out step by step

Free oscillator. The three basic quantities, then the underdamped response. The critical and overdamped cases have their own expressions (cosh and sinh for the latter).

ω0=km,ξ=c2km,ωd=ω01−ξ2x(t)=e−ξω0t[x0cos⁡ωdt+v0+ξω0x0ωdsin⁡ωdt]
Natural frequency, damping ratio, damped frequency and the underdamped free response from x0 and v0.

Logarithmic decrement. Two amplitudes n cycles apart are enough to get back to ξ.

δ=1nln⁡xixi+n,ξ=δ4π2+δ2
Logarithmic decrement over n cycles and the damping ratio it gives.

Forced oscillator. With Ω = ω/ω0, resonance sits at Ω = √(1 − 2ξ²). The total response adds the steady state and the transient, which is why beats show up when there is no damping.

Ad=1(1−Ω2)2+(2ξΩ)2,X0=F0kAdtan⁡φ=2ξΩ1−Ω2,TR=Ad1+(2ξΩ)2
Dynamic amplification factor, amplitude, phase and transmissibility. For a rotating unbalance, F0 = me·e·ω².

Multi-DOF systems. The modes come from the generalized eigenvalue problem. I factor M by Cholesky to reduce it to a standard symmetric problem, then solve that with Jacobi rotations. Mode shapes are normalized on the first mass.

For 2 DOF the tool also shows the hand solution, a quadratic in ω².

det⁡(K−ω2M)=0,(K−ωi2M)φi=0mi*=φiTMφi,Γi=φiTM1mi*
Natural frequencies and mode shapes, modal mass and participation factor (1 is the vector whose components are all 1).

Modal basis. With x(t) = Σ φi qi(t), each mode becomes an independent SDOF oscillator. The frequency response is the superposition of these modes, with modal damping.

q¨i+2ξωiq˙i+ωi2qi=pi,pi=φiTFmi*
Decoupled equation of mode i, with the load on one mass, on all of them or on none.

Response spectrum. The elastic spectrum Se(T) rises up to TB, stays on a plateau at 2.5·η·S·agd up to TC, decays as 1/T up to TD, then as 1/T² beyond. The code parameters can be edited.

η=max⁡(105+ξ,0.55)Sd,i=Se(Ti)ωi2,qi,max=ΓiSd,iui=φiqi,max,fi=MφiΓiSe(Ti)u=∑iui2
Damping correction (ξ in %), then for each mode: spectral displacement, modal displacement, displacements and equivalent forces. Displacements and forces are combined by SRSS. A variant starts from a given mode shape and frequency.

Inverse problems. Getting ξ from a resonance peak means solving a nonlinear equation, so I use bisection. Sizing an isolation system comes down to a quadratic in Ω², then k = m·ω0².

Validation

Two examples from the course

For multi-DOF systems, the tool gives eigenvalues as s, with ω² = s·k/m. If m and k are 1, s is simply ω². Here are two systems whose values the tool reproduces. Examples taken from the structural dynamics course (HES-SO).

01

3-storey building

Masses m, m and 0.8 m, linked by identical springs of stiffness k, the first one to the support. Eigenvalues s = 0.222, 1.686, 3.342. First mode (1, 1.78, 2.16), normalized on the first mass.

02

2-mass frame

Masses 3m/4 and m/4. Eigenvalues s = 0.2324 and 1.4343.

M=m(100010000.8),K=k(2−10−12−10−11)
Matrices of the 3-storey building.

What was interesting

Every number on screen has its line of working

Every result is written with its numbers substituted in. Most of the display code exists for that: one line per step, the final value in bold.

Each edge case has its own branch: critical or overdamped systems, a mass matrix that is not positive definite, an isolation target that cannot be reached, a peak too weak for an underdamped solution. In each case the tool shows a message saying why it can't give an answer.

The amplification and transmissibility curves are capped at 12. Otherwise the resonance peak flattens the rest of the plot.

The rest is comfort: light and dark themes, printing, copying results, PNG export of the mode shapes, state kept in the browser.

0

Libraries

For multi-DOF systems the Cholesky plus Jacobi solver is written by hand, with no linear algebra library. Schematics and curves are drawn on a native canvas.

75 KB

One file

HTML, CSS and JavaScript fit in one file that opens offline in any browser. The SDOF tabs recalculate on every keystroke.

Sharing

A private tool, shown in screenshots

The tool stays a personal one: it isn't put online. I only publish these screenshots, taken with neutral values.

Tech stack

  • HTML
  • CSS
  • JavaScript, no libraries
  • Canvas 2D
  • hand-written Cholesky and Jacobi
  • no network
  • localStorage to keep state

See the other projects

Contact

Let's talk?