You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a beginner question, but I'm struggling with this.
I have an equation that represents the temperature distribution along one dimension:
I would like to plot the temperature as a function of the distance x. I want to display all the other parameters on the screen (T_l, T_r, q, K, L) and sweep through the parameters (one at a time) to show what the curve does when these parameters change. I want to display the parameter value on the screen and constantly have this update.
Can someone walk me through the easiest way to do this?
Here is what I have so far:
frommanimimport*pixel_width=450pixel_height=800config.frame_width=20config.frame_height=15classTemperatureDistribution(Scene):
defconstruct(self):
# initialize the parameter valuesT_l_init=300# Left temperature (in Kelvin)T_r_init=400# Right temperature (in Kelvin)q_init=100# Heat generation rate (W/m^3)k_init=50# Thermal conductivity (W/m·K)L_init=10# Length of the rod (meters)# Define the temperature function T(x)defT(x,T_l,T_r,q,k,L):
returnT_l+(0.5*(L**2)*(q/k)+T_r-T_l)*(x/L)-(0.5*L**2)*(q/k)*(x/L)**2axes=Axes(
x_range=[0, 10,1],
y_range=[200, 1000+50,50],
axis_config={"include_numbers": True},
)
x_label=axes.get_x_axis_label("distance, x [m]") # Label for the x-axisy_label=axes.get_y_axis_label("Temperature, T(x) [K]") # Label for the y-axis# Create the graph of the temperature distribution function T(x)graph=axes.plot(lambdax: T(x,T_l_init,T_r_init,q_init,k_init,L_init))
# Label the axes# Add the axes and the graph to the sceneself.play(Create(axes))
self.play(Create(graph))
self.play(Write(x_label), Write(y_label))
# Animate the graph by changing the value of L (length of the rod)label1=MathTex(f'T_l={T_l_init}')
label1.shift(5*UP+3*RIGHT)
label2=MathTex(f'T_r={T_r_init}')
label2.next_to(label1,DOWN)
label3=MathTex(f'q={q_init}')
label3.next_to(label2,DOWN)
label4=MathTex(f'k={k_init}')
label4.next_to(label3,DOWN)
label5=MathTex(f'L={L_init}')
label5.next_to(label4,DOWN)
self.play(Write(label1))
self.play(Write(label2))
self.play(Write(label3))
self.play(Write(label4))
self.play(Write(label5))
self.wait(2)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This is a beginner question, but I'm struggling with this.
I have an equation that represents the temperature distribution along one dimension:
I would like to plot the temperature as a function of the distance x. I want to display all the other parameters on the screen (T_l, T_r, q, K, L) and sweep through the parameters (one at a time) to show what the curve does when these parameters change. I want to display the parameter value on the screen and constantly have this update.
Can someone walk me through the easiest way to do this?
Here is what I have so far:
Beta Was this translation helpful? Give feedback.
All reactions