예제 #1
0
 def _repr_html_(self):
     from sympy.printing.latex import LatexPrinter
     from sympy.physics.vector import vlatex
     lp = LatexPrinter()
     x = vlatex(self.loop.x)
     y = vlatex(self.loop.y)
     return lp.doprint(r"$$ \begin{bmatrix} {%s} \\ {%s} \end{bmatrix} $$" %
                       (x, y))
예제 #2
0
 def _repr_html_(self):
     from sympy.printing.latex import LatexPrinter
     from sympy.physics.vector import vlatex
     lp = LatexPrinter()
     x = vlatex(self.x)
     y = vlatex(self.y)
     # return lp.doprint("$$ \\langle {0}, \\\\ {1} \\rangle $$".format(x,y))
     return lp.doprint(r"$$ \begin{bmatrix} {%s} \\ {%s} \end{bmatrix} $$" %
                       (x, y))
예제 #3
0
def test_vlatex(): # vlatex is broken #12078
    from sympy.physics.vector import vlatex

    x = symbols('x')
    J = symbols('J')

    f = Function('f')
    g = Function('g')
    h = Function('h')

    expected = r'J \left(\frac{d}{d x} g{\left(x \right)} - \frac{d}{d x} h{\left(x \right)}\right)'

    expr = J*f(x).diff(x).subs(f(x), g(x)-h(x))

    assert vlatex(expr) == expected
예제 #4
0
def test_vlatex():  # vlatex is broken #12078
    from sympy.physics.vector import vlatex

    x = symbols("x")
    J = symbols("J")

    f = Function("f")
    g = Function("g")
    h = Function("h")

    expected = r"J \left(\frac{d}{d x} g{\left(x \right)} - \frac{d}{d x} h{\left(x \right)}\right)"

    expr = J * f(x).diff(x).subs(f(x), g(x) - h(x))

    assert vlatex(expr) == expected
f, (ax1, ax2, ax3) = plt.subplots(3)

ke1, ke2 = dynamicsymbols('ke1, ke2')
pe1, pe2 = dynamicsymbols('pe1, pe2')
ke, pe,tot = dynamicsymbols('ke, pe, tot')

energies = [pe1,pe2,ke1,ke2]
energy = [pe, ke, tot]




ax1.plot(t, rad2deg(y[:,:2]))
ax1.set_xlabel('Time [s]')
ax1.set_ylabel('Angle[deg]')
ax1.legend(["${}$".format(vlatex(c)) for c in coordinates])
"""
plot(time_vector, tracking_vector)
#plot(time_vector, curr_vector)
xlabel('Time')
ylabel('angle')
plt.show()

plot(time_vector, torque_vector)
xlabel('Time [s]')
ylabel('Angle 1 torque')
plt.show()
"""
ax2.plot(t, rad2deg(y[:, 2:]))
ax2.set_xlabel('Time [s]')
ax2.set_ylabel('Angular Rate [deg/s]')
template = \
r"""\begin{{bmatrix}}
  0 \\
  0 \\
  0 \\
  0
\end{{bmatrix}}
=
\begin{{bmatrix}}
{rows}
\end{{bmatrix}}"""

rows = []
for row in m.kin_diff_eqs + tuple(fr_plus_frstar):
    rows.append(vlatex(row))

with open(os.path.join(paths['project_root'], 'eoms.tex'), 'w') as f:
    f.write(template.format(rows='\\\\\n'.join(rows)))

# Generate a table for the open loop model constants. This should have three
# columns: latex variable name, value, units

units = {'d': r'\si{\meter}',
         'l': r'\si{\meter}',
         'm': r'\si{\kilogram}',
         'I': r'\si{\kilogram\meter\squared}',
         'g': r'\si{\meter\per\second\squared}'}

template = \
r"""
def animate(i):
  thisx = [0, LA_x[i], RH_x[i], RA_x[i], RH_x[i], C_x[i], M_x[i]]
  thisy = [0, LA_y[i], RH_y[i], RA_y[i], RH_y[i], C_y[i], M_y[i]]

  line.set_data(thisx, thisy)
  time_text.set_text(time_template%(i*dt))
  return line, time_text

ani = animation.FuncAnimation(fig, animate, np.arange(1, len(y)), interval=25, blit=True, init_func=init)
#ani.save('triple_pendulum_alt_with_limits.mp4')
plt.show()

plot(t, rad2deg(y[:,:3]))
xlabel('Time [s]')
ylabel('Angle[deg]')
legend(["${}$".format(vlatex(c)) for c in coordinates])
plt.show()

plot(time_vector, torque_vector)
xlabel('Time [s]')
ylabel('Angle torques')
legend(["${}$".format(vlatex(c)) for c in specified])
plt.show()
plot(time_vector, idx_vector)
xlabel('time')
ylabel('idx')
plt.show()

plot(t, rad2deg(y[:, 3:]))
xlabel('Time [s]')
ylabel('Angular Rate [deg/s]')
  thisy = [0, y1[i], y2[i]]

  line.set_data(thisx, thisy)
  time_text.set_text(time_template%(i*dt))
  return line, time_text

ani = animation.FuncAnimation(fig, animate, np.arange(1, len(y)), interval=dt*1000, blit=True, init_func=init)
#ani.save('acrobot_zeroc_0_0_disturbance_initial_K.mp4')
plt.show()

f, (ax1, ax2, ax3) = plt.subplots(3)

ax1.plot(t, rad2deg(y[:,:2]))
ax1.set_xlabel('Time [s]')
ax1.set_ylabel('Angle[deg]')
ax1.legend(["${}$".format(vlatex(c)) for c in coordinates])
"""
plot(time_vector, tracking_vector)
#plot(time_vector, curr_vector)
xlabel('Time')
ylabel('angle')
plt.show()
"""
ax3.plot(time_vector, torque_vector)
ax3.set_xlabel('Time [s]')
ax3.set_ylabel('Torques')
ax3.legend(["${}$".format(vlatex(b)) for b in specified])

ax2.plot(t, rad2deg(y[:, 2:]))
ax2.set_xlabel('Time [s]')
ax2.set_ylabel('Angular Rate [deg/s]')
예제 #9
0
#--------------------------------------------------
    #fw = Fwo * cos(w_w*t) # input wind force
    #Fw_history.append(fw*1e-6) # MN
#--------------------------------------------------
for i in range(0,len(zeta_list)):
    ze = zeta_list[i]
    c = ze * cc # Damping coefficient
    Xw = Fwo / ((k-m*w_w**2) + complex(0,w_w*c))
    for j in range(0,len(time)):
        t = time[j]
        x_w = abs(Xw)*cos(w_w*t-phase(Xw)) # Steady state response from wind
        Xw_history[i,j] = x_w*1e6 # micro
    
#************************************************************************************************

    ## Results and Responses:
fig1 = plt.figure()
rect = fig1.patch

for i in range(0,len(zeta_list)):
    graphW = fig1.add_subplot(1,1,1)
    graphW.plot(time, Xw_history[i,0:], linewidth=2.0)
    #graphW.plot(time, Fw_history, linewidth=1.0)
    #graphW.legend(['x_w(t) [cm]', 'f(t) [MN]'], fontsize=12, loc='lower right')
    graphW.set_title(' "Isolation for Wind at resonace, [microm]" ', fontsize=25)
    graphW.legend( ["${}$".format( vlatex(ze_list[k])+' = '+str(zeta_list[k])) for k in range(0,len(zeta_list))  ] , fontsize=13, loc='upper right' )
    graphW.set_xlabel('Time [s]', fontsize=20)
    graphW.grid(True)

plt.show()
예제 #10
0
from sympy.physics.vector import vlatex, ReferenceFrame, dynamicsymbols
N = ReferenceFrame('N')
q1, q2 = dynamicsymbols('q1 q2')
q1d, q2d = dynamicsymbols('q1 q2', 1)
q1dd, q2dd = dynamicsymbols('q1 q2', 2)
vlatex(N.x + N.y)
vlatex(q1 + q2)
vlatex(q1d)
vlatex(q1 * q2d)
vlatex(q1dd * q1 / q1d)


from sympy.physics.vector import vprint, dynamicsymbols
u1 = dynamicsymbols('u1')
print(u1)
vprint(u1)
예제 #11
0
graphW.set_title(' "Wind System Response" ', fontsize=25)
graphW.set_xlabel('Time [s]', fontsize=20)
graphW.grid(True)

### Amplification Factor:

fig2a = plt.figure()
rect = fig2a.patch
fig2b = plt.figure()
rect = fig2b.patch

for i in range(0, len(zeta_list)):
    graphW2a = fig2a.add_subplot(1, 1, 1)
    graphW2a.plot(R, M_history[i, 0:], linewidth=1.5)
    graphW2a.legend([
        "${}$".format(vlatex(ze_list[k]) + ' = ' + str(zeta_list[k]))
        for k in range(0, len(zeta_list))
    ],
                    fontsize=13,
                    loc='upper right')
    graphW2a.set_title(' "Amplification factor with r for Wind" ', fontsize=25)
    graphW2a.set_ylabel('M = Xw/x_st', fontsize=20)
    graphW2a.set_xlabel('r = w_w/wn', fontsize=20)
    graphW2a.grid(True)
    graphW2b = fig2b.add_subplot(1, 1, 1)
    graphW2b.plot(R, PH_history[i, 0:], linewidth=1.5)
    graphW2b.legend([
        "${}$".format(vlatex(ze_list[k]) + ' = ' + str(zeta_list[k]))
        for k in range(0, len(zeta_list))
    ],
                    fontsize=13,
from sympy.physics.vector import vlatex, ReferenceFrame, dynamicsymbols
N = ReferenceFrame('N')
q1, q2 = dynamicsymbols('q1 q2')
q1d, q2d = dynamicsymbols('q1 q2', 1)
q1dd, q2dd = dynamicsymbols('q1 q2', 2)
vlatex(N.x + N.y)
vlatex(q1 + q2)
vlatex(q1d)
vlatex(q1 * q2d)
vlatex(q1dd * q1 / q1d)

from sympy.physics.vector import vprint, dynamicsymbols
u1 = dynamicsymbols('u1')
print(u1)
vprint(u1)