in2lambda 0.3.0__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {in2lambda-0.3.0 → in2lambda-0.3.2}/PKG-INFO +5 -4
  2. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/api/module.py +36 -5
  3. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/api/question.py +37 -17
  4. in2lambda-0.3.2/in2lambda/example_questions.tex +231 -0
  5. in2lambda-0.3.2/in2lambda/example_solutions.tex +567 -0
  6. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/filters/PartsSepSol/filter.py +5 -3
  7. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/filters/markdown.py +4 -1
  8. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/json_convert/json_convert.py +2 -2
  9. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/json_convert/minimal_template.json +1 -1
  10. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/main.py +14 -5
  11. {in2lambda-0.3.0 → in2lambda-0.3.2}/pyproject.toml +10 -10
  12. {in2lambda-0.3.0 → in2lambda-0.3.2}/LICENSE +0 -0
  13. {in2lambda-0.3.0 → in2lambda-0.3.2}/README.md +0 -0
  14. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/__init__.py +0 -0
  15. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/api/__init__.py +0 -0
  16. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/api/part.py +0 -0
  17. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/filters/PartPartSolSol/__init__.py +0 -0
  18. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/filters/PartPartSolSol/example.tex +0 -0
  19. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/filters/PartPartSolSol/filter.py +0 -0
  20. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/filters/PartSolPartSol/__init__.py +0 -0
  21. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/filters/PartSolPartSol/example.tex +0 -0
  22. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/filters/PartSolPartSol/filter.py +0 -0
  23. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/filters/PartsOneSol/__init__.py +0 -0
  24. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/filters/PartsOneSol/example.tex +0 -0
  25. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/filters/PartsOneSol/filter.py +0 -0
  26. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/filters/PartsSepSol/__init__.py +0 -0
  27. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/filters/PartsSepSol/example.tex +0 -0
  28. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/filters/__init__.py +0 -0
  29. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/json_convert/__init__.py +0 -0
  30. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/katex_convert/__init__.py +0 -0
  31. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/katex_convert/delete_list.txt +0 -0
  32. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/katex_convert/katex_convert.py +0 -0
  33. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/katex_convert/replace_list.txt +0 -0
  34. {in2lambda-0.3.0 → in2lambda-0.3.2}/in2lambda/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: in2lambda
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Converts content ready for import into Lambda Feedback
5
5
  Home-page: https://lambda-feedback.github.io/in2lambda
6
6
  License: MIT
@@ -12,11 +12,12 @@ Classifier: Operating System :: OS Independent
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.10
14
14
  Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
15
16
  Classifier: Programming Language :: Python :: 3 :: Only
16
17
  Classifier: Typing :: Typed
17
- Requires-Dist: beartype (>=0.16.4,<0.17.0)
18
- Requires-Dist: panflute (>=2.3.0,<3.0.0)
19
- Requires-Dist: rich-click (>=1.7.2,<2.0.0)
18
+ Requires-Dist: beartype (>=0.17.2,<0.18.0)
19
+ Requires-Dist: panflute (>=2.3.1,<3.0.0)
20
+ Requires-Dist: rich-click (>=1.7.4,<2.0.0)
20
21
  Project-URL: Bug Tracker, https://github.com/lambda-feedback/in2lambda/issues
21
22
  Project-URL: Documentation, https://lambda-feedback.github.io/in2lambda
22
23
  Project-URL: Repository, https://github.com/lambda-feedback/in2lambda
@@ -6,6 +6,7 @@ from typing import Union
6
6
  import panflute as pf
7
7
 
8
8
  from in2lambda.api.question import Question
9
+ from in2lambda.json_convert import json_convert
9
10
 
10
11
 
11
12
  @dataclass
@@ -28,11 +29,11 @@ class Module:
28
29
  Examples:
29
30
  >>> from in2lambda.api.module import Module
30
31
  >>> Module().current_question
31
- Question(title='INVALID', parts=[], images=[], _main_text='')
32
+ Question(title='INVALID', parts=[], images=[], main_text='')
32
33
  >>> module = Module()
33
34
  >>> module.add_question()
34
35
  >>> module.current_question
35
- Question(title='', parts=[], images=[], _main_text='')
36
+ Question(title='', parts=[], images=[], main_text='')
36
37
  """
37
38
  return (
38
39
  self.questions[self._current_question_index]
@@ -56,7 +57,7 @@ class Module:
56
57
  >>> module = Module()
57
58
  >>> module.add_question("Some title", pf.Para(pf.Str("hello"), pf.Space, pf.Str("there")))
58
59
  >>> module
59
- Module(questions=[Question(title='Some title', parts=[], images=[], _main_text='hello there')])
60
+ Module(questions=[Question(title='Some title', parts=[], images=[], main_text='hello there')])
60
61
  >>> module.add_question(main_text="Normal string text")
61
62
  >>> module.questions[1].main_text
62
63
  'Normal string text'
@@ -85,7 +86,37 @@ class Module:
85
86
  >>> module.increment_current_question()
86
87
  >>> module.current_question.add_solution("Question 2 answer")
87
88
  >>> module.questions
88
- [Question(title='Question 1', parts=[Part(text='', worked_solution='Question 1 answer')], images=[], _main_text=''),\
89
- Question(title='Question 2', parts=[Part(text='', worked_solution='Question 2 answer')], images=[], _main_text='')]
89
+ [Question(title='Question 1', parts=[Part(text='', worked_solution='Question 1 answer')], images=[], main_text=''),\
90
+ Question(title='Question 2', parts=[Part(text='', worked_solution='Question 2 answer')], images=[], main_text='')]
90
91
  """
91
92
  self._current_question_index += 1
93
+
94
+ def to_json(self, output_dir: str) -> None:
95
+ """Turns this module into Lambda Feedback JSON/ZIP files.
96
+
97
+ WARNING: This will overwrite any existing files in the directory.
98
+
99
+ Args:
100
+ output_dir: Where to output the final Lambda Feedback JSON/ZIP files.
101
+
102
+ Examples:
103
+ >>> import tempfile
104
+ >>> import os
105
+ >>> import json
106
+ >>> # Create a module with two questions
107
+ >>> module = Module()
108
+ >>> module.add_question("Question 1")
109
+ >>> module.add_question("Question 2")
110
+ >>> with tempfile.TemporaryDirectory() as temp_dir:
111
+ ... # Write the JSON files to the temporary directory
112
+ ... module.to_json(temp_dir)
113
+ ... # Check the contents of the directory
114
+ ... sorted(os.listdir(temp_dir))
115
+ ... # Check the title of the first question
116
+ ... with open(f"{temp_dir}/question_1/question_1.json") as file:
117
+ ... print(f"Question 1's title: {json.load(file)['title']}")
118
+ ['question_1', 'question_1.zip', 'question_2', 'question_2.zip']
119
+ Question 1's title: Question 1
120
+
121
+ """
122
+ json_convert.main(self.questions, output_dir)
@@ -16,8 +16,8 @@ class Question:
16
16
 
17
17
  Examples:
18
18
  >>> from in2lambda.api.question import Question
19
- >>> Question(title="Some title", _main_text="Some text")
20
- Question(title='Some title', parts=[], images=[], _main_text='Some text')
19
+ >>> Question(title="Some title", main_text="Some text")
20
+ Question(title='Some title', parts=[], images=[], main_text='Some text')
21
21
  """
22
22
 
23
23
  title: str = ""
@@ -25,7 +25,11 @@ class Question:
25
25
  parts: list[Part] = field(default_factory=list)
26
26
  images: list[str] = field(default_factory=list)
27
27
 
28
- _main_text: str = ""
28
+ # Use getter/setter methods for main_text without exposing private attribute.
29
+ # See https://stackoverflow.com/a/61480946
30
+ main_text: str = ""
31
+ _main_text: str = field(init=False, repr=False, default="")
32
+
29
33
  _last_part: dict[str, int] = field(
30
34
  default_factory=lambda: {"solution": 0, "text": 0}, repr=False
31
35
  )
@@ -34,15 +38,10 @@ class Question:
34
38
 
35
39
  @property
36
40
  def main_text(self) -> str:
37
- """Main top-level question text."""
38
- return self._main_text
41
+ r"""Main top-level question text.
39
42
 
40
- @main_text.setter
41
- def main_text(self, value: Union[pf.Element, str]) -> None:
42
- r"""Appends to the top-level main text, which starts off as an empty string.
43
-
44
- Args:
45
- value: A panflute element or string denoting what to append to the main text.
43
+ Setting the attribute multiple times appends to the current value with a newline.
44
+ This allows question text to be dynamically appended.
46
45
 
47
46
  Examples:
48
47
  >>> from in2lambda.api.question import Question
@@ -52,7 +51,28 @@ class Question:
52
51
  >>> question.main_text
53
52
  'hello\nthere'
54
53
  """
55
- text_value = value if isinstance(value, str) else pf.stringify(value, False)
54
+ return self._main_text
55
+
56
+ @main_text.setter
57
+ def main_text(self, value: Union[pf.Element, str, property]) -> None:
58
+ r"""Appends to the top-level main text, which starts off as an empty string.
59
+
60
+ Args:
61
+ value: A panflute element or string denoting what to append to the main text.
62
+
63
+ See example in main_text property.
64
+ """
65
+ # Converts the inputted value into a string, stored in text_value
66
+ match value:
67
+ case str():
68
+ text_value = value
69
+ case property():
70
+ # Use default value when no value set at initialisation.
71
+ # See https://stackoverflow.com/a/61480946
72
+ text_value = self.main_text
73
+ case pf.Element():
74
+ text_value = pf.stringify(value, False)
75
+
56
76
  if self._main_text:
57
77
  self._main_text += "\n"
58
78
  self._main_text += text_value
@@ -69,7 +89,7 @@ class Question:
69
89
  >>> question.add_part_text("part a")
70
90
  >>> question.add_solution("part a solution")
71
91
  >>> question
72
- Question(title='', parts=[Part(text='part a', worked_solution='part a solution')], images=[], _main_text='')
92
+ Question(title='', parts=[Part(text='part a', worked_solution='part a solution')], images=[], main_text='')
73
93
  >>> question.add_part_text("part b")
74
94
  >>> question.add_part_text("part c")
75
95
  >>> question.add_solution("Solution for b")
@@ -77,12 +97,12 @@ class Question:
77
97
  >>> question
78
98
  Question(title='', parts=[Part(text='part a', worked_solution='part a solution'), \
79
99
  Part(text='part b', worked_solution='Solution for b'), \
80
- Part(text='part c', worked_solution='Solution for b')], images=[], _main_text='')
100
+ Part(text='part c', worked_solution='Solution for b')], images=[], main_text='')
81
101
  >>> question.add_solution("We now have a solution for c!")
82
102
  >>> question
83
103
  Question(title='', parts=[Part(text='part a', worked_solution='part a solution'), \
84
104
  Part(text='part b', worked_solution='Solution for b'), \
85
- Part(text='part c', worked_solution='We now have a solution for c!')], images=[], _main_text='')
105
+ Part(text='part c', worked_solution='We now have a solution for c!')], images=[], main_text='')
86
106
  """
87
107
  elem_text = elem if isinstance(elem, str) else pf.stringify(elem)
88
108
 
@@ -111,13 +131,13 @@ Part(text='part c', worked_solution='We now have a solution for c!')], images=[]
111
131
  >>> question.add_part_text("part a")
112
132
  >>> question.add_solution("part a solution")
113
133
  >>> question
114
- Question(title='', parts=[Part(text='part a', worked_solution='part a solution')], images=[], _main_text='')
134
+ Question(title='', parts=[Part(text='part a', worked_solution='part a solution')], images=[], main_text='')
115
135
  >>> # Supports adding the answer first.
116
136
  >>> question.add_solution("part b solution")
117
137
  >>> question.add_part_text("part b")
118
138
  >>> question
119
139
  Question(title='', parts=[Part(text='part a', worked_solution='part a solution'), \
120
- Part(text='part b', worked_solution='part b solution')], images=[], _main_text='')
140
+ Part(text='part b', worked_solution='part b solution')], images=[], main_text='')
121
141
  """
122
142
  elem_text = elem if isinstance(elem, str) else pf.stringify(elem)
123
143
 
@@ -0,0 +1,231 @@
1
+ \documentclass[12pt]{article}
2
+
3
+ % Mechanics course definitions and macros.
4
+ %\usepackage{mechanics}
5
+ \usepackage{graphicx}
6
+
7
+ % Add space between paragraphs instead of indenting.
8
+ \usepackage{parskip}
9
+
10
+ \addtolength{\topmargin}{-4em}
11
+ \addtolength{\evensidemargin}{-3em}
12
+ \addtolength{\oddsidemargin}{-3em}
13
+ \addtolength{\textheight}{6em}
14
+ \addtolength{\textwidth}{4em}
15
+
16
+ %\usepackage{bm}
17
+ \usepackage{graphics}
18
+ \usepackage{color}
19
+ \usepackage{amsmath}
20
+
21
+ \begin{document}
22
+ \section*{\textrm{\textbf{Mechanics Problem Sheet 4 --- Collisions and CoM frame}}}
23
+
24
+ \begin{enumerate}
25
+ %\begin{enumerate}
26
+ \item The ballistic pendulum is a device for determining the speed of a
27
+ projectile. A large stationary mass $M$ is suspended by a wire from
28
+ the ceiling and a projectile of mass $m$ is fired into it at an
29
+ unknown speed $u$. The projectile embeds itself in the hanging mass.
30
+ Assume that $g = 9.8\,\text{m}\cdot\text{s}^{-2}$.
31
+ \begin{enumerate}
32
+ \item Is momentum conserved in the collision? Is kinetic energy
33
+ conserved?
34
+ \item Derive an expression for the height $h$ to which the masses rise
35
+ after the collision.
36
+ \item A bullet of mass $m = 12\,$g is fired into a block of mass
37
+ $M = 10\,$kg and the height rise $h$ is measured to be $10\,$cm.
38
+ What was the speed of the bullet?
39
+ \end{enumerate}
40
+
41
+ \item A ping-pong (table tennis) ball makes a head-on elastic collision
42
+ with a much heavier basketball, which is initially stationary. Which
43
+ of the following statements are true after the collision?
44
+ \begin{enumerate}
45
+ \item The absolute value of the momentum of the ping-pong ball is
46
+ smaller than that of the basketball.
47
+ \item The absolute value of the momentum of the ping-pong ball is the
48
+ same as that of the basketball.
49
+ \item The absolute value of the momentum of the ping-pong ball is
50
+ greater than that of the basketball.
51
+ \item Not enough information is given to decide between (a), (b) and
52
+ (c).
53
+ \item The ping-pong ball has less kinetic energy than the basketball.
54
+ \item The ping-pong ball has the same kinetic energy as the
55
+ basketball.
56
+ \item The ping-pong ball has more kinetic energy than the basketball.
57
+ \item Not enough information is given to decide between (e), (f) and
58
+ (g).
59
+ \end{enumerate}
60
+
61
+ \item Question 3 on Problem Sheet 3 (repeated below) was about a woman
62
+ walking along a plank on a frictionless frozen lake. Solve this
63
+ problem again, this time using the concept of the centre of mass.
64
+
65
+ % \begin{tcolbox}{0.96\textwidth}
66
+ % {Woman walking along a plank on a frozen lake}
67
+ A woman of mass 60\,kg stands at one end of a 10\,m plank of
68
+ mass 20\,kg, which itself lies on a (frictionless) frozen lake. She
69
+ walks to the other end of the plank. Work out how far she has
70
+ travelled relative to the lake.
71
+ % \end{tcolbox}
72
+
73
+ \item Two masses, $m_1 = 4\,$kg and $m_2 = 6\,$kg, are moving in the
74
+ $x$-$y$ plane. The position of $m_1$ is given by
75
+ $\vec{\boldsymbol{r}}_1(t) = (1 + 3t)\boldsymbol{\hat{i}} + t\boldsymbol{\hat{j}}$ and the position of $m_2$ by
76
+ $\vec{\boldsymbol{r}}_2(t) = -2t\boldsymbol{\hat{i}} + 5\boldsymbol{\hat{j}}$. Positions are measured in metres and
77
+ the time $t$ is measured in seconds.
78
+ \begin{enumerate}
79
+ \item What is the reduced mass of the system?
80
+ \item What is the velocity of the centre of mass?
81
+ \item What is the velocity of $m_1$ relative to $m_2$?
82
+ \item What is the momentum of $m_1$ in the centre-of-mass frame?
83
+ \item What is the total kinetic energy of the system in the
84
+ centre-of-mass frame?
85
+ \end{enumerate}
86
+
87
+ \item The position $\vec{\boldsymbol{R}}(t)$ of the centre of mass of $N$ objects with
88
+ masses $m_i$ at positions $\vec{\boldsymbol{r}}_i(t)$ is given by:
89
+ %
90
+ \begin{displaymath}
91
+ \vec{\boldsymbol{R}}(t) = \frac{\sum_{i=1}^{N} m_i \vec{\boldsymbol{r}}_i(t)}{\sum_{i=1}^{N} m_i} .
92
+ \end{displaymath}
93
+ %
94
+ Show that the vector sum of the momenta of all of the masses is zero
95
+ in the centre-of-mass frame. In other words, show that the
96
+ centre-of-mass frame is also the zero-momentum frame.
97
+
98
+ \item In lectures, you saw that the total laboratory-frame kinetic
99
+ energy of two particles is the sum of their kinetic energy in the
100
+ centre-of-mass frame and the kinetic energy of the centre of mass in
101
+ the laboratory frame. Show that the same result holds for a system of
102
+ $N$ particles. You may assume (because you proved it in the previous question) that the
103
+ total momentum of the $N$ particles is zero in the centre-of-mass
104
+ frame.
105
+
106
+ \item In one-dimensional inelastic collisions, the coefficient of
107
+ restitution $e$ is defined by the equation
108
+ %
109
+ \begin{displaymath}
110
+ v_2 - v_1 = -e (u_2 - u_1),
111
+ \end{displaymath}
112
+ %
113
+ where $v_1$ and $v_2$ are the final velocities of the two bodies and
114
+ $u_1$ and $u_2$ are their initial velocities. Use this equation, plus
115
+ momentum conservation, to derive the following expressions for the
116
+ final velocities of the two bodies (of masses $m_1$ and $m_2$) in the
117
+ case when the second body is initially at rest ($u_2 = 0$):
118
+ %
119
+ \begin{align*}
120
+ v_1 &= \frac{(m_1 - e m_2) u_1}{m_1 + m_2},
121
+ &
122
+ v_2 &= \frac{(1 + e)m_1 u_1}{m_1 + m_2}.
123
+ \end{align*}
124
+
125
+
126
+
127
+ %\end{enumerate}
128
+
129
+
130
+ %\subsection*{Problems for Reflection and Discussion}
131
+
132
+
133
+ %\begin{enumerate}
134
+ \item
135
+ A ball is dropped onto a table from an initial height $h_0$. If it
136
+ lands with speed $v$, it bounces up with speed $ev$, where the
137
+ coefficient of restitution $e$ is a positive constant less than 1.
138
+ %
139
+ \begin{enumerate}
140
+ \item Write down expressions for the speed $v_0$ of the ball when it
141
+ first hits the table and the time $t_0$ it takes to drop.
142
+
143
+ \item Find the height $h_1$ reached by the ball after its first bounce
144
+ and the corresponding drop time $t_1$. Write down expressions for
145
+ the height $h_n$ and drop time $t_n$ of the $n^{\text{th}}$ bounce.
146
+ \item How long does the ball take to stop completely? Evaluate this
147
+ time if the initial height $h_0 = 5\,$m and the coefficient of
148
+ restitution $e = 0.5$. Take $g = 10\,\text{m}\cdot\text{s}^{-2}$.
149
+
150
+ [Hint: you will need the formula for the sum of a geometric series:
151
+
152
+ \centerline{$\displaystyle a + ar + ar^2 + ar^3 + \ldots =
153
+ \frac{a}{1-r}, \qquad |r|<1.]$}
154
+ \end{enumerate}
155
+
156
+ \item In the chemical reaction $\text{NO} + \text{O}_3 \rightarrow
157
+ \text{NO}_2 + \text{O}_2$, there is an intermediate step where the
158
+ $\text{NO}$ and $\text{O}_3$ molecules combine to form an activated
159
+ complex $[\text{NO--O}_3]^{\ast}$. The diagram below shows an
160
+ empirical potential energy curve representing the three different
161
+ stages of the reaction.
162
+ %
163
+ \begin{center}
164
+ \includegraphics[width=0.75\textwidth]{figures/activated_complex.png}
165
+ \end{center}
166
+ %
167
+ Although the $x$ axis corresponds to an unspecified reaction
168
+ coordinate, the diagram can be interpreted as any other potential
169
+ function. The peak of the potential curve is 9.6\,kJ$\cdot$ mol$^{-1}$
170
+ above the combined potential energy of the $\text{NO} + \text{O}_3$
171
+ reactants; this is the ``activation energy'' required for the reaction
172
+ to take place. One mole consists of Avogadro's number, $6.022 \times
173
+ 10^{23}$, of $[\text{NO--O}_3]^{\ast}$ complexes. The mass of a
174
+ nitrogen atom is 14 atomic mass units and the mass of an oxygen
175
+ atom is 16 atomic mass units.
176
+
177
+ \smallskip
178
+
179
+ An $\text{NO}$ molecule travelling in the $x$ direction at speed
180
+ $u_{\text{NO}} = -550\,\text{m}\cdot\text{s}^{-1}$ and an $\text{O}_3$
181
+ molecule travelling at
182
+ $u_{\text{O}_3} = +550\,\text{m}\cdot\text{s}^{-1}$ collide. After the
183
+ collision, the molecules temporarily coalesce to form an
184
+ $[\text{NO--O}_3]^{\ast}$ complex.
185
+ \begin{enumerate}
186
+ \item Find the velocity of the $[\text{NO--O}_3]^{\ast}$ complex
187
+ after the collision.
188
+ \item Show that the collision is inelastic. What has happened to the
189
+ kinetic energy lost in the collision?
190
+ \item Will this collision lead to the formation of $\text{NO}_2$?
191
+ Explain your answer.
192
+ \item Two oxygen atoms collide in isolation. Could the collision
193
+ result in the formation of an $\text{O}_2$ molecule in the right
194
+ circumstances?
195
+ \end{enumerate}
196
+
197
+
198
+ \item Show that the velocity $v(t)$ of a rocket starting from rest and
199
+ accelerating against the Earth's gravity is given by
200
+ %
201
+ \begin{displaymath}
202
+ v(t) = u\ln \left ( \frac{M_0}{M(t)} \right ) - gt.
203
+ \end{displaymath}
204
+ The exhaust speed is $u$, the initial mass is $M_0$, and the mass
205
+ after time $t$ is $M(t)$. Neglect the dependence of $g$ on height.
206
+
207
+ \item A two-stage rocket accelerates in free space by ejecting fuel at a
208
+ constant relative speed $u$. Three-quarters of its initial mass is
209
+ fuel. It accelerates from rest until $2/3$ of the fuel is burnt. The
210
+ first stage is then detached. Fuel accounts for $4/5$ of the mass of
211
+ the second stage. Show that the final speed of the second stage is
212
+ equal to $u\ln(10)$.
213
+
214
+ Show that a single-stage rocket of the same initial mass, burning
215
+ the same total mass of fuel, would reach a final speed of
216
+ approximately $0.6u\ln(10)$.
217
+
218
+ \end{enumerate}
219
+
220
+
221
+
222
+ %\subsubsection*{Numerical Answers}
223
+ %
224
+ %\begin{list}{}{\setlength{\itemsep}{0em}\setlength{\labelwidth}{6em}}
225
+ %\item[1.] 2.5\,m.
226
+ %\item[2.] (a) 2.4\,kg; (b) $0.4\boldsymbol{\hat{j}}\,$m\udot s$^{-1}$; (c) $(5\boldsymbol{\hat{i}} +
227
+ % \boldsymbol{\hat{j}})\,$m\udot s$^{-1}$; (d) $(12\boldsymbol{\hat{i}} + 2.4\boldsymbol{\hat{j}})\,$kg\udot m\udot
228
+ % s$^{-1}$; (e) 31.2\,J.
229
+ %\end{list}
230
+
231
+ \end{document}
@@ -0,0 +1,567 @@
1
+ \documentclass[12pt]{article}
2
+
3
+ % Mechanics course definitions and macros.
4
+ %\usepackage{mechanics}
5
+ \usepackage{graphicx}
6
+
7
+ % Add space between paragraphs instead of indenting.
8
+ \usepackage{parskip}
9
+
10
+ \addtolength{\topmargin}{-4em}
11
+ \addtolength{\evensidemargin}{-3em}
12
+ \addtolength{\oddsidemargin}{-3em}
13
+ \addtolength{\textheight}{6em}
14
+ \addtolength{\textwidth}{4em}
15
+
16
+ %\usepackage{bm}
17
+ \usepackage{graphics}
18
+ \usepackage{color}
19
+ \usepackage{amsmath}
20
+
21
+ \begin{document}
22
+ \section*{Mechanics Answer Sheet 4}
23
+
24
+ \begin{enumerate}
25
+ \item
26
+ \begin{enumerate}
27
+
28
+ \item Momentum is conserved. Kinetic energy is not conserved. (The
29
+ collision is said to be \textbf{inelastic}.)
30
+
31
+ \item Immediately after the collision, the block and projectile have
32
+ merged into a single object of mass $M+m$ with total momentum $mu$.
33
+ The speed $U$ of the merged block and projectile is given by
34
+ %
35
+ \begin{displaymath}
36
+ (M + m)U = mu \qquad \Rightarrow \qquad U = \frac{mu}{M+m} ,
37
+ \end{displaymath}
38
+ %
39
+ and its kinetic energy $K$ is
40
+ %
41
+ \begin{displaymath}
42
+ K = \frac{1}{2}(M+m)U^2 = \frac{m^2 u^2}{2(M+m)}.
43
+ \end{displaymath}
44
+ %
45
+ At the maximum height $h$, all of this kinetic energy has become
46
+ gravitational potential energy:
47
+ %
48
+ \begin{displaymath}
49
+ (M+m)gh = \frac{m^2 u^2}{2(M+m)}.
50
+ \end{displaymath}
51
+ %
52
+ Hence
53
+ %
54
+ \begin{displaymath}
55
+ h = \frac{m^2 u^2}{2(M+m)^2 g}.
56
+ \end{displaymath}
57
+
58
+ \item The question says that $m = 12\,$g = $0.012\,$kg, $M = 10\,$kg,
59
+ and $h = 10\,$cm $= 0.1\,$m. Rearranging the result of part (b)
60
+ gives
61
+ %
62
+ \begin{displaymath}
63
+ u = \frac{M+m}{m} \sqrt{2gh}
64
+ = \frac{10.012}{0.012} \sqrt{2 \times 9.8 \times 0.1} \approx
65
+ 1168 \, \text{m}\cdot\text{s}^{-1} \approx 1.17\,\text{km}\cdot\text{s}^{-1}.
66
+ \end{displaymath}
67
+
68
+ \end{enumerate}
69
+
70
+ \item Suppose the woman of mass $60\,$kg starts at the origin
71
+ ($X_{\text{woman}} = 0$) standing on the left-hand end of the plank.
72
+ The centre of mass of the $10\,$m long plank of mass $20\,$kg is at
73
+ $X_{\text{plank}} = 5\,$m, and the centre of mass of the joint system
74
+ (woman $+$ plank) is at
75
+ \[
76
+ X = \frac{60 \times X_{\text{woman}} + 20 \times X_{\text{plank}}}
77
+ {60 + 20} = 1.25\,\text{m}.
78
+ \]
79
+
80
+ There are no externally applied horizontal forces acting on the woman
81
+ $+$ plank (treated as one system), so the position $X$ of the centre
82
+ of mass cannot change. The diagram below, which pictures the woman and
83
+ plank before and after she walks from one end to the other, shows that
84
+ she moves a total distance of $2X = 2.5\,$m relative to the frozen
85
+ surface of the lake.
86
+
87
+ \item
88
+ \begin{enumerate}
89
+
90
+ \item Using the formula
91
+ $\displaystyle \frac{1}{\mu} = \frac{1}{m_1} + \frac{1}{m_2}$ gives
92
+ $\mu = 2.4\,$kg.
93
+
94
+ \item Differentiating the definition of the centre of mass,
95
+ %
96
+ \begin{displaymath}
97
+ \vec{\boldsymbol{R}} = \frac{m_1 \vec{\boldsymbol{r}}_1 + m_2 \vec{\boldsymbol{r}}_2}{m_1 + m_2} ,
98
+ \end{displaymath}
99
+ %
100
+ gives a formula for the velocity of the centre of mass:
101
+ %
102
+ \begin{displaymath}
103
+ \dot{\vec{\boldsymbol{R}}} = \frac{m_1 \vec{\boldsymbol{v}}_1 + m_2 \vec{\boldsymbol{v}}_2}{m_1 + m_2}.
104
+ \end{displaymath}
105
+ %
106
+ We are told that $\vec{\boldsymbol{r}}_1 = (1 + 3t)\boldsymbol{\hat{i}} + t\boldsymbol{\hat{j}}$ and
107
+ $\vec{\boldsymbol{r}}_2 = -2t\boldsymbol{\hat{i}} + 5\boldsymbol{\hat{j}}$, so $\vec{\boldsymbol{v}}_1 = \dot{\vec{\boldsymbol{r}}}_1 = 3\boldsymbol{\hat{i}} + \boldsymbol{\hat{j}}$ and
108
+ $\vec{\boldsymbol{v}}_2 = \dot{\vec{\boldsymbol{r}}}_2 = -2\boldsymbol{\hat{i}}$. Hence
109
+ \begin{displaymath}
110
+ \dot{\vec{\boldsymbol{R}}} = \frac{4(3\boldsymbol{\hat{i}} + \boldsymbol{\hat{j}}) + 6(-2\boldsymbol{\hat{i}})}{4 + 6} = 0.4\boldsymbol{\hat{j}}
111
+ \;\text{m}\cdot\text{s}^{-1}.
112
+ \end{displaymath}
113
+
114
+ \item The velocity of $m_1$ relative to $m_2$ is
115
+ \begin{displaymath}
116
+ \vec{\boldsymbol{v}}_1 - \vec{\boldsymbol{v}}_2 = (3\boldsymbol{\hat{i}} + \boldsymbol{\hat{j}}) - (-2\boldsymbol{\hat{i}}) = (5\boldsymbol{\hat{i}} + \boldsymbol{\hat{j}})\,\text{m}\cdot\text{s}^{-1}.
117
+ \end{displaymath}
118
+
119
+ \item The momentum of $m_1$ in the centre-of-mass frame is
120
+ \begin{displaymath}
121
+ \vec{\boldsymbol{p}}_1^{\ast} = m_1(\vec{\boldsymbol{v}}_1 - \dot{\vec{\boldsymbol{R}}}) = 4(3\boldsymbol{\hat{i}} + 0.6\boldsymbol{\hat{j}})
122
+ = (12\boldsymbol{\hat{i}} + 2.4\boldsymbol{\hat{j}}) \, \text{kg}\cdot\text{m}\cdot\text{s}^{-1}.
123
+ \end{displaymath}
124
+
125
+ \item The velocities of the two particles in the centre-of-mass frame
126
+ are:
127
+ \begin{align*}
128
+ \vec{\boldsymbol{v}}_1^{\ast} &= \vec{\boldsymbol{v}}_1 - \dot{\vec{\boldsymbol{R}}} = (3\boldsymbol{\hat{i}} +
129
+ 0.6\boldsymbol{\hat{j}})\,\text{m}\cdot\text{s}^{-1}, \\
130
+ \vec{\boldsymbol{v}}_2^{\ast} &= \vec{\boldsymbol{v}}_2 - \dot{\vec{\boldsymbol{R}}} = (-2\boldsymbol{\hat{i}} -
131
+ 0.4\boldsymbol{\hat{j}})\,\text{m}\cdot\text{s}^{-1}.
132
+ \end{align*}
133
+ %
134
+ Their kinetic energies are
135
+ %
136
+ \begin{align*}
137
+ \frac{1}{2}m_1 (v_1^{\ast})^2 &= \frac{1}{2} 4 \left ( 3^2 +
138
+ (0.6)^2 \right ) =
139
+ 18.72\,\text{J}, \\
140
+ \frac{1}{2}m_2 (v_2^{\ast})^2 &= \frac{1}{2} 6 \left ( 2^2 +
141
+ (0.4)^2 \right ) =
142
+ 12.48\,\text{J}.
143
+ \end{align*}
144
+ %
145
+ The total kinetic energy in the centre-of-mass frame is $31.2\,$J.
146
+
147
+ \end{enumerate}
148
+
149
+ \item As in the answer to Q2(b), the velocity of the centre of mass can
150
+ be found by differentiating the equation for $\vec{\boldsymbol{R}}(t)$:
151
+ %
152
+ \begin{displaymath}
153
+ \dot{\vec{\boldsymbol{R}}} = \frac{d}{dt} \left (
154
+ \frac{\sum_{i=1}^{N} m_i \vec{\boldsymbol{r}}_i}{\sum_{i=1}^{N} m_i}
155
+ \right ) = \frac{\sum_{i=1}^{N} m_i \vec{\boldsymbol{v}}_i}{\sum_{i=1}^{N} m_i}
156
+ = \frac{\sum_{i=1}^{N} m_i \vec{\boldsymbol{v}}_i}{M}
157
+ \end{displaymath}
158
+ %
159
+ where $M \equiv \sum_{i=1}^{N} m_i$. Since the velocity
160
+ $\vec{\boldsymbol{v}}_i^{\ast}$ of mass $m_i$ in the centre-of-mass frame is given by
161
+ $\vec{\boldsymbol{v}}_i - \dot{\vec{\boldsymbol{R}}}$, its momentum
162
+ $\vec{\boldsymbol{p}}_i^{\ast} = m_i(\vec{\boldsymbol{v}}_i - \dot{\vec{\boldsymbol{R}}})$. The total momentum in the
163
+ centre-of-mass frame is
164
+ %
165
+ \begin{align*}
166
+ \sum_{i=1}^{N} \vec{\boldsymbol{p}}_i^{\ast}
167
+ &= \sum_{i=1}^{N} m_i (\vec{\boldsymbol{v}}_i - \dot{\vec{\boldsymbol{R}}} ) \\
168
+ &= \sum_{i=1}^{N} m_i \vec{\boldsymbol{v}}_i - \dot{\vec{\boldsymbol{R}}} \sum_{i=1}^{N} m_i \\
169
+ &= M \left ( \frac{\sum_{i=1}^{N} m_i \vec{\boldsymbol{v}}_i}{M} - \dot{\vec{\boldsymbol{R}}}
170
+ \right ) \\
171
+ &= 0. \qquad\qquad
172
+ \text{(Note that this is a zero \underline{vector}.)}
173
+ \end{align*}
174
+ %
175
+ The final step used the equation for $\dot{\vec{\boldsymbol{r}}}$ above.
176
+
177
+ \item The total laboratory-frame kinetic energy of the $N$ particles
178
+ (masses $m_i$, velocities $\vec{\boldsymbol{v}}_i$) is
179
+ %
180
+ \begin{displaymath}
181
+ K = \sum_{i=1}^{N} \frac{1}{2} m_i v_i^2 .
182
+ \end{displaymath}
183
+ %
184
+ The laboratory (unstarred) and centre-of-mass (starred) velocities of
185
+ the particles are related by $\vec{\boldsymbol{v}}_i^{\phantom{}} = \vec{\boldsymbol{v}}_i^{\ast} +
186
+ \dot{\vec{\boldsymbol{R}}}$, where
187
+ %
188
+ \begin{displaymath}
189
+ \dot{\vec{\boldsymbol{R}}} = \frac{\sum_{i=1}^{N} m_i \vec{\boldsymbol{v}}_i}{\sum_{i=1}^{N} m_i}
190
+ \end{displaymath}
191
+ %
192
+ is the velocity of the centre of mass. Hence
193
+ %
194
+ \begin{align*}
195
+ K &= \frac{1}{2} \sum_{i=1}^{N} m_i^{\phantom{}}
196
+ \left ( \vec{\boldsymbol{v}}_i^{\ast} + \dot{\vec{\boldsymbol{R}}} \right )^2 \\
197
+ &= \frac{1}{2} \sum_{i=1}^{N} m_i^{\phantom{}} \left [
198
+ \left ( v_i^{\ast} \right)^2 +
199
+ 2 (\vec{\boldsymbol{v}}_i^{\ast}\cdot \dot{\vec{\boldsymbol{R}}}) + \dot{R}^2 \right ] \\
200
+ &= \frac{1}{2} \sum_{i=1}^{N} m_i^{\phantom{}}
201
+ \left ( v_i^{\ast}\right )^2
202
+ + \left ( \sum_{i=1}^{N} m_i^{\phantom{}} \vec{\boldsymbol{v}}_i^{\ast} \right )
203
+ \cdot \dot{\vec{\boldsymbol{R}}}
204
+ + \frac{1}{2} \left ( \sum_{i=1}^{N} m_i^{\phantom{}} \right )
205
+ \dot{R}^2 \\
206
+ &= \frac{1}{2}\sum_{i=1}^{N} m_i^{\phantom{}}
207
+ \left ( v_i^{\ast} \right )^2 + \frac{1}{2} M \dot{R}^2
208
+ \qquad (\text{where } M \equiv \sum_{i=1}^{N} m_i^{\phantom{}}) \\
209
+ &= K^{\ast} + \frac{1}{2} M \dot{R}^2 \\
210
+ &= \text{(KE in centre-of-mass frame)} + \text{(KE of centre of mass)}.
211
+ \end{align*}
212
+ %
213
+ The cross term vanished because $\sum_{i=1}^{N} m_i^{\phantom{}}
214
+ \vec{\boldsymbol{v}}_i^{\ast}$ is the total momentum in the centre-of-mass frame, which
215
+ Q2 showed is always zero.
216
+
217
+ \item Start by writing down the definition of the coefficient of
218
+ restitution and the law of conservation of momentum in the case when
219
+ $u_2 = 0$:
220
+ %
221
+ \begin{align*}
222
+ v_2 - v_1 &= eu_1 ,\\
223
+ m_1 v_1 + m_2 v_2 &= m_1 u_1 .
224
+ \end{align*}
225
+ %
226
+ Our job is to solve for $v_1$ and $v_2$ as functions of $u_1$. One way
227
+ is to multiply the first equation by $m_1$,
228
+ %
229
+ \begin{displaymath}
230
+ m_1 v_2 - m_1 v_1 = e m_1 u_1,
231
+ \end{displaymath}
232
+ %
233
+ and add it to the second equation to obtain
234
+ %
235
+ \begin{displaymath}
236
+ m_2 v_2 + m_1 v_2 = m_1 u_1 + e m_1 u_1 ,
237
+ \end{displaymath}
238
+ %
239
+ which rearranges to give
240
+ %
241
+ \begin{displaymath}
242
+ v_2 = \frac{(1 + e)m_1 u_1}{m_1 + m_2}.
243
+ \end{displaymath}
244
+ %
245
+ Plugging this back into $v_1 - v_2 = -eu_1$ yields
246
+ %
247
+ \begin{displaymath}
248
+ v_1 = v_2 - eu_1 = \frac{(1+e)m_1 u_1}{m_1 + m_2} - \frac{e(m_1 +
249
+ m_2)u_1}{m_1 + m_2} = \frac{(m_1 - e m_2)u_1}{m_1 + m_2}.
250
+ \end{displaymath}
251
+
252
+
253
+ \item Options (a) and (g) are true.
254
+
255
+ The ping-pong ball of mass $m$ is so much lighter than the basketball
256
+ of mass $M$ that its momentum almost reverses when it collides:
257
+ $m\vec{\boldsymbol{u}}_m \rightarrow -m\vec{\boldsymbol{u}}_m$. Since the total momentum $m\vec{\boldsymbol{u}}_m$ is
258
+ conserved, the momentum of the basketball after the collision must be
259
+ approximately $2m\vec{\boldsymbol{u}}_m$. The absolute value of the momentum of the
260
+ basketball after the collision is larger than that of the ping-pong
261
+ ball.
262
+
263
+ The momentum of the basketball after the collision is approximately
264
+ $2m\vec{\boldsymbol{u}}_m$, so its velocity $\vec{\boldsymbol{v}}_M \approx \frac{2m}{M} \vec{\boldsymbol{u}}_m$. The
265
+ final kinetic energies of the basketball and ping-pong ball are:
266
+ %
267
+ \begin{align*}
268
+ K_M
269
+ &= \frac{1}{2}M |\vec{\boldsymbol{v}}_M|^2 \approx \frac{1}{2} M
270
+ \left |\frac{2m\vec{\boldsymbol{u}}_m}{M}\right |^2 = \frac{2m^2}{M}
271
+ |\vec{\boldsymbol{u}}_m|^2 ,\\
272
+ K_m
273
+ &\approx \frac{1}{2} m |-\vec{\boldsymbol{u}}_m|^2 .
274
+ \end{align*}
275
+ %
276
+ The ratio $K_m/K_M = M/(4m)$ is much bigger than 1 (the mass of one
277
+ basketball is much larger than the mass of four ping-pong balls), so
278
+ the ping-pong ball has much more kinetic energy than the basketball.
279
+
280
+ \item
281
+ \begin{enumerate}
282
+
283
+ \item The total momentum before the collision that forms the
284
+ complex is
285
+ \begin{displaymath}
286
+ p_{\text{tot}} = m_{\text{NO}} u_{\text{NO}} + m_{\text{O}_3}
287
+ u_{\text{O}_3} = (14 + 16)m_u u_{\text{NO}} + (3\times 16)m_u u_{\text{O}_3},
288
+ \end{displaymath}
289
+ where $m_u \approx 1.66 \times 10^{-27}\,$kg is the atomic mass
290
+ unit. Setting the value of $u_{\text{NO}}$ to $-550\,$m$\cdot$
291
+ s$^{-1}$ and $u_{\text{O}_3} = +550\,$m$\cdot$s$^{-1}$ gives
292
+ %
293
+ \begin{displaymath}
294
+ p_{\text{tot}} \approx 1.64 \times 10^{-23}\,\text{kg}\cdot\text{m}\cdot\text{s}^{-1}.
295
+ \end{displaymath}
296
+
297
+ The total momentum is conserved during the collision in which
298
+ the two molecules bind to form the [NO--O$_3$]$^{\ast}$ complex,
299
+ so
300
+ %
301
+ \begin{displaymath}
302
+ p_{\text{[NO--O$_3$]}^{\ast}} \approx 1.64 \times
303
+ 10^{-23}\,\text{kg}\cdot\text{m}\cdot\text{s}^{-1}
304
+ \end{displaymath}
305
+ %
306
+ and the velocity of the complex is
307
+ %
308
+ \begin{displaymath}
309
+ v_{\text{[NO--O$_3$]}^{\ast}} \approx \frac{1.64 \times
310
+ 10^{-23}}{[(14 + 16) + (3 \times 16)] m_u} \approx
311
+ 127\,\text{m}\cdot\text{s}^{-1}.
312
+ \end{displaymath}
313
+
314
+ \item The total kinetic energy before the collision is
315
+ %
316
+ \[
317
+ K = \frac{1}{2} m^{}_{\text{NO}}v_{\text{NO}}^2 + \frac{1}{2}
318
+ m^{}_{\text{O}_3} v_{\text{O}_3}^2
319
+ = \frac{1}{2} [ (14 + 16) + (3 \times 16) ] m_u (550)^2
320
+ \approx 1.96\times 10^{-20}\,\text{J}.
321
+ \]
322
+
323
+ The total kinetic energy after the collision is
324
+ %
325
+ \[
326
+ K' = \frac{1}{2} m^{}_{\text{[NO--O$_3$]}^{\ast}} \,
327
+ v_{\text{[NO--O$_{3}$]}^{\ast}}^2 \\
328
+ = \frac{1}{2} (78 m_u) (127)^2 \\
329
+ \approx 1.04 \times 10^{-21}\,\text{J}.
330
+ \]
331
+
332
+ The total KE has reduced so the collision was inelastic.
333
+
334
+ The KE lost has gone into the internal energy of the activated
335
+ complex, which has higher chemical energy than the two molecules
336
+ of which it is formed (it is only metastable) plus internal
337
+ vibrational and rotational energy.
338
+
339
+ \item The collision will only form the products if the internal energy
340
+ of the complex exceeds the activation barrier. The internal
341
+ energy is
342
+ %
343
+ \begin{displaymath}
344
+ E^{\text{internal}}_{[\text{NO--O}_3]^{\ast}} = K - K' \approx
345
+ 1.96 \times 10^{-20} - 1.04 \times 10^{-21}
346
+ \approx 1.85 \times 10^{-20}\,\text{J}.
347
+ \end{displaymath}
348
+ %
349
+ An activation barrier of of $9.6\,\text{kJ}\cdot\text{mol}^{-1}$
350
+ translates into
351
+ %
352
+ \begin{displaymath}
353
+ \frac{9.6 \times 10^3}{6.022 \times 10^{23}} \approx 1.59 \times
354
+ 10^{-20} \, \text{J per complex}.
355
+ \end{displaymath}
356
+ %
357
+ This is less than the internal energy provided by the collision,
358
+ so the NO$_2$ and O$_2$ products will be formed (some of the
359
+ time, at least).
360
+
361
+ \item Set the potential energy of interaction to zero when the two
362
+ oxygen atoms are far apart. Since the atoms are approaching each
363
+ other, they already have some kinetic energy even before the
364
+ attractive part of the interaction starts accelerating them
365
+ towards each other. This means that their total energy $E$ is
366
+ greater than zero. If we choose to work in the centre-of-mass
367
+ frame, the total momentum is zero and the two oxygen atoms
368
+ approach each other with equal and opposite momentum.
369
+
370
+ Momentum and total energy are conserved, so the O$_2$ molecule
371
+ must have zero total momentum but positive total energy $E$. If
372
+ the molecule is to form, the kinetic energy of the molecules
373
+ arriving at their equilibrium spacing (the difference between
374
+ $E$ and the minimum value of $U(r)$) must be transferred into
375
+ internal vibrational, rotational and electronic degrees freedom
376
+ of the O$_2$ molecule.
377
+
378
+ Since the total energy of the molecule is greater than zero, it
379
+ is large enough to provide the two O atoms with enough kinetic
380
+ energy to unbind and escape to infinity. Unless some other
381
+ nearby atom or molecule takes away the excess energy before it
382
+ is too late, the highly-excited oxygen molecule will soon break
383
+ up.
384
+
385
+ \begin{center}
386
+ \includegraphics[width=0.55\textwidth]{figures/O2_potential.png}
387
+ \end{center}
388
+
389
+ The figure above illustrates the situation. It shows the
390
+ potential energy $U(r)$ of the two O atoms as a function of
391
+ their separation $r$ (compare with Q5 of the Mechanics part of
392
+ the week 6 problem sheet). The total energy $E$, indicated by
393
+ the dashed red line, is greater than zero. The total kinetic
394
+ energy at separation $r$, indicated by the green arrow, is $E -
395
+ U(r)$. Because $E > 0$, the two escaping atoms will keep moving
396
+ away from each other even as $r \rightarrow \infty$.
397
+
398
+ \end{enumerate}
399
+
400
+ \begin{enumerate}
401
+
402
+ \item Using conservation of energy, the speed $v_0$ of the ball when
403
+ it first hits the ground is related to the initial height $h_0$ by
404
+ $mgh_0 = \frac{1}{2}mv_0^2$. This gives
405
+ %
406
+ \begin{displaymath}
407
+ v_0 = \sqrt{2gh_0}.
408
+ \end{displaymath}
409
+ %
410
+ (Could also have used the SUVAT equation $v^2 = u^2 + 2as$.) Since
411
+ $v_0 = g t_0$,
412
+ %
413
+ \begin{displaymath}
414
+ t_0 = \sqrt{\frac{2h_0}{g}}.
415
+ \end{displaymath}
416
+
417
+ \item The upward speed after the first bounce is $v_1 = ev_0$. The
418
+ height reached after the first bounce is
419
+ %
420
+ \begin{displaymath}
421
+ h_1 = \frac{v_1^2}{2g} = \frac{e^2 v_0^2}{2g}
422
+ = e^2 h_0.
423
+ \end{displaymath}
424
+ %
425
+ The time taken to reach the top of the first bounce is
426
+ %
427
+ \begin{displaymath}
428
+ t_1 = \sqrt{\frac{2h_1}{g}} = et_0.
429
+ \end{displaymath}
430
+ %
431
+ The height $h_n$ and drop time $t_n$ for the $n^{\text{th}}$ bounce
432
+ are
433
+ %
434
+ \begin{displaymath}
435
+ h_n = e^{2n} h_0, \qquad t_n = e^n t_0.
436
+ \end{displaymath}
437
+
438
+ \item The initial drop takes time $t_0$. The duration of the
439
+ $n^{\text{th}}$ bounce is $2t_n$, not $t_n$, because the ball has to
440
+ rise and then drop again. The total time $T$ for the ball to stop
441
+ bouncing is the sum of the durations of the initial drop and all
442
+ subsequent bounces:
443
+ %
444
+ \begin{align*}
445
+ T &= t_0 + 2 e t_0 + 2 e^2 t_0 + 2 e^3 t_0 + \ldots \\
446
+ &= 2 t_0 (1 + e + e^2 + e^3 + \ldots) - t_0 \\
447
+ &= \frac{2 t_0}{1 - e} - t_0
448
+ \qquad \text{(using the formula given in the question)}\\
449
+ &= \frac{1 + e}{1 - e} \, t_0.
450
+ \end{align*}
451
+
452
+ If $h_0 = 5\,$m, $e = 0.5$, and $g = 10\,\text{m}\cdot\text{s}^{-2}$,
453
+ then
454
+ %
455
+ \begin{displaymath}
456
+ t_0 = \sqrt{\frac{2 \times 5}{10}} = 1\,\text{s},
457
+ \end{displaymath}
458
+ %
459
+ and the time $T$ taken to stop bouncing is
460
+ %
461
+ \begin{displaymath}
462
+ T = \frac{1 + 0.5}{1 - 0.5} \, t_0 = 3\,\text{s}.
463
+ \end{displaymath}
464
+
465
+ \end{enumerate}
466
+
467
+ \item The diagram below shows that the change in momentum of the
468
+ rocket+fuel in time $dt$ can be found as follows:
469
+ %
470
+ \begin{align*}
471
+ \text{change in momentum}
472
+ &= \text{(momentum at time $t + dt$)} - \text{(momentum at time $t$)} \\
473
+ &=\big( (M + dM)(v + dv) + (-dM)(v-u) \big) - \big( Mv \big)\\
474
+ &= M dv + u dM . \qquad \text{(ignoring second-order terms)}
475
+ \end{align*}
476
+
477
+ \begin{center}
478
+ \includegraphics[width=0.45\textwidth]{figures/rocket-momentum.png}
479
+ \end{center}
480
+
481
+ Since the only external force acting on the system is gravity, this
482
+ must be equal to the gravitational impulse $-Mg\,dt$ (which is negative
483
+ because gravity acts against the rocket's acceleration):
484
+ %
485
+ \begin{align*}
486
+ &M dv + u dM = -Mg \, dt \\
487
+ \Rightarrow \qquad
488
+ &dv = -u\frac{dM}{M} - g \, dt \\
489
+ \Rightarrow \qquad
490
+ &\int_{0}^{v(t)} dv' = -u \int_{M_0}^{M(t)} \frac{dM'}{M'} -
491
+ g\int_0^{t} dt' \\
492
+ \Rightarrow \qquad
493
+ &\left [ v' \right ]_0^{v(t)} = -u \left [ \ln M' \right
494
+ ]_{M_0}^{M(t)} - g \left [ t' \right ]_0^{t} \\
495
+ \Rightarrow \qquad
496
+ &v(t) = -u \left \{ \ln(M(t)) - \ln(M_0) \right \} - gt \\
497
+ \Rightarrow \qquad
498
+ &v(t) = u\ln\left ( \frac{M_0}{M(t)} \right ) - gt,
499
+ \end{align*}
500
+ as required.
501
+
502
+ \item The free-space rocket equation is
503
+ %
504
+ \begin{displaymath}
505
+ v(t) = v_0 + u \ln \left ( \frac{M_0}{M(t)} \right ),
506
+ \end{displaymath}
507
+ %
508
+ where $v_0$ is the initial speed of the rocket, $u$ is the exhaust
509
+ speed, $M_0$ is the rocket's initial mass (including any fuel it is
510
+ carrying), and $M(t)$ is its mass at time $t$ (including any fuel not
511
+ yet burnt).
512
+
513
+ For the first stage of the journey, call the initial mass
514
+ $M_1^{\text{init}}$. The initial speed is zero. The initial mass of
515
+ fuel is $3M_1^{\text{init}}/4$, but only $2/3$ of this is burnt during
516
+ stage 1. The mass $M_1^{\text{final}}$ of the rocket and remaining
517
+ fuel at the end of stage 1 is therefore
518
+ $M_1^{\text{init}} - (2/3)(3M_1^{\text{init}}/4) =
519
+ M_1^{\text{init}}/2$. We can now work out the speed $v_1$ at the end
520
+ of stage 1:
521
+ %
522
+ \begin{displaymath}
523
+ v_1 = u \ln \left ( \frac{M_1^{\text{init}}}{M_1^{\text{final}}} \right )
524
+ = u\ln \left ( \frac{M_1^{\text{init}}}{M_1^{\text{init}}/2} \right ) = u\ln 2.
525
+ \end{displaymath}
526
+
527
+ Once the first stage of the rocket has detached, the remaining mass of
528
+ fuel, which we know is equal to
529
+ $(1/3)(3M_1^{\text{init}}/4) = M_1^{\text{init}}/4$, accounts for
530
+ $4/5$ of the mass of the rocket. This tells us the initial mass
531
+ of stage 2:
532
+ %
533
+ \begin{displaymath}
534
+ M_2^{\text{init}} = (5/4)(M_1^{\text{init}}/4) =
535
+ 5M_1^{\text{init}}/16.
536
+ \end{displaymath}
537
+ %
538
+ At the end of stage 2, the fuel has all been burnt, so
539
+ $M_2^{\text{final}} = M_2^{\text{init}} - M_1^{\text{init}}/4 =
540
+ M_1^{\text{init}}/16$. The velocity $v_2$ at the end of stage 2 is
541
+ %
542
+ \begin{align*}
543
+ v_2 &= v_1 + u \ln \left (
544
+ \frac{M_2^{\text{init}}}{M_2^{\text{final}}} \right )
545
+ = u\ln 2 + u\ln \left
546
+ ( \frac{5M_1^{\text{init}}/16}{M_1^{\text{init}}/16} \right ) \\
547
+ &= u\ln 2 + u\ln 5 = u\ln 10.
548
+ \end{align*}
549
+
550
+ Suppose we had instead made the journey with a single-stage rocket of
551
+ initial mass $M_1^{\text{init}}$ and the same initial mass of fuel,
552
+ $3M_{1}^{\text{init}}/4$. At the end of the single stage, all of the
553
+ fuel has been burnt, so the final mass is
554
+ $M_1^{\text{init}} - 3M_{1}^{\text{init}}/4 = M_1^{\text{init}}/4$.
555
+ The final speed $v_1'$ is given by
556
+ %
557
+ \begin{align*}
558
+ v_1' = u\ln\left ( \frac{M_1^{\text{init}}}{M_1^{\text{init}}/4}
559
+ \right ) = u\ln 4,
560
+ \end{align*}
561
+ %
562
+ which is approximately $0.6u\ln(10)$.
563
+
564
+ \end{enumerate}
565
+
566
+
567
+ \end{document}
@@ -72,7 +72,9 @@ def pandoc_filter(
72
72
  # Add each part solution/text
73
73
  # For the solution, prepend any top level answer text to each part answer
74
74
  for part in lettered_parts:
75
- module.current_question.add_solution(
76
- spaced_blurb + part
77
- ) if parsing_answers else module.current_question.add_part_text(part)
75
+ (
76
+ module.current_question.add_solution(spaced_blurb + part)
77
+ if parsing_answers
78
+ else module.current_question.add_part_text(part)
79
+ )
78
80
  return None
@@ -120,7 +120,10 @@ def filter(
120
120
  [pf.Element, pf.elements.Doc, Module, bool],
121
121
  Optional[pf.Str],
122
122
  ]
123
- ) -> Callable[[pf.Element, pf.elements.Doc, Module, str, bool], Optional[pf.Str],]:
123
+ ) -> Callable[
124
+ [pf.Element, pf.elements.Doc, Module, str, bool],
125
+ Optional[pf.Str],
126
+ ]:
124
127
  """Python decorator to make generic LaTeX elements markdown readable.
125
128
 
126
129
  As an example, part of the process involves putting dollar signs around maths
@@ -18,7 +18,7 @@ def converter(
18
18
  """Turns a list of question objects into Lambda Feedback JSON.
19
19
 
20
20
  Args:
21
- template: The loaded JSON from the minimal template.
21
+ template: The loaded JSON from the minimal template (it needs to be in sync).
22
22
  ListQuestions: A list of question objects.
23
23
  output_dir: The absolute path for where to produced the final JSON/zip files.
24
24
  """
@@ -50,7 +50,7 @@ def converter(
50
50
  )
51
51
 
52
52
  # Output file
53
- filename = "Question " + str(i + 1)
53
+ filename = "question_" + str(i + 1)
54
54
 
55
55
  # create directory to put the questions
56
56
  os.makedirs(output_dir, exist_ok=True)
@@ -1,5 +1,4 @@
1
1
  {
2
- "isPublished": false,
3
2
  "masterContent": "Top level question here",
4
3
  "parts": [
5
4
  {
@@ -17,6 +16,7 @@
17
16
  ]
18
17
  }
19
18
  ],
19
+ "publish": false,
20
20
  "questionSettings": {
21
21
  "displayFinalAnswer": true,
22
22
  "displayStructuredTutorial": true,
@@ -9,7 +9,6 @@ import rich_click as click
9
9
 
10
10
  import in2lambda.filters
11
11
  from in2lambda.api.module import Module
12
- from in2lambda.json_convert import json_convert
13
12
 
14
13
 
15
14
  def file_type(file: str) -> str:
@@ -40,7 +39,17 @@ def file_type(file: str) -> str:
40
39
  match (extension := file.split(".")[-1].lower()):
41
40
  case "tex" | "latex" | "ltx":
42
41
  return "latex"
43
- case "md" | "rmd" | "markdown" | "mdown" | "mdwn" | "mkd" | "mkdn" | "text" | "txt":
42
+ case (
43
+ "md"
44
+ | "rmd"
45
+ | "markdown"
46
+ | "mdown"
47
+ | "mdwn"
48
+ | "mkd"
49
+ | "mkdn"
50
+ | "text"
51
+ | "txt"
52
+ ):
44
53
  return "markdown"
45
54
  case "docx":
46
55
  return "docx" # Pandoc doesn't seem to support doc
@@ -71,9 +80,9 @@ def runner(
71
80
  >>> from in2lambda.main import runner
72
81
  >>> # Retrieve an example TeX file and run the given filter.
73
82
  >>> runner(f"{os.path.dirname(in2lambda.__file__)}/filters/PartsSepSol/example.tex", "PartsSepSol") # doctest: +ELLIPSIS
74
- Module(questions=[Question(title='', parts=[Part(text=..., worked_solution=''), ...], images=[], _main_text='This is a sample question\n\n'), ...])
83
+ Module(questions=[Question(title='', parts=[Part(text=..., worked_solution=''), ...], images=[], main_text='This is a sample question\n\n'), ...])
75
84
  >>> runner(f"{os.path.dirname(in2lambda.__file__)}/filters/PartsOneSol/example.tex", "PartsOneSol") # doctest: +ELLIPSIS
76
- Module(questions=[Question(title='', parts=[Part(text='This is part (a)\n\n', worked_solution=''), ...], images=[], _main_text='Here is some preliminary question information that might be useful.'), ...)
85
+ Module(questions=[Question(title='', parts=[Part(text='This is part (a)\n\n', worked_solution=''), ...], images=[], main_text='Here is some preliminary question information that might be useful.'), ...)
77
86
  """
78
87
  # The list of questions for Lambda Feedback as a Python API.
79
88
  module = Module()
@@ -112,7 +121,7 @@ def runner(
112
121
 
113
122
  # Read the Python API format and convert to JSON.
114
123
  if output_dir is not None:
115
- json_convert.main(module.questions, output_dir)
124
+ module.to_json(output_dir)
116
125
 
117
126
  return module
118
127
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "in2lambda"
3
- version = "0.3.0"
3
+ version = "0.3.2"
4
4
  description = "Converts content ready for import into Lambda Feedback"
5
5
  authors = []
6
6
  license = "MIT"
@@ -23,25 +23,25 @@ documentation = "https://lambda-feedback.github.io/in2lambda"
23
23
 
24
24
  [tool.poetry.dependencies]
25
25
  python = "^3.10"
26
- panflute = "^2.3.0"
27
- rich-click = "^1.7.2"
28
- beartype = "^0.16.4"
26
+ panflute = "^2.3.1"
27
+ rich-click = "^1.7.4"
28
+ beartype = "^0.17.2"
29
29
 
30
30
  [tool.poetry.scripts]
31
31
  in2lambda = "in2lambda.main:cli"
32
32
 
33
33
  [tool.poetry.group.dev.dependencies]
34
- black = "^23.12.0"
34
+ black = "^24.3.0"
35
35
  isort = "^5.13.2"
36
36
  pydocstyle = "^6.3.0"
37
- mypy = "^1.7.1"
38
- pytest = "^7.4.3"
37
+ mypy = "^1.9.0"
38
+ pytest = "^8.1.1"
39
39
  pytest-cov = "^4.1.0"
40
- pytest-sugar = "^0.9.7"
41
- pre-commit = "^3.6.0"
40
+ pytest-sugar = "^1.0.0"
41
+ pre-commit = "^3.6.2"
42
42
 
43
43
  [tool.poetry.group.docs.dependencies]
44
- furo = "^2023.9.10"
44
+ furo = "^2024.1.29"
45
45
  myst-parser = "^2.0.0"
46
46
  sphinx = "^7.2.6"
47
47
  sphinx-copybutton = "^0.5.2"
File without changes
File without changes
File without changes