电容微积分
0.00
★103次@未来之窗
A:赛忞初雪
from manim import * class CapacitorChargingDischarging(Scene): def construct(self): # 创建电容和电阻 capacitor = Rectangle(width=2, height=1.5, fill_color=BLUE, fill_opacity=0.5) resistor = Rectangle(width=1, height=0.2, fill_color=GRAY, fill_opacity=0.5) # 将电容和电阻放置在场景中 capacitor.move_to(LEFT * 2) resistor.move_to(RIGHT * 2) self.add(capacitor, resistor) # 创建电源和电压标签 power_source = Arrow(start=LEFT * 1.5, end=RIGHT * 1.5, color=YELLOW) voltage_label = Tex("V").next_to(power_source, UP) self.add(power_source, voltage_label) # 创建电容电压标签 capacitor_voltage_label = Tex("V_c").next_to(capacitor, UP) self.add(capacitor_voltage_label) # 定义动画函数 def charging_animation(t): voltage = 10 * (1 - np.exp(-t)) capacitor_voltage_label.set_value(voltage) return capacitor_voltage_label def discharging_animation(t): if t < 5: return capacitor_voltage_label else: voltage = 10 * np.exp(-(t - 5)) capacitor_voltage_label.set_value(voltage) return capacitor_voltage_label # 运行充电动画 self.play(UpdateFromFunc(capacitor_voltage_label, charging_animation, run_time=10)) # 暂停一段时间 self.wait(2) # 运行放电动画 self.play(UpdateFromFunc(capacitor_voltage_label, discharging_animation, run_time=10))
硬件app