Skip to content

Commit 28fcca3

Browse files
committed
Merge branch 'main' of github.com:nextjournal/clerk-demo
2 parents fb6e9cb + 72c626e commit 28fcca3

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

deps.edn

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{:paths ["dev" "notebooks"]
2-
:deps {io.github.nextjournal/clerk {:mvn/version "0.6.387"}
2+
:deps {io.github.nextjournal/clerk {:mvn/version "0.7.416"}
33

44
;; input various external data formats
55
com.github.seancorfield/next.jdbc {:mvn/version "1.2.659"}
@@ -12,8 +12,8 @@
1212
;; some statistical routines
1313
kixi/stats {:mvn/version "0.5.4"}
1414

15-
;; SICM utils numerical and physics routines
16-
sicmutils/sicmutils {:mvn/version "0.20.1"}
15+
;; SICMUtils numerical and physics routines
16+
sicmutils/sicmutils {:mvn/version "0.22.0"}
1717

1818
;; semantic web goodies and box/arrow graphs
1919
jackrusher/mundaneum {:git/url "https://github.com/jackrusher/mundaneum/"

notebooks/images.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
;; `java.awt.image.BufferedImage` class, which is the native image
1313
;; format of the JVM.
1414

15-
;; When combined with `java.imageio.ImageIO/read`, one can easily load
15+
;; When combined with `javax.imageio.ImageIO/read`, one can easily load
1616
;; images in a variety of formats from a `java.io.File`, an
1717
;; `java.io.InputStream`, or any resource that a `java.net.URL` can
1818
;; address.

notebooks/sicmutils.clj

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
;; the [SICMUtils](https://github.com/sicmutils/sicmutils) Clojure library and
88
;; the Clerk rendering environment.
99

10+
#_{:clj-kondo/ignore [:refer-all]}
1011
(ns sicmutils
1112
(:refer-clojure
1213
:exclude [+ - * / partial ref zero? numerator denominator compare = run!])
1314
(:require [nextjournal.clerk :as clerk]
14-
[sicmutils.env :as e :refer :all]))
15+
[sicmutils.env :as e :refer :all]
16+
[sicmutils.expression.render :as xr]))
1517

1618
;; ## Lagrangian
1719
;;
@@ -20,22 +22,22 @@
2022
;; Lagrangian with the familiar form of `T - V`.
2123

2224
(defn angles->rect [l1 l2]
23-
(fn [[t [theta1 theta2]]]
25+
(fn [[_ [theta1 theta2]]]
2426
(let [x1 (* l1 (sin theta1))
25-
y1 (- (* l1 (cos theta1)))
27+
y1 (- (* l1 (cos theta1)))
2628
x2 (+ x1 (* l2 (sin (+ theta1 theta2))))
27-
y2 (- y1 (* l2 (cos (+ theta1 theta2))))]
28-
(up x1 y1 x2 y2))))
29+
y2 (- y1 (* l2 (cos (+ theta1 theta2))))]
30+
(up x1 y1 x2 y2))))
2931

3032
;; `T` describes the sum of the kinetic energy of two particles in rectangular
3133
;; coordinates.
3234

3335
(defn T [m1 m2]
3436
(fn [[_ _ [xdot1 ydot1 xdot2 ydot2]]]
35-
(+ (* (/ 1 2) m1 (+ (square xdot1)
36-
(square ydot1)))
37-
(* (/ 1 2) m2 (+ (square xdot2)
38-
(square ydot2))))))
37+
(+ (* 1/2 m1 (+ (square xdot1)
38+
(square ydot1)))
39+
(* 1/2 m2 (+ (square xdot2)
40+
(square ydot2))))))
3941

4042

4143
;; `V` describes a uniform gravitational potential with coefficient `g`, acting
@@ -85,7 +87,7 @@
8587
;; And here are the equations of motion for the system:
8688

8789
(let [L (L-double-pendulum 'm_1 'm_2 'l_1 'l_2 'g)]
88-
(binding [sicmutils.expression.render/*TeX-vertical-down-tuples* true]
90+
(binding [xr/*TeX-vertical-down-tuples* true]
8991
(render-eq
9092
(((Lagrange-equations L)
9193
(up (literal-function 'theta_1)
@@ -95,7 +97,6 @@
9597
;; What do these mean?
9698
;;
9799
;; - the system has two degrees of freedom: $\theta_1$ and $\theta_2$.
98-
99100
;; - at any point `t` in time, the two equations above, full of first and second
100101
;; - order derivatives of the position functions, will stay true
101102
;; - the system can use these equations to simulate the system, one tick at a time.
@@ -162,7 +163,7 @@
162163
horizon
163164
{:compile? true
164165
:epsilon 1.0e-13
165-
:observe (fn [t state]
166+
:observe (fn [_ state]
166167
(swap!
167168
collector conj! state))})
168169
(persistent! @collector))))
@@ -221,6 +222,7 @@
221222

222223
;; Here is `transform-data`:
223224

225+
#_{:clj-kondo/ignore [:unresolved-symbol]}
224226
(defn transform-data [xs]
225227
(let [energy-fn (L-energy m1 m2 l1 l2 g)
226228
monitor (energy-monitor energy-fn (first xs))
@@ -453,29 +455,29 @@
453455

454456
(defn divergence-monitor []
455457
(let [pv (principal-value Math/PI)]
456-
(fn [[t [thetas1 thetas2]]]
458+
(fn [[_ [thetas1 thetas2]]]
457459
(safe-log
458460
(Math/abs
459461
(pv
460-
(- (nth thetas1 1)
461-
(nth thetas2 1))))))))
462+
(- (nth thetas1 1)
463+
(nth thetas2 1))))))))
462464

463465
(defn run-double-double!
464466
"Two different initializations, slightly kicked"
465467
[step horizon initial-q1]
466468
(let [initial-q2 (+ initial-q1 (up 0.0 1e-10))
467469
initial-qdot (up 0.0 0.0)
468470
initial-state (up 0.0
469-
(up initial-q1 initial-q2)
470-
(up initial-qdot initial-qdot))
471+
(up initial-q1 initial-q2)
472+
(up initial-qdot initial-qdot))
471473
collector (atom (transient []))]
472474
((evolve dd-state-derivative m1 m2 l1 l2 g)
473475
initial-state
474476
step
475477
horizon
476478
{:compile? true
477479
:epsilon 1.0e-13 ; = (max-norm 1.e-13)
478-
:observe (fn [t state]
480+
:observe (fn [_ state]
479481
(swap! collector conj! state))})
480482
(persistent! @collector)))
481483

0 commit comments

Comments
 (0)