Spaces:
Paused
Paused
Download theory.py from jobinv/MathematicsApps: direct link, hf CLI and curl.
- Browser
- Download file 10.7 kB
-
https://huggingface.co/spaces/jobinv/MathematicsApps/resolve/main/theory.py
- Command line
-
hf download hf://spaces/jobinv/MathematicsApps/theory.py
-
curl -L -o theory.py https://huggingface.co/spaces/jobinv/MathematicsApps/resolve/main/theory.py
10.7 kB
| """Compact teaching notes matched to each generated M1 mission.""" | |
| from __future__ import annotations | |
| THEORY = { | |
| "custom_train": r""" | |
| ## Theory vault · Electric train journey | |
| The live train, question and diagrams share one three-stage speed model: | |
| 1. uniform acceleration from $u$ to $V=u+at_a$; | |
| 2. constant speed $V$ for $t_c$; | |
| 3. uniform braking of magnitude $b$ until $v=0$. | |
| The braking time is $V/b$. Distance is the area under the speed–time graph, | |
| so the complete journey is | |
| $$s=ut_a+\tfrac12at_a^2+Vt_c+\frac{V^2}{2b}.$$ | |
| Average speed is total distance divided by total time. It is not generally the | |
| average of the initial and maximum speeds because the three stages last for | |
| different times. | |
| ### Forces and the visual model | |
| During acceleration, Newton's second law along the track gives | |
| $$F-R=ma.$$ | |
| With mass in tonnes, $ma$ is numerically in kN. The train length represents | |
| mass, the rate of movement represents the calculated speed, and the animation | |
| changes from acceleration to cruising and braking at the exact model times. | |
| """, | |
| "custom_rocket": r""" | |
| ## Theory vault · Rocket capsule after engine cut-off | |
| Once the engine cuts off, gravity is the only force in the model. Taking | |
| upward as positive gives $a=-g$ and | |
| $$v=u-gt,\qquad y=h+ut-\tfrac12gt^2.$$ | |
| At the highest point $v=0$, so $t_{top}=u/g$ and | |
| $$y_{max}=h+\frac{u^2}{2g}.$$ | |
| To find when the capsule reaches the ground, set $y=0$ and use the positive | |
| root. Its speed immediately before landing satisfies | |
| $$v^2=u^2+2gh.$$ | |
| The capsule in the experiment follows this same height equation frame by | |
| frame. Its size responds to mass; its path and landing time respond to height, | |
| launch speed and gravity. The whoosh and landing flash are learning cues, not | |
| extra forces in the mechanics model. | |
| """, | |
| "custom_trolley": r""" | |
| ## Theory vault · Pulled trolley on a rough floor | |
| Resolve the angled pulling force $P$ before applying Newton's second law. The | |
| upward component reduces the normal reaction: | |
| $$R+P\sin\theta=mg,\qquad F=\mu R.$$ | |
| While the trolley moves to the right, friction acts to the left, so | |
| $$P\cos\theta-F=ma.$$ | |
| The sign of $a$ decides what the animation shows. A positive result speeds the | |
| trolley up; a negative result slows it down. If $-u/a$ is within the selected | |
| trial time, the model stops at that instant and does not reverse under the | |
| same kinetic-friction assumption. | |
| Displacement before stopping or the end of the trial is | |
| $s=ut+\tfrac12at^2$. The load size represents mass, the rope angle follows | |
| $\theta$, and friction sparks become more visible as $\mu$ increases. | |
| """, | |
| "custom_collision": r""" | |
| ## Theory vault · Build-your-own two-body mechanics | |
| The custom lab keeps the diagram, question and solution linked to one physical | |
| model. Before impact, both particles use constant-acceleration kinematics: | |
| $$x_P=u_Pt+\tfrac12a_Pt^2,\qquad | |
| x_Q=d+u_Qt+\tfrac12a_Qt^2.$$ | |
| A collision occurs only if $x_P=x_Q$ has a positive real solution. If it does | |
| not, the least separation is found by differentiating $x_Q-x_P$ and setting the | |
| relative velocity to zero. | |
| ### Why friction and acceleration can both be controlled | |
| The velocity and acceleration sliders use **right as positive**. The | |
| acceleration sliders specify net acceleration. While a roller is moving, | |
| friction has magnitude $\mu mg$ and points opposite its velocity. Therefore the | |
| signed horizontal driving force is | |
| $$X-\operatorname{sgn}(u)\mu mg=ma | |
| \quad\Rightarrow\quad | |
| X=ma+\operatorname{sgn}(u)\mu mg.$$ | |
| A negative velocity or force means it points left. If a roller starts from | |
| rest, the intended acceleration supplies the provisional direction; if both | |
| velocity and acceleration are zero, the model reports zero initial friction. | |
| ### During impact | |
| External impulses are negligible over the short impact time, so momentum is | |
| conserved. If the particles join, they share one velocity. If they separate, | |
| the restitution equation is also used: | |
| $$v_Q-v_P=e(u_P-u_Q).$$ | |
| Sphere radius in the 3D view and collision game is proportional to $m^{1/3}$, | |
| so visual volume is proportional to mass. The coloured band makes rotation | |
| visible, while the calculations retain the M1 particle assumption and ignore | |
| rotational kinetic energy. | |
| """, | |
| "collision": r""" | |
| ## Theory vault · Momentum and impulse | |
| ### The physical story | |
| Momentum measures how difficult a moving object is to stop: | |
| $$\mathbf p=m\mathbf v$$ | |
| During a short collision, internal contact forces are large but occur in | |
| equal-and-opposite pairs. If the external impulse in the direction of motion is | |
| negligible, total **signed** momentum is conserved: | |
| $$\sum m u=\sum m v.$$ | |
| Impulse is the change in momentum of one object: | |
| $$J=\Delta p=m(v-u).$$ | |
| ### Exam routine | |
| 1. Draw arrows and declare a positive direction. | |
| 2. Give every velocity a sign; speed alone has no sign. | |
| 3. Write one total-momentum equation. | |
| 4. For impulse, use the change for the named particle only. | |
| 5. State units: $\mathrm{N\,s}=\mathrm{kg\,m\,s^{-1}}$. | |
| ### Model language | |
| “Smooth horizontal plane” means there is no horizontal friction impulse. | |
| “Particles” means size and rotation are ignored. “Join together” means both | |
| objects have one common velocity after impact. | |
| """, | |
| "vertical": r""" | |
| ## Theory vault · Constant acceleration and gravity | |
| For motion with constant acceleration: | |
| $$v=u+at,\qquad s=ut+\tfrac12at^2,$$ | |
| $$v^2=u^2+2as,\qquad s=\tfrac12(u+v)t.$$ | |
| Near Earth, a freely moving particle has acceleration $g=9.8\,\mathrm{m\,s^{-2}}$ | |
| downward. If upward is positive, then $a=-9.8$. | |
| ### The sign table habit | |
| Before substituting, write $u$, $v$, $a$ and $s$ with signs. The ground is | |
| below a raised launch point, so its displacement is negative when upward is | |
| positive. At greatest height the **velocity** is zero, but acceleration is | |
| still $-g$. | |
| ### Model language | |
| “Particle moving freely under gravity” means air resistance is ignored and | |
| gravity is the only force after release. The constant-$g$ model is being used. | |
| """, | |
| "speed_time": r""" | |
| ## Theory vault · Speed–time graphs | |
| Two meanings unlock the whole graph: | |
| - **Gradient** $=\dfrac{\Delta v}{\Delta t}=$ acceleration. | |
| - **Area under the graph** $=$ distance travelled. | |
| A straight sloping line means constant acceleration. A horizontal line means | |
| constant speed. For a triangle, area is $\tfrac12bh$; for a rectangle it is | |
| $bh$. | |
| ### Ratio reasoning | |
| For the same change in speed, time is inversely proportional to acceleration | |
| magnitude. If acceleration is twice deceleration, the acceleration time is | |
| half the deceleration time. | |
| ### Exam checks | |
| Label both axes and their units. Make the graph continuous. Average speed is | |
| total distance divided by total time—not the mean of the largest and smallest | |
| speeds unless the graph happens to justify that shortcut. | |
| """, | |
| "beam": r""" | |
| ## Theory vault · Moments and rigid-body equilibrium | |
| The moment of a force about a point is | |
| $$\text{moment}=F\times d_\perp,$$ | |
| where $d_\perp$ is the perpendicular distance from the point to the force's | |
| line of action. In equilibrium: | |
| $$\sum F_x=0,\qquad \sum F_y=0,\qquad \sum M_A=0.$$ | |
| ### Why “uniform” matters | |
| A uniform beam has its centre of mass at its geometric midpoint, so its weight | |
| acts there. A non-uniform beam needs a separately specified or calculated | |
| centre of mass. | |
| ### Exam routine | |
| 1. Mark every force and distance on one diagram. | |
| 2. Use vertical equilibrium for reactions or tensions. | |
| 3. Take moments about a point that removes an unknown force. | |
| 4. Label clockwise and anticlockwise terms before equating them. | |
| At the point of tilting, the reaction at the support that is losing contact is | |
| zero. | |
| """, | |
| "friction": r""" | |
| ## Theory vault · Friction and limiting equilibrium | |
| Friction acts parallel to the contact surface and opposes actual or impending | |
| relative motion. Its general law is | |
| $$0\le F\le \mu R.$$ | |
| Only at limiting equilibrium—“on the point of slipping”—may we use | |
| $$F=\mu R.$$ | |
| An angled pull changes the normal reaction. For a pull $P$ at angle $\theta$ | |
| above a horizontal plane: | |
| $$R+P\sin\theta=mg.$$ | |
| The upward component therefore reduces $R$ and reduces the maximum available | |
| friction. | |
| ### Common trap | |
| Do not automatically write $R=mg$. Resolve vertically first. Also decide the | |
| direction of impending motion before drawing the friction arrow. | |
| """, | |
| "connected": r""" | |
| ## Theory vault · Connected particles | |
| Apply Newton's second law separately to each particle: | |
| $$\sum F=ma.$$ | |
| A light inextensible string stays taut, so both ends have the same acceleration | |
| magnitude. A small smooth pulley allows the tension to be modelled as the same | |
| on both sides. | |
| For a block on an incline: | |
| $$W_\parallel=mg\sin\alpha,\qquad R=mg\cos\alpha.$$ | |
| If the block moves up the plane, friction acts down it. Choose the positive | |
| direction to match each particle's stated motion, write two equations, and add | |
| them to eliminate tension. | |
| ### Modelling checklist | |
| - particle: ignore size and rotation; | |
| - light string: ignore string mass; | |
| - inextensible: equal acceleration magnitudes; | |
| - smooth pulley: equal tension on both sides; | |
| - rough plane: include friction. | |
| """, | |
| "vectors": r""" | |
| ## Theory vault · Vector kinematics and bearings | |
| With constant vector acceleration: | |
| $$\mathbf v=\mathbf u+t\mathbf a,\qquad | |
| \mathbf r=\mathbf r_0+t\mathbf u+\tfrac12t^2\mathbf a.$$ | |
| Resolve into east ($\mathbf i$) and north ($\mathbf j$) components. The speed is | |
| the magnitude of velocity: | |
| $$|\mathbf v|=\sqrt{v_x^2+v_y^2}.$$ | |
| The velocity—not the position vector—gives the instantaneous direction of | |
| motion. | |
| ### Bearing convention | |
| Bearings are measured clockwise from north and written with three figures, | |
| such as $045^\circ$ or $270^\circ$. Use the signs of east and north components | |
| to identify the quadrant before using inverse trigonometry. | |
| """, | |
| "equilibrium": r""" | |
| ## Theory vault · Equilibrium of a particle | |
| A particle in equilibrium has zero resultant force: | |
| $$\sum \mathbf F=\mathbf 0.$$ | |
| Choose axes that simplify the geometry. For a particle held by a string and a | |
| force perpendicular to that string, resolving along and perpendicular to the | |
| string avoids simultaneous equations. | |
| ### Free-body diagram rule | |
| Isolate the particle and draw only forces acting **on** it: weight vertically | |
| down, tension along the string towards the support, and the applied force in | |
| its stated direction. | |
| For three non-parallel forces in equilibrium, the vectors can also be arranged | |
| head-to-tail to form a closed triangle of forces. | |
| """, | |
| } | |
| def theory_for(question: dict) -> str: | |
| if not question: | |
| return "Generate a mission to unlock its theory vault." | |
| return THEORY.get(question.get("theory_key"), "Theory notes are being prepared for this mission.") | |