Skip to content

Commit 5a86ba0

Browse files
authored
Merge pull request 3b1b#596 from 3b1b/diffyq
Diffyq
2 parents 66f9ff2 + e421d36 commit 5a86ba0

File tree

12 files changed

+2341
-62
lines changed

12 files changed

+2341
-62
lines changed

active_projects/ode/all_part3_scenes.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
from active_projects.ode.part3.temperature_graphs import *
33
from active_projects.ode.part3.pi_creature_scenes import *
44
from active_projects.ode.part3.wordy_scenes import *
5+
from active_projects.ode.part3.discrete_case import *
56

67

78
OUTPUT_DIRECTORY = "ode/part3"
89
SCENES_IN_ORDER = [
910
LastChapterWrapper,
1011
ThreeConstraints,
1112
OceanOfPossibilities,
12-
# TODO
1313
ThreeMainObservations,
14+
SimpleCosExpGraph,
15+
AddMultipleSolutions,
16+
FourierSeriesIllustraiton,
1417
BreakDownAFunction,
1518
SineCurveIsUnrealistic,
1619
AnalyzeSineCurve,
@@ -27,7 +30,31 @@
2730
BoundaryConditionReference,
2831
GiantCross,
2932
SimulateRealSineCurve,
33+
DerivativesOfLinearFunction,
34+
StraightLine3DGraph,
3035
SimulateLinearGraph,
36+
EmphasizeBoundaryPoints,
37+
ShowNewRuleAtDiscreteBoundary,
38+
DiscreteEvolutionPoint25,
39+
DiscreteEvolutionPoint1,
40+
FlatEdgesForDiscreteEvolution,
41+
FlatEdgesForDiscreteEvolutionTinySteps,
42+
FlatEdgesContinuousEvolution,
43+
FlatAtBoundaryWords,
44+
SlopeToHeatFlow,
45+
CloserLookAtStraightLine,
46+
WriteOutBoundaryCondition,
47+
SoWeGotNowhere,
48+
ManipulateSinExpSurface,
49+
HeatEquationFrame,
50+
ShowFreq1CosExpDecay,
51+
ShowFreq2CosExpDecay,
52+
ShowFreq4CosExpDecay,
53+
CompareFreqDecays1to2,
54+
CompareFreqDecays1to4,
55+
CompareFreqDecays2to4,
56+
ShowHarmonics,
57+
ShowHarmonicSurfaces,
3158

3259
# SimpleCosExpGraph,
3360
# AddMultipleSolutions,

active_projects/ode/part2/heat_equation.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def setup_axes(self):
185185

186186
y_label = axes.get_y_axis_label("\\text{Temperature}")
187187
y_label.to_edge(UP)
188+
axes.y_axis.label = y_label
188189
axes.y_axis.add(y_label)
189190
axes.y_axis.add_numbers(
190191
*range(20, 100, 20)
@@ -329,7 +330,7 @@ def initial_function(self, x):
329330
else:
330331
return 10
331332

332-
def update_graph(self, graph, dt, alpha=None, n_mini_steps=100):
333+
def update_graph(self, graph, dt, alpha=None, n_mini_steps=500):
333334
if alpha is None:
334335
alpha = self.alpha
335336
points = np.append(
@@ -349,7 +350,7 @@ def update_graph(self, graph, dt, alpha=None, n_mini_steps=100):
349350
if (0 < i < len(points) - 1):
350351
second_deriv = d2y / (dx**2)
351352
else:
352-
second_deriv = d2y / dx
353+
second_deriv = 2 * d2y / (dx**2)
353354
# second_deriv = 0
354355

355356
y_change[i] = alpha * second_deriv * dt / n_mini_steps
@@ -464,6 +465,7 @@ def construct(self):
464465
self.add_clock()
465466
self.add_rod()
466467
self.add_arrows()
468+
self.initialize_updaters()
467469
self.let_play()
468470

469471
def add_axes(self):
@@ -521,24 +523,25 @@ def update_arrows(arrows):
521523
self.add(arrows)
522524
self.arrows = arrows
523525

524-
def let_play(self):
525-
graph = self.graph
526-
rod = self.rod
527-
clock = self.clock
528-
time_label = self.time_label
526+
def initialize_updaters(self):
527+
if hasattr(self, "graph"):
528+
self.graph.add_updater(self.update_graph)
529+
if hasattr(self, "rod"):
530+
self.rod.add_updater(self.color_rod_by_graph)
531+
if hasattr(self, "time_label"):
532+
self.time_label.add_updater(
533+
lambda d, dt: d.increment_value(dt)
534+
)
529535

530-
graph.add_updater(self.update_graph)
531-
time_label.add_updater(
532-
lambda d, dt: d.increment_value(dt)
533-
)
534-
rod.add_updater(self.color_rod_by_graph)
536+
def let_play(self):
537+
self.run_clock(self.wait_time)
535538

536-
# return
539+
def run_clock(self, time):
537540
self.play(
538541
ClockPassesTime(
539-
clock,
540-
run_time=self.wait_time,
541-
hours_passed=self.wait_time,
542+
self.clock,
543+
run_time=time,
544+
hours_passed=time,
542545
),
543546
)
544547

0 commit comments

Comments
 (0)