feat(ClassicalMechanics): add Caldirola-Kanai lagrangian for the damped harmonic oscillator#1354
Conversation
…scillator Adds section F to DampedHarmonicOscillator/Basic.lean: - lagrangian: the Caldirola-Kanai lagrangian exp(γ/m t) * (T - V), with lagrangian_eq, lagrangian_eq_exp_mul_kineticEnergy_sub_potentialEnergy, lagrangian_of_isUndamped, contDiff_lagrangian - gradient_lagrangian_position_eq / gradient_lagrangian_velocity_eq via the helper gradient_const_mul - gradLagrangian: the variational gradient of the action, simplified by gradLagrangian_eq_force to exp(γ/m t) • (F - m a) - equationOfMotion_iff_gradLagrangian_zero: the equation of motion holds iff the variational gradient vanishes Adds Time.val_contDiff (@[fun_prop]) to SpaceAndTime/Time/Derivatives.lean, completing the measurable/differentiable/contDiff API for Time.val. Marks the lagrangian, variational-gradient, and (inherited) kinetic/potential energy requirements done in API-map.yaml. Toward leanprover-community#905. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- fix transposed L(t, x, v) arguments in the F.2 variational-gradient formula - mark gradient_const_mul private (mirrors HarmonicOscillator's private helper) - pack gradLagrangian_eq_force signature onto one line (HO precedent) - sync API-map.yaml Overview and References with the new section F - retitle Time/Derivatives section D to cover Time.val_contDiff Toward leanprover-community#905. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Thank you for this PR, which will now be reviewed. If submitting to ./Physlib or ./QuantumInfo, please see our review guidelines if you are not familiar with the process. You should expect a back and forth with a reviewer before your PR is merged. See also that link for how to add appropriate labels to your PR. The PR will also go through a number of automated checks. You can learn more about these here, including how to run them locally. If you are submitting to ./PhyslibAlpha there will be a lighter review process, though your PR must still pass the automated checks. If you want to bring attention to this PR, please write a message on this thread of the Lean Zulip. Important: If a reviewer adds an |
jstoobysmith
left a comment
There was a problem hiding this comment.
Great! This is really nice! Just a couple of convention comments.
| done: true | ||
| location: > | ||
| Inherited from Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean (kineticEnergy), | ||
| since DampedHarmonicOscillator extends HarmonicOscillator. |
There was a problem hiding this comment.
I would keep this as:
Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean (kineticEnergy)
just because I think we will likely use a script at some point to make sure these definitions go to a place which actually exists. (likewise with below).
There was a problem hiding this comment.
Done - both inherited-energy location fields now use the plain file (name) format; the inheritance rationale stays in the Overview.
… their defining file Review: keep 'location' machine-parseable as 'file (name)'; the inheritance rationale is already stated in the Overview. Toward leanprover-community#905. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
-awaiting-author |
jstoobysmith
left a comment
There was a problem hiding this comment.
Approved - will merge shortly. Many thanks.
Summary
Adds the Caldirola–Kanai lagrangian for the damped harmonic oscillator and the simplification of its variational gradient to the Euler-Lagrange equations, completing two open requirements of #905. Since the damped oscillator is non-conservative, the plain
T − Vlagrangian does not reproduce the damped equation of motion; the Caldirola–Kanai lagrangianexp (γ/m * t) * (T − V)does: its Euler-Lagrange equation is exactlym ẍ + γ ẋ + k x = 0, theEquationOfMotionalready in the file.The new section F mirrors the structure of
HarmonicOscillator/Basic.lean(sections D.1–D.3).Changes
lagrangianDampedHarmonicOscillator/Basic.leanexp (γ/m * t) *undamped lagrangianlagrangian_eq,lagrangian_eq_exp_mul_kineticEnergy_sub_potentialEnergy,lagrangian_of_isUndampedγ = 0contDiff_lagrangian(@[fun_prop])gradient_const_mul(private)gradient (c * f) = c • gradient fgradient_lagrangian_position_eq,gradient_lagrangian_velocity_eqHarmonicOscillatorgradient lemmasgradLagrangianδ ∫ Lof the actiongradLagrangian_eq_eulerLagrangeOpeuler_lagrange_varGradientderiv_exp_smul(private)∂ₜ (exp (a t) • y t)product rulegradLagrangian_eq_forceexp (γ/m * t) • (F − m a)equationOfMotion_iff_gradLagrangian_zeroTime.val_contDiff(@[fun_prop])SpaceAndTime/Time/Derivatives.leanval_measurable/val_differentiableAPI; needed forcontDiff_lagrangian(section D retitled "Smoothness properties" to cover it)DampedHarmonicOscillator/API-map.yamlHarmonicOscillator(per the discussion on #905); Overview and References syncedReviewer reading order:
Time.val_contDiff→lagrangian→ F.1.1–F.1.3 →gradLagrangian→gradLagrangian_eq_force→equationOfMotion_iff_gradLagrangian_zero.Scope — what is NOT changed
Time/Derivatives.leansection-D title and the API-map prose are touched.HarmonicOscillator/Basic.leansection D.2 transposes the position and velocity arguments ofL(t, x, v)(doc-only typo). The new section F.2 here states it correctly; I can fix theHarmonicOscillatordocstring in a small follow-up rather than widen this diff.Solution.leanhas a privateexp_decay_smul_velocitysimilar in spirit to the privatederiv_exp_smuladded here (decay vs growth sign, function-level vs pointwise). Unifying them would mean touchingSolution.lean; happy to do that as a follow-up if preferred.Solution.lean).On size: the diff is 236 gross lines, but roughly half is module-doc/section-header text required by the numbered template; the net Lean code is ~110 lines forming one coherent concept (the CK lagrangian and its Euler-Lagrange derivation), which loses its point if split.
Verification
lake build(full library): success; touched modules re-built clean after the final docs pass.lake exe lint_all: passes (the "transitive imports" shake messages are the known pre-existing false positives, incl. onTime/Derivatives.leanbefore this change)../scripts/lint-style.sh(on the committed state): clean.#print axiomson all 12 new public declarations: only[propext, Classical.choice, Quot.sound].Toward #905.