manim paraffins conformation
作者:互联网
%%manim -v WARNING -qh s1 class s1(Scene): def construct(self): t1 = Text("链烷烃的构象", font="STZhongsong") self.play(DrawBorderThenFill(t1)) self.play(FadeOut(t1)) pro1 = Text("由于单键可以“自由”旋转", font="STZhongsong").scale(0.8).to_edge(DOWN) pro2 = Text("使分子中的原子或基团在空间产生不同的排列", font="STZhongsong").scale(0.8).to_edge(DOWN) pro3 = Text("这样产生的异构体称为构象异构体", font="STZhongsong").scale(0.8).to_edge(DOWN) g = SVGMobject(r"D:\manimSVG\dwjj.svg").scale(2) self.play(DrawBorderThenFill(pro1), Write(g)) self.play(Succession(Transform(pro1,pro2), Wait(2), Transform(pro1,pro3)), Wait(2), Succession( Rotate(g[-9:-1], angle = 120*DEGREES, about_point = g[-1].get_corner(UR), rate_func=rate_functions.smooth, run_time=2), Rotate(g[0:8], angle = -120*DEGREES, about_point = g[-1].get_corner(DL), rate_func=rate_functions.smooth, run_time=2), Rotate(g[-9:-1], angle = 270*DEGREES, about_point = g[-1].get_corner(UR), rate_func=rate_functions.smooth, run_time=2), )) self.play(FadeOut(pro1, g))
%%manim -v WARNING -qh s2 class s2(Scene): def construct(self): t1 = Text("乙烷", font="STZhongsong") t2 = Text("丙烷", font="STZhongsong") t3 = Text("丁烷", font="STZhongsong") t4 = Text("乙烷衍生物", font="STZhongsong") vg = VGroup(t1,t2,t3,t4).arrange(DOWN, buff=1) # 注意安排位置时考虑好顺序 a1 = MathTex("C_2H_6").scale(0.7).next_to(t1, DOWN) a2 = MathTex("C_3H_8").scale(0.7).next_to(t2, DOWN) a3 = MathTex("C_4H_{10}").scale(0.7).next_to(t3, DOWN) vgall = VGroup(vg,a1,a2,a3) self.play(DrawBorderThenFill(vgall)) self.wait(1) vgtmp = VGroup(t2,t3,t4,a2,a3) self.play(FadeOut(vgtmp)) ethyl = MathTex("CH_3CH_3") vgt = VGroup(t1,a1) vgtcopy = vgt.copy() self.play(Transform(vgt, ethyl)) s0 = SVGMobject(r"D:\manimSVG\ywjj.svg").scale(1.5) s0[6:12].rotate(angle = 180*DEGREES, about_point = s0[-1].get_corner(UR)) s12 = SVGMobject(r"D:\manimSVG\yws1.svg").scale(0.8) s22 = SVGMobject(r"D:\manimSVG\ywnm1.svg").scale(1.2) s11 = SVGMobject(r"D:\manimSVG\yws2.svg").scale(0.8) s21 = SVGMobject(r"D:\manimSVG\ywnm2.svg").scale(1.2) s22copy = s21.copy().shift(4*RIGHT) s21copy = s22.copy().shift(4*RIGHT) vg1 = VGroup(s11, s0, s21).arrange(RIGHT, buff=2) vg2 = VGroup(s12, s0, s22).arrange(RIGHT, buff=2) s00 = s0.copy() s000 = s0.copy() w1 = Text("锯架式", font="STZhongsong").scale(0.5).next_to(s0, DOWN) w2 = Text("伞形式", font="STZhongsong").scale(0.5).next_to(s11, DOWN).set_y(w1.get_y()) w3 = Text("Newman式", font="STZhongsong").scale(0.5).next_to(s21, DOWN).set_y(w1.get_y()) typ2 = Text("重叠型", font="STZhongsong").to_edge(DOWN) typ1 = Text("交叉型", font="STZhongsong").to_edge(DOWN) self.wait(1) self.play(Transform(vgt, s0)) self.play(Write(w1)) self.play(Write(typ1)) self.wait(1) self.play(Transform(s00, s11)) self.play(Write(w2)) self.wait(1) self.play(Transform(s000, s21)) self.play(Write(w3)) self.wait(1) self.play(Rotate(vgt[6:12], angle = 60*DEGREES, about_point = vgt[-1].get_corner(UR), rate_func=rate_functions.smooth)) self.wait(1) self.play(Transform(typ1,typ2)) self.play(Transform(s00, s12)) self.wait(1) self.play(Transform(s000, s22)) self.wait(1) vgg = VGroup(vgt,s000,w1,w2,w3,typ1) self.play(FadeOut(vgg)) self.play(s00.animate.move_to(np.array([0,0,0]))) self.play(s00.animate.scale(1.5)) # 势能曲线 doublearr = DoubleArrow(start=s00[7].get_center() + 0.2*RIGHT, end=s00[9].get_center() + 0.2*LEFT) self.add(s00) self.play(GrowFromPoint(doublearr, doublearr.get_center())) index = MathTex("229pm").next_to(doublearr, UP, buff=0) self.play(GrowFromPoint(index, index.get_center())) t1 = Text("在重叠性构象中", font="STZhongsong").scale(0.6).to_edge(DOWN) t2 = Text("两个氢原子之间的距离约为229pm,而氢原子的范德华半径约为120pm", font="STZhongsong").scale(0.6).to_edge(DOWN) self.play(DrawBorderThenFill(t1)) self.play(Transform(t1,t2)) cir1 = Circle(radius=1.85, color=WHITE).move_to(s00[7].get_center()) cir2 = Circle(radius=1.85, color=WHITE).move_to(s00[9].get_center()) self.play(Write(cir1), Write(cir2)) arr1 = DoubleArrow(start=s00[7].get_center() + 0.05*UP, end=cir1.get_center() + 2*UP) arr2 = DoubleArrow(start=s00[9].get_center() + 0.05*UP, end=cir2.get_center() + 2*UP) index1 = MathTex("120pm").next_to(arr1, RIGHT, buff=0).scale(0.8).shift(0.2*LEFT) index2 = MathTex("120pm").next_to(arr2, RIGHT, buff=0).scale(0.8).shift(0.2*LEFT) self.play(GrowFromPoint(arr1, arr1.get_center()), GrowFromPoint(arr2, arr2.get_center())) self.play(GrowFromPoint(index1, index1.get_center()), GrowFromPoint(index2, index2.get_center())) t2 = Text("120pm+120pm>229pm,因此有排斥力", font="STZhongsong").scale(0.6).to_edge(DOWN) self.play(Transform(t1,t2)) self.wait(1.5) t3 = Text("此时从能量上考虑是不稳定的", font="STZhongsong").scale(0.6).to_edge(DOWN) self.play(Transform(t1,t3)) vv = VGroup(cir1,cir2,index1,index2,doublearr,index,arr1,arr2) self.play(FadeOut(vv)) self.play(s00.animate.scale(0.7)) self.play(s00.animate.shift(4*RIGHT)) ax = Axes( x_range=[0, 130, 60], y_range=[0, 14, 12.1], x_length=0.8*PI, y_length=1, axis_config = {"include_tip": False} ).add_coordinates(font_size=20) labels = ax.get_axis_labels( x_label=Text("旋转角度/(°)", font="STZhongsong").scale(0.25), y_label=Text("势能/(kJ/mol)", font="STZhongsong").scale(0.25) ) graph = ax.plot(lambda x : 12.1*np.cos(PI/60*x), x_range = [0,120], color = BLUE) vgfunc = VGroup(ax,labels,graph).scale(2).shift(2.7*LEFT + UP) self.play(Write(vgfunc[0:2])) self.play(Write(vgfunc[-1])) self.play(Transform(s00, s21copy)) self.play(s00.animate.scale(0.5)) point = ax.c2p(120, 12.1) dot = Dot(point) self.play(GrowFromPoint(dot, dot.get_center()), s00.animate.move_to(dot.get_center() + 0.8*UP), rate_func=rate_functions.smooth) self.wait(1) t4 = Text("而在交叉型构象中,两个氢核之间的距离约为250pm", font="STZhongsong").scale(0.6).to_edge(DOWN) t5 = Text("从能量上看,这种构象是最稳定的", font="STZhongsong").scale(0.6).to_edge(DOWN) self.play(Transform(t1,t4), FadeIn(s22copy)) self.wait(1.5) self.play(Transform(t1,t5)) self.play(s22copy.animate.scale(0.5)) point1 = ax.c2p(60, -12.1) dot1 = Dot(point1) self.play(GrowFromPoint(dot1, dot1.get_center()), s22copy.animate.move_to(dot1.get_center() + 0.8*DOWN), rate_func=rate_functions.smooth) self.play(FadeOut(t1)) vgvg = VGroup(vgfunc, dot, dot1, s00, s22copy) self.play(vgvg.animate.move_to(np.array([0,-0.5,0]))) title = Text("乙烷各种构象的势能关系图", font="STZhongsong").scale(0.8).next_to(vgvg, UP) self.play(DrawBorderThenFill(title)) self.wait(1) vggall = VGroup(vgvg, title) self.play(Transform(vggall, vgtcopy)) self.play(FadeIn(vgtmp)) self.wait(3)
%%manim -v WARNING -qh s3 class s3(Scene): def construct(self): li11 = Text("乙烷", font="STZhongsong") li21 = Text("丙烷", font="STZhongsong") li31 = Text("丁烷", font="STZhongsong") li4 = Text("乙烷衍生物", font="STZhongsong") vgli = VGroup(li11,li21,li31,li4).arrange(DOWN, buff=1) # 注意安排位置时考虑好顺序 li12 = MathTex("C_2H_6").scale(0.7).next_to(li11, DOWN) li22 = MathTex("C_3H_8").scale(0.7).next_to(li21, DOWN) li32 = MathTex("C_4H_{10}").scale(0.7).next_to(li31, DOWN) vgfadeout = VGroup(li11,li12,li31,li32,li4) li2 = VGroup(li21,li22) li2copy = li2.copy() vgallli = VGroup(li11,li12,li21,li22,li31,li32,li4) self.add(vgallli) self.wait(2) self.play(FadeOut(vgfadeout)) li2transmol = MathTex("CH_3CH_2CH_3") self.play(Transform(li2,li2transmol)) self.wait(1) propsaw = SVGMobject(r"D:\manimSVG\prop_saw.svg").scale(1.5) propubl = propsaw.copy() propnm = propsaw.copy() propumbrella1 = SVGMobject(r"D:\manimSVG\prop_umbrella1.svg").scale(0.8) propumbrella2 = SVGMobject(r"D:\manimSVG\prop_umbrella2.svg").scale(0.8) propnewman1 = SVGMobject(r"D:\manimSVG\prop_newman1.svg").scale(1.2) propnewman2 = SVGMobject(r"D:\manimSVG\prop_newman2.svg").scale(1.2) vgprop1 = VGroup(propumbrella1, propsaw, propnewman1).arrange(RIGHT, buff=2) vgprop2 = VGroup(propumbrella2, propsaw, propnewman2).arrange(RIGHT, buff=2) notesaw = Text("锯架式", font="STZhongsong").scale(0.5).next_to(propsaw, DOWN) noteubl= Text("伞形式", font="STZhongsong").scale(0.5).next_to(propumbrella1, DOWN).set_y(notesaw.get_y()) notenm = Text("Newman式", font="STZhongsong").scale(0.5).next_to(propnewman1, DOWN).set_y(notesaw.get_y()) type1 = Text("交叉型", font="STZhongsong").to_edge(DOWN) type2 = Text("重叠型", font="STZhongsong").to_edge(DOWN) self.play(Transform(li2, propsaw)) self.play(Write(notesaw)) self.play(Write(type1)) self.wait(1) self.play(Transform(propubl, propumbrella1)) self.play(Write(noteubl)) self.wait(1) self.play(Transform(propnm, propnewman1)) self.play(Write(notenm)) self.wait(1) self.play(Rotate(li2[8:14], angle = 60*DEGREES, about_point=li2[-1].get_corner(UR), rate_func=rate_functions.smooth)) self.wait(1) self.play(Transform(type1, type2)) self.wait(1) self.play(Transform(propubl, propumbrella2)) self.wait(1) self.play(Transform(propnm, propnewman2)) self.wait(1) vg_fadeout2 = VGroup(type1, li2, notesaw, noteubl, notenm, propubl) self.play(FadeOut(vg_fadeout2)) propnmpos = propnm.copy() vgpropnm = VGroup(propnewman1, propnmpos).move_to(np.array([0,0,0])).arrange(RIGHT, buff=3) self.play(propnm.animate.move_to(propnmpos.get_center())) propnm2 = propnm.copy() self.play(Transform(propnm2, propnewman1)) narra = Text("和乙烷类似,重叠型构象不稳定", font="STZhongsong").scale(0.6).to_edge(DOWN) narra2 = Text("它和交叉型构象的势能差为13.3kJ/mol", font="STZhongsong").scale(0.6).to_edge(DOWN) self.wait(1) self.play(DrawBorderThenFill(narra)) self.play(Transform(narra, narra2)) ax = Axes( x_range=[0, 130, 60], y_range=[0, 15, 13.3], x_length=0.8*PI, y_length=1, axis_config = {"include_tip": False} ).add_coordinates(font_size=10) labels = ax.get_axis_labels( x_label=Text("旋转角度/(°)", font="STZhongsong").scale(0.15), y_label=Text("势能/(kJ/mol)", font="STZhongsong").scale(0.15) ) graph = ax.plot(lambda x : 6.65*np.cos(PI/60*x) + 6.65, x_range = [0,120], color = BLUE) vgax = VGroup(ax,labels,graph).scale(3).shift(0.6*DOWN) point1 = ax.c2p(60, 0) dot1 = Dot(point1) point2 = ax.c2p(120, 13.3) dot2 = Dot(point2) self.play(propnm2.animate.scale(0.8), propnm.animate.scale(0.8)) self.play(propnm2.animate.move_to(dot1.get_center() + 1.2*UP), propnm.animate.move_to(dot2.get_center() + UP), rate_func=rate_functions.smooth) self.wait(1) self.play(Write(vgax[0:2])) self.play(Write(vgax[-1])) self.play(GrowFromPoint(dot1, dot1.get_center()), GrowFromPoint(dot2, dot2.get_center())) self.wait(1.5) self.play(FadeOut(narra)) vgback = VGroup(vgax, dot1, dot2, propnm, propnm2) self.play(Transform(vgback, li2copy)) self.play(FadeIn(vgfadeout)) self.wait(1)
%%manim -v WARNING -qh s4 class s4(Scene): def construct(self): li11 = Text("乙烷", font="STZhongsong") li21 = Text("丙烷", font="STZhongsong") li31 = Text("丁烷", font="STZhongsong") li4 = Text("乙烷衍生物", font="STZhongsong") vgli = VGroup(li11,li21,li31,li4).arrange(DOWN, buff=1) # 注意安排位置时考虑好顺序 li12 = MathTex("C_2H_6").scale(0.7).next_to(li11, DOWN) li22 = MathTex("C_3H_8").scale(0.7).next_to(li21, DOWN) li32 = MathTex("C_4H_{10}").scale(0.7).next_to(li31, DOWN) vgfadeout = VGroup(li11,li12,li21,li22,li4) li3 = VGroup(li31,li32) li3copy = li3.copy() vgallli = VGroup(li11,li12,li21,li22,li31,li32,li4) self.add(vgallli) self.wait(2) self.play(FadeOut(vgfadeout)) li3transmol = MathTex("CH_3CH_2CH_2CH_3") self.play(Transform(li3,li3transmol)) self.wait(1) butsaw = SVGMobject(r"D:\manimSVG\butsaw.svg").scale(1.5) butubl = butsaw.copy() butnm = butsaw.copy() butumbrella1 = SVGMobject(r"D:\manimSVG\butumbrella1.svg").scale(0.8) butumbrella2 = SVGMobject(r"D:\manimSVG\butumbrella2.svg").scale(0.8) butumbrella3 = SVGMobject(r"D:\manimSVG\butumbrella3.svg").scale(0.8) butumbrella4 = SVGMobject(r"D:\manimSVG\butumbrella4.svg").scale(0.8) butnewman1 = SVGMobject(r"D:\manimSVG\butnewman1.svg").scale(1.2) butnewman2 = SVGMobject(r"D:\manimSVG\butnewman2.svg").scale(1.2) butnewman3 = SVGMobject(r"D:\manimSVG\butnewman3.svg").scale(1.2) butnewman4 = SVGMobject(r"D:\manimSVG\butnewman4.svg").scale(1.2) butnmpos1 = SVGMobject(r"D:\manimSVG\butnewman1.svg").scale(1.2) butnmpos2 = SVGMobject(r"D:\manimSVG\butnewman2.svg").scale(1.2) butnmpos3 = SVGMobject(r"D:\manimSVG\butnewman3.svg").scale(1.2) butnmpos4 = SVGMobject(r"D:\manimSVG\butnewman4.svg").scale(1.2) vgbut1 = VGroup(butumbrella1, butsaw, butnewman1).arrange(RIGHT, buff=2) vgbut2 = VGroup(butumbrella2, butsaw, butnewman2).arrange(RIGHT, buff=2) vgbut3 = VGroup(butumbrella3, butsaw, butnewman3).arrange(RIGHT, buff=2) vgbut4 = VGroup(butumbrella4, butsaw, butnewman4).arrange(RIGHT, buff=2) notesaw = Text("锯架式", font="STZhongsong").scale(0.5).next_to(butsaw, DOWN) noteubl= Text("伞形式", font="STZhongsong").scale(0.5).next_to(butumbrella1, DOWN).set_y(notesaw.get_y()) notenm = Text("Newman式", font="STZhongsong").scale(0.5).next_to(butnewman1, DOWN).set_y(notesaw.get_y()) type1 = Text("对交叉型", font="STZhongsong").to_edge(DOWN) type2 = Text("部分重叠型", font="STZhongsong").to_edge(DOWN) type3 = Text("邻交叉型", font="STZhongsong").to_edge(DOWN) type4 = Text("全重叠型", font="STZhongsong").to_edge(DOWN) self.play(Transform(li3, butsaw)) self.play(Write(notesaw)) self.play(Write(type1)) self.wait(1) self.play(Transform(butubl, butumbrella1)) self.play(Write(noteubl)) self.wait(1) self.play(Transform(butnm, butnewman1)) self.play(Write(notenm)) self.wait(1) # 改变构型 self.play(Rotate(li3[8:16], angle = 60*DEGREES, about_point=li3[-1].get_corner(UR), rate_func=rate_functions.smooth)) self.wait(1) self.play(Transform(type1, type2)) self.wait(1) self.play(Transform(butubl, butumbrella2)) self.wait(1) self.play(Transform(butnm, butnewman2)) self.wait(1) self.play(Rotate(li3[8:16], angle = 60*DEGREES, about_point=li3[-1].get_corner(UR), rate_func=rate_functions.smooth)) self.wait(1) self.play(Transform(type1, type3)) self.wait(1) self.play(Transform(butubl, butumbrella3)) self.wait(1) self.play(Transform(butnm, butnewman3)) self.wait(1) self.play(Rotate(li3[8:16], angle = 60*DEGREES, about_point=li3[-1].get_corner(UR), rate_func=rate_functions.smooth)) self.wait(1) self.play(Transform(type1, type4)) self.wait(1) self.play(Transform(butubl, butumbrella4)) self.wait(1) self.play(Transform(butnm, butnewman4)) self.wait(1) # 画函数图像前准备 vg_fadeout2 = VGroup(type1, li3, notesaw, noteubl, notenm, butubl) self.play(FadeOut(vg_fadeout2)) butnmpos = butnm.copy() vgbutnm = VGroup(butnewman1, butnewman2, butnewman3, butnmpos).move_to(np.array([0,0,0])).arrange(RIGHT, buff=1) self.play(butnm.animate.move_to(butnmpos.get_center())) butnm2 = butnm.copy() butnm3 = butnm.copy() butnm4 = butnm.copy() self.play(Transform(butnm2, butnewman1)) self.play(Transform(butnm3, butnewman2)) self.play(Transform(butnm4, butnewman3)) self.wait(1) narra = Text("同样的,全重叠型的能量最高,对交叉型的能量最低", font="STZhongsong").scale(0.6).to_edge(DOWN) self.play(DrawBorderThenFill(narra)) ax = Axes( x_range=[0, 200, 60], y_range=[0, 40, 40], x_length=0.8*PI, y_length=1, axis_config = {"include_tip": False} ).add_coordinates(font_size=10) labels = ax.get_axis_labels( x_label=Text("旋转角度/(°)", font="STZhongsong").scale(0.15), y_label=Text("势能/(kJ/mol)", font="STZhongsong").scale(0.15) ) graph1 = ax.plot(lambda x : -7.3*np.cos(PI/60*x) + 7.3, x_range = [0,60], color = BLUE) graph2 = ax.plot(lambda x : -5.4*np.cos(PI/60*x) + 9.2, x_range = [60,120], color = BLUE) graph3 = ax.plot(lambda x : -9.4*np.cos(PI/60*x) + 13.2, x_range = [120,180], color = BLUE) vgax = VGroup(ax,labels,graph1,graph2,graph3).scale(3.5) point1 = ax.c2p(0, 0) dot1 = Dot(point1) point2 = ax.c2p(60, 14.6) dot2 = Dot(point2) point3 = ax.c2p(120, 3.8) dot3 = Dot(point3) point4 = ax.c2p(180, 22.6) dot4 = Dot(point4) self.play(butnm2.animate.scale(0.6), butnm3.animate.scale(0.6), butnm4.animate.scale(0.6), butnm.animate.scale(0.6)) self.play(butnm2.animate.move_to(dot1.get_center() + 0.8*UP), butnm3.animate.move_to(dot2.get_center() + 0.7*UP), butnm4.animate.move_to(dot3.get_center() + 0.8*UP), butnm.animate.move_to(dot4.get_center() + 0.7*UP), rate_func=rate_functions.smooth) self.play(Write(vgax[0:2])) self.play(Write(vgax[2:])) self.play(GrowFromPoint(dot1, dot1.get_center()), GrowFromPoint(dot2, dot2.get_center()), GrowFromPoint(dot3, dot3.get_center()), GrowFromPoint(dot4, dot4.get_center())) self.wait(1.5) self.play(FadeOut(narra)) vgback = VGroup(vgax, dot1, dot2, dot3, dot4, butnm, butnm2, butnm3, butnm4) self.play(vgback.animate.shift(0.5*DOWN)) title = Text("正丁烷各种构象的势能关系图", font="STZhongsong").scale(0.8).next_to(vgax, UP).shift(LEFT) self.play(DrawBorderThenFill(title)) self.wait(1) vgaxfadeout = VGroup(ax,labels) self.play(FadeOut(vgaxfadeout), FadeOut(title)) vgaxremain = VGroup(graph1,graph2,graph3,dot1,dot2,dot3,dot4,butnm2,butnm3,butnm4,butnm) self.play(vgaxremain.animate.move_to(np.array([0,0,0]))) self.play(vgaxremain.animate.scale(1.4)) baseline = DashedLine(start=dot1.get_center() + 0.05*DOWN, end=np.array([dot4.get_x(),dot1.get_y(),0])) self.play(Write(baseline)) arr1 = DoubleArrow(start=np.array([dot2.get_x(),dot2.get_y(),0]), end=np.array([dot2.get_x(),dot1.get_y(),0]), buff=0, tip_length=0.2, color=GREEN) arr2 = DoubleArrow(start=np.array([dot3.get_x(),dot3.get_y(),0]), end=np.array([dot3.get_x(),dot1.get_y(),0]), buff=0, tip_length=0.2, color=GREEN) arr3 = DoubleArrow(start=np.array([dot4.get_x(),dot4.get_y(),0]), end=np.array([dot4.get_x(),dot1.get_y(),0]), buff=0, tip_length=0.2, color=GREEN) self.play(GrowFromPoint(arr1,arr1.get_center()), GrowFromPoint(arr2,arr2.get_center()), GrowFromPoint(arr3,arr3.get_center())) diff1 = MathTex("3.8kJ/mol").next_to(arr2, 0.05*LEFT).scale(0.6).shift(0.4*RIGHT) diff2 = MathTex("14.6kJ/mol").next_to(arr1, 0.05*LEFT).scale(0.6).shift(0.45*RIGHT) diff3 = MathTex("22.6kJ/mol").next_to(arr3, 0.05*LEFT).scale(0.6).shift(0.45*RIGHT) self.play(DrawBorderThenFill(diff1), DrawBorderThenFill(diff2), DrawBorderThenFill(diff3)) self.wait(1.5) vgback2 = VGroup(vgaxremain, baseline, arr1, arr2, arr3, diff1, diff2, diff3) clddot1 = Dot(radius=0.1732,color=RED).to_corner(DL).shift(UP+RIGHT) clddot2 = Dot(radius=0.1732,color=BLUE).to_corner(UR).shift(DOWN+LEFT) vgclddot = VGroup(clddot1,clddot2) narra2 = Text("在室温下,分子间的碰撞足以", font="STZhongsong").scale(0.6).to_edge(DOWN) narra3 = Text("提供构象异构体之间相互转化的能量", font="STZhongsong").scale(0.6).to_edge(DOWN) narra4 = Text("因此这些构象异构体可以互相转化而不能分离", font="STZhongsong").scale(0.6).to_edge(DOWN) self.play(Transform(vgback2, vgclddot), DrawBorderThenFill(narra2)) self.add(vgclddot) self.remove(vgback2) self.wait(1) self.play(clddot1.animate.move_to(np.array([-0.1732,-0.1,0])), clddot2.animate.move_to(np.array([0,0.2,0])), Transform(narra2,narra3), rate_func = rush_into) self.play(clddot1.animate.move_to(np.array([0,-3,0])), clddot2.animate.move_to(np.array([1.5,2.5981,0])), rate_func = rush_from) self.wait(1) vgback2 = VGroup(clddot1,clddot2) self.play(Transform(narra2, narra4), Transform(vgback2, butnmpos1)) self.play(Transform(vgback2,butnmpos2), run_time=0.2) self.play(Transform(vgback2,butnmpos3), run_time=0.2) self.play(Transform(vgback2,butnmpos4), run_time=0.2) self.play(Transform(vgback2,butnmpos1), run_time=0.2) self.play(Transform(vgback2,butnmpos2), run_time=0.2) self.play(Transform(vgback2,butnmpos3), run_time=0.2) self.play(Transform(vgback2,butnmpos4), run_time=0.2) self.play(Transform(vgback2,butnmpos1), run_time=0.3) self.play(Transform(vgback2,butnmpos2), run_time=0.4) self.play(Transform(vgback2,butnmpos3), run_time=0.5) self.play(Transform(vgback2,butnmpos4), run_time=0.6) self.play(Transform(vgback2,butnmpos1), run_time=0.7, rate_func = rush_from) self.play(FadeOut(narra2)) butnmpos3flip = SVGMobject(r"D:\manimSVG\butnewman3flip.svg").scale(1.2) vgback2pos = vgback2.copy() vgbutper = VGroup(butnmpos3flip, vgback2pos, butnmpos3).arrange(RIGHT, 1.5) vgback3 = vgback2.copy() vgback4 = vgback2.copy() self.play(Transform(vgback3, butnmpos3flip)) self.play(Transform(vgback4, butnmpos3)) per2 = Text("约70%", font="STZhongsong").scale(0.5).next_to(vgback2, DOWN) per1 = Text("约15%", font="STZhongsong").scale(0.5).next_to(vgback3, DOWN).set_y(per2.get_y()) per3 = Text("约15%", font="STZhongsong").scale(0.5).next_to(vgback4, DOWN).set_y(per2.get_y()) notation = Text("正丁烷的构象分布", font="STZhongsong").scale(0.8).to_edge(UP) self.play(Write(per1)) self.play(Write(per2)) self.play(Write(per3)) self.play(DrawBorderThenFill(notation)) self.wait(1) vgbackfinal = VGroup(vgback2,vgback3,vgback4,per1,per2,per3,notation) self.play(Transform(vgbackfinal, li3copy)) self.play(FadeIn(vgfadeout)) self.wait(1)
%%manim -v WARNING -qh s5 class s5(Scene): def construct(self): mol1 = MathTex("CH_2ClCH_2Cl").scale(0.7) mol2 = MathTex("CH_2BrCH_2Br").scale(0.7) mol3 = MathTex("C_6H_5CH_2CH_2C_6H_5").scale(0.7) vgmol = VGroup(mol1,mol2,mol3).arrange(RIGHT,1.5).set_y(2) li11 = Text("乙烷", font="STZhongsong") li21 = Text("丙烷", font="STZhongsong") li31 = Text("丁烷", font="STZhongsong") li4 = Text("乙烷衍生物", font="STZhongsong") vgli = VGroup(li11,li21,li31,li4).arrange(DOWN, buff=1) # 注意安排位置时考虑好顺序 li12 = MathTex("C_2H_6").scale(0.7).next_to(li11, DOWN) li22 = MathTex("C_3H_8").scale(0.7).next_to(li21, DOWN) li32 = MathTex("C_4H_{10}").scale(0.7).next_to(li31, DOWN) vgfadeout = VGroup(li11,li12,li21,li22,li31,li32) li4copy = li4.copy() vgallli = VGroup(li11,li12,li21,li22,li31,li32,li4) self.add(vgallli) self.wait(2) self.play(FadeOut(vgfadeout)) self.play(Transform(li4,vgmol)) self.add(vgmol) self.remove(li4) nm1 = SVGMobject(r"D:\manimSVG\doublecl.svg").scale(1.2).set_x(mol1.get_x()) nm2 = SVGMobject(r"D:\manimSVG\doublebr.svg").scale(1.2).set_x(mol2.get_x()) nm3 = SVGMobject(r"D:\manimSVG\doubleben.svg").scale(1.2).set_x(mol3.get_x()) nmhydro11 = SVGMobject(r"D:\manimSVG\doublealco1.svg").scale(1.8).shift(3*LEFT) nmhydro12 = SVGMobject(r"D:\manimSVG\doublealco2.svg").scale(1.8).shift(3*LEFT) nmhydro13 = SVGMobject(r"D:\manimSVG\doublealco3.svg").scale(1.8).shift(3*LEFT) nmhydro21 = SVGMobject(r"D:\manimSVG\clandalco1.svg").scale(1.8).shift(3*RIGHT) nmhydro22 = SVGMobject(r"D:\manimSVG\clandalco2.svg").scale(1.8).shift(3*RIGHT) nmhydro23 = SVGMobject(r"D:\manimSVG\clandalco3.svg").scale(1.8).shift(3*RIGHT) note1 = Text("约70%", font="STZhongsong").scale(0.5).set_x(mol1.get_x()).set_y(-2) note2 = Text("约85%", font="STZhongsong").scale(0.5).set_x(mol2.get_x()).set_y(-2) note3 = Text("约90%以上", font="STZhongsong").scale(0.5).set_x(mol3.get_x()).set_y(-2) mol1copy = mol1.copy() mol2copy = mol2.copy() mol3copy = mol3.copy() vgnm = VGroup(nm1,nm2,nm3) vgnote = VGroup(note1,note2,note3) t1 = Text("大多数有机分子都以交叉型构象为主要的存在形式", font="STZhongsong").scale(0.6).to_edge(DOWN) t2 = Text("比如:", font="STZhongsong").scale(0.6).to_edge(DOWN) t3 = Text("但在乙二醇和2-氯乙醇分子中", font="STZhongsong").scale(0.6).to_edge(DOWN) t4 = Text("由于邻交叉构象可以形成分子内氢键而降低能量", font="STZhongsong").scale(0.6).to_edge(DOWN) t5 = Text("所以主要以邻交叉构象形式存在", font="STZhongsong").scale(0.6).to_edge(DOWN) self.play(DrawBorderThenFill(t1)) self.play(Transform(t1,t2)) self.play(Transform(mol1copy, nm1)) self.play(Write(note1)) self.play(Transform(mol2copy, nm2)) self.play(Write(note2)) self.play(Transform(mol3copy, nm3)) self.play(Write(note3)) vgfadeout2 = VGroup(vgmol,mol1copy,mol2copy,mol3copy,vgnote) self.play(FadeOut(vgfadeout2)) self.play(Transform(t1,t3), GrowFromPoint(nmhydro11, nmhydro11.get_center()), GrowFromPoint(nmhydro21, nmhydro21.get_center())) self.wait(1.5) self.play(Transform(t1,t4),Transform(nmhydro11,nmhydro12), Transform(nmhydro21,nmhydro22)) self.wait(1) self.play(Transform(t1,t4),Transform(nmhydro11,nmhydro13),Transform(nmhydro21,nmhydro23)) self.wait(1) self.play(Transform(t1,t5)) self.wait(2) vgback = VGroup(t1,nmhydro11,nmhydro21) self.play(Transform(vgback,li4copy)) self.play(FadeIn(vgfadeout)) self.wait(1) vgfinalfadeout = VGroup(vgback,vgfadeout) self.play(FadeOut(vgfinalfadeout))
标签:play,scale,paraffins,self,get,conformation,Transform,font,manim 来源: https://www.cnblogs.com/daxiangcai/p/16441757.html