Certainly! Below is a Python script using Manim (a mathematical animation engine) that illustrates some basic thermodynamics concepts with clear, non-overlapping text and objects. Each scene is properly cleaned up before transitioning.
Make sure you have Manim installed (pip install manim) before running this code. The animation progresses through several key thermodynamics ideas without any overlap.
from manim import *
class Thermodynamics(Scene):
def construct(self):
# Scene 1: Title
title = Text("Thermodynamics", font_size=72)
self.play(Write(title))
self.wait(2)
self.play(FadeOut(title))
self.wait(0.5)
# Scene 2: Definition of Thermodynamics
definition = Text(
"Thermodynamics: \n"
"Study of energy, heat, work, \n"
"and their transformations.",
font_size=48,
t2c={"Thermodynamics:": YELLOW}
)
self.play(Write(definition))
self.wait(3)
self.play(FadeOut(definition))
self.wait(0.5)
# Scene 3: Zeroth Law
zeroth_title = Text("Zeroth Law of Thermodynamics", font_size=54, color=BLUE)
zeroth_law = Text(
"If two systems are each in thermal equilibrium \n"
"with a third system, then they are in thermal \n"
"equilibrium with each other.",
font_size=36,
).next_to(zeroth_title, DOWN, buff=0.5)
# Arrange to avoid overlap
self.play(Write(zeroth_title))
self.play(FadeIn(zeroth_law))
self.wait(4)
self.play(FadeOut(zeroth_title), FadeOut(zeroth_law))
self.wait(0.5)
# Scene 4: First Law
first_title = Text("First Law of Thermodynamics", font_size=54, color=GREEN)
# Display the formula and explanation side by side
formula = MathTex(r"\Delta U = Q - W", font_size=72)
explanation = Tex(
"Change in internal energy (\\(\\Delta U\\)) = Heat added (Q) - Work done (W)",
font_size=36
)
first_title.to_edge(UP)
formula.next_to(first_title, DOWN, buff=1)
explanation.next_to(formula, DOWN, buff=0.5)
self.play(Write(first_title))
self.play(Write(formula))
self.play(Write(explanation))
self.wait(4)
self.play(FadeOut(first_title), FadeOut(formula), FadeOut(explanation))
self.wait(0.5)
# Scene 5: Second Law
second_title = Text("Second Law of Thermodynamics", font_size=54, color=RED)
second_law = Text(
"Entropy of an isolated system \n"
"never decreases; it either increases \n"
"or remains constant.",
font_size=36
).next_to(second_title, DOWN, buff=0.5)
self.play(Write(second_title))
self.play(Write(second_law))
self.wait(4)
self.play(FadeOut(second_title), FadeOut(second_law))
self.wait(0.5)
# Scene 6: Third Law
third_title = Text("Third Law of Thermodynamics", font_size=54, color=PURPLE)
third_law = Text(
"Entropy of a perfect crystal at absolute zero \n"
"is exactly zero.",
font_size=36
).next_to(third_title, DOWN, buff=0.5)
self.play(Write(third_title))
self.play(Write(third_law))
self.wait(4)
self.play(FadeOut(third_title), FadeOut(third_law))
self.wait(0.5)
# Scene 7: Summary
summary = BulletedList(
"Zeroth Law: Thermal equilibrium",
"First Law: Conservation of energy",
"Second Law: Entropy increases",
"Third Law: Entropy zero at 0 K",
font_size=36
)
summary.to_edge(UP)
self.play(Write(Text("Summary", font_size=54, color=TEAL).next_to(summary, UP)))
self.play(Write(summary))
self.wait(5)
# End scene
self.play(FadeOut(summary))
self.wait(1)
How this meets your requirements:
- No overlapping text or objects.
- Each scene clears before the next content appears.
- Uses different colors and sizes to visually separate headings from text.
- Objects are spaced using
.next_to() and to_edge() to handle layout carefully.
You can run this with:
manim -pql your_script.py Thermodynamics
This plays a low quality preview. Change -pql to -pqh or -p for higher quality.
Let me know if you'd like me to add any animations, formulas, or visual diagrams!