springdashpotmass.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. !!omap
  2. - name: springdashpotmass
  3. - parts:
  4. - name: head
  5. shapes:
  6. libraries: ['from math import tan, radians, sin, cos', 'from pysketcher import *']
  7. - name: constants
  8. shapes:
  9. L: 12.
  10. - name: frame
  11. shapes:
  12. H: L/6
  13. W: L/6
  14. xmax: L
  15. x: 0
  16. setframe:
  17. action: drawing_tool.set_coordinate_system(xmin=-L, xmax=xmax,
  18. ymin=-1, ymax=L+H,
  19. axis=False,
  20. instruction_file='tmp_mpl_spring_mass.py')
  21. globallinecolor:
  22. action: drawing_tool.set_linecolor('black')
  23. d_start: (-L,2*H)
  24. dashpot:
  25. formula: Dashpot(start=d_start, total_length=L+x, width=W,
  26. bar_length=3*H/2, dashpot_length=L/2, piston_pos=H+x)
  27. transform: rotate(-90, d_start)
  28. s_start: (-L,4*H)
  29. spring:
  30. formula: Spring(start=s_start, length=L+x, bar_length=3*H/2, teeth=True)
  31. transform: rotate(-90, s_start)
  32. M: Rectangle((0,H), 4*H, 4*H).set_linewidth(4)
  33. left_wall: Rectangle((-L,0),H/10,L).set_filled_curves(pattern='/')
  34. ground: Wall(x=[-L/2,L], y=[0,0], thickness=-H/10)
  35. wheel1: Circle((H,H/2), H/2)
  36. wheel2:
  37. formula: wheel1.copy()
  38. transform: translate(point(2*H, 0))
  39. fontsize: 18
  40. text_m: Text('$m$', (2*H, H+2*H), fontsize=fontsize)
  41. text_ku: Text('$ku$', (-L/2, H+4*H), fontsize=fontsize)
  42. text_bv: Text("$bu'$", (-L/2, H), fontsize=fontsize)
  43. x_axis: Axis((2*H, L), H, '$u(t)$', fontsize=fontsize,
  44. label_spacing=(0.04, -0.01))
  45. x_axis_start:
  46. formula: Line((2*H, L-H/4), (2*H, L+H/4))
  47. style:
  48. linewidth: 4
  49. springdashpotmass: |
  50. Composition({
  51. 'spring': spring, 'dashpot': dashpot, 'mass': M, 'left wall': left_wall,
  52. 'ground': ground, 'wheel1': wheel1, 'wheel2': wheel2,
  53. 'text_m': text_m, 'text_ku': text_ku,
  54. 'x_axis': x_axis, 'x_axis_start': x_axis_start})