Задача из Яблонского Д24-19 — различия между версиями

Материал из Department of Theoretical and Applied Mechanics
Перейти к: навигация, поиск
(Новая страница: «== Условие задачи== Определить частоты малых свободных колебаний и формы главных колебан…»)
 
(Условие задачи)
 
(не показаны 4 промежуточные версии этого же участника)
Строка 1: Строка 1:
 
== Условие задачи==
 
== Условие задачи==
 
Определить частоты малых свободных колебаний и формы главных колебаний системы с двумя степенями свободы, пренебрегая силами сопротивления, массами пружин и моментами инерции скручиваемых валов.
 
Определить частоты малых свободных колебаний и формы главных колебаний системы с двумя степенями свободы, пренебрегая силами сопротивления, массами пружин и моментами инерции скручиваемых валов.
 
<math>m_1</math> = 8 кг;
 
<math>m_2</math> = 10 кг;
 
<math>c_1</math> = 40 Н⁄см;
 
<math>c_2</math> = 60 Н⁄см;
 
<math>l</math> = 0,5 м.
 
  
 
== Программа ==
 
== Программа ==
  
{{#widget:Iframe |url=http://tm.spbstu.ru/htmlets/KaloevaDiana/D24_20/Project.html |width=1200 |height=800 |border=0 }}
+
{{#widget:Iframe |url=http://tm.spbstu.ru/htmlets/Vedrov_MA/ |width=1350 |height=800 |border=0 }}
  
 
== Код программы ==
 
== Код программы ==
Строка 204: Строка 198:
  
 
* three.js
 
* three.js
* CurveExtras1.js
 
 
* stats.min.js
 
* stats.min.js
 
* dat.gui.js
 
* dat.gui.js
* OrbitControls.js
+
* graphicBuilder.js
  
 
== Скачать работу ==
 
== Скачать работу ==
  
* [http://mech.spbstu.ru/File:KR_PL_2018_KaloevaDE.docx  Скачать текст работы].
+
* [http://mech.spbstu.ru/File:%D0%9A%D0%9F_%D1%8F%D0%B7.%D0%BF%D1%80%D0%BE%D0%B3..docx  Скачать текст работы].
* [http://mech.spbstu.ru/File:D24_20.rar  Скачать программу].
+
* [http://mech.spbstu.ru/File:Maxproject.rar  Скачать программу].

Текущая версия на 23:10, 11 сентября 2018

Условие задачи[править]

Определить частоты малых свободных колебаний и формы главных колебаний системы с двумя степенями свободы, пренебрегая силами сопротивления, массами пружин и моментами инерции скручиваемых валов.

Программа[править]

Код программы[править]

Текст программы:
  1     const scene = new THREE.Scene();
  2     const camera = new THREE.PerspectiveCamera(60, 1, 1, 100);
  3     const renderer = new THREE.WebGLRenderer();
  4 
  5     //Постановка задачи(условия)
  6     const R = 2;
  7     const solution = new function () {
  8         this.c1 = 20000;
  9         this.c2 = 30000;
 10         this.c3 = 10000;
 11         this.R = .2;
 12         this.t = 0;
 13         this.dt = .7;
 14 
 15         this.m1 = 50;
 16         this.m2 = 60;
 17         this.m3 = 40;
 18         this.m4 = 50;
 19 
 20 
 21         this.a11 = .5*(this.m1+this.m2)*Math.pow(this.R,2);
 22         this.a22 = .5*(this.m3+this.m4)*Math.pow(this.R,2);
 23         this.c11 = this.c1+this.c2/1.44;
 24         this.c22 = this.c2/.81 + this.c3;
 25         this.c12 = this.c2/(1.2*.9);
 26         this.D = Math.sqrt(Math.pow(this.a11 * this.c22 + this.a22 * this.c11,2) -4 * this.a11 * this.a22 * (this.c11 * this.c22 - Math.pow(this.c12,2)));
 27         this.k1 = '' + Math.sqrt((this.a11 * this.c22 + this.a22 * this.c11 + this.D)/(2*this.a11*this.a22));
 28         this.k2 = '' + Math.sqrt((this.a11 * this.c22 + this.a22 * this.c11 - this.D)/(2*this.a11*this.a22));
 29 
 30         this.p1 = -(this.c11 - this.a11*Math.pow(this.k1,2))/this.c12;
 31         this.p2 = -(this.c11 - this.a11*Math.pow(this.k2,2))/this.c12;
 32 
 33         let self = this;
 34 
 35         this.redraw = function() {
 36             self.t = 0;
 37             ctx.clearRect(0,-242,500,500);
 38             ctx1.clearRect(0,-242,500,500);
 39         };
 40     };
 41     class Construction {
 42         constructor(geometry,material,x,y,z) {
 43             this.geometry = geometry;
 44             this.material = material;
 45             this.x = x;
 46             this.y = y;
 47             this.z = z;
 48             this.mesh = new THREE.Mesh(geometry,material);
 49         }
 50         build(scene,angleX,angleY,angleZ) {
 51             this.mesh.position.x = this.x;
 52             this.mesh.position.y = this.y;
 53             this.mesh.position.z = this.z;
 54             this.mesh.rotation.x = angleX;
 55             this.mesh.rotation.y = angleY;
 56             this.mesh.rotation.z = angleZ;
 57             scene.add(this.mesh);
 58         }
 59     }
 60 
 61     class Moving_parts extends Construction {
 62         spin(solution,sign,ratio,r) {
 63             let r1 = 1;
 64             let r2 = 1;
 65             if(r !== 1) {
 66                 r1 =  solution.p1;
 67                 r2 =  solution.p2;
 68             }
 69             this.mesh.rotation.x = r1 * sign * Math.sin(solution.k1 * solution.t / 1000) * 2 / ratio + r2 * sign * Math.sin(solution.k2 * solution.t / 1000) * 2 / ratio;
 70         }
 71         static equation(solution,sign,ratio,r,t) {
 72             let r1 = 1;
 73             let r2 = 1;
 74             if(r !== 1) {
 75                 r1 =  solution.p1;
 76                 r2 =  solution.p2;
 77             }
 78             return r1 * sign * Math.sin(solution.k1 * t / 1000) * 50 / ratio + r2 * sign * Math.sin(solution.k2 * t / 1000) * 50 / ratio;
 79         }
 80     }
 81 
 82 
 83     renderer.setClearColor(0xEEEEEE);
 84     renderer.setSize(600, 600);
 85     let main = document.getElementById("canvas_3d");
 86     main.appendChild(renderer.domElement);
 87     renderer.domElement.style.border = "1px solid#000";
 88 
 89 
 90     let gr = new GraphicBulider(450,242);
 91     let ctx = gr.dom("canvas_1");
 92     let gr1 = new GraphicBulider(450,242);
 93     let ctx1 = gr1.dom("canvas_2");
 94     let buffer = GraphicBulider.createBuffer();
 95     let buffer1 = GraphicBulider.createBuffer();
 96 
 97 
 98     const spotLight = new THREE.SpotLight( 0xffffff );
 99     spotLight.position.set( 50, 80, 20 );
100     scene.add(spotLight);
101 
102     const axes = new THREE.AxisHelper( 20 );
103     scene.add(axes);
104 
105     //Условия задачи
106     let wall_1 = new Construction(new THREE.CubeGeometry(10,5,1),new THREE.MeshLambertMaterial({color: 0xff0000,wireframe: false}),0,0,0);
107     let shaft_1 = new Construction(new THREE.CylinderGeometry(.5,.5,10,20,10),new THREE.MeshLambertMaterial({color: 0xff0000,wireframe: false}),5.5,0,0);
108     let wheel_1 = new Moving_parts(new THREE.CylinderGeometry(2*R,2*R,1,20,5),new THREE.MeshLambertMaterial({color: 0xff0000,wireframe: true}),11,0,0);
109     let wheel_2 = new Moving_parts(new THREE.CylinderGeometry(2*R*1.2,2*R*1.2,1,20,5),new THREE.MeshLambertMaterial({color: 0xff0000,wireframe: true}),11,-(2*R+1.2*R*2),0);
110     let shaft_2 = new Construction(new THREE.CylinderGeometry(.5,.5,10,20,10),new THREE.MeshLambertMaterial({color: 0xff0000,wireframe: false}),16.5,-(2*R+1.2*R*2),0);
111     let wheel_3 = new Moving_parts(new THREE.CylinderGeometry(2*R*.9,2*R*.9,1,20,5),new THREE.MeshLambertMaterial({color: 0xff0000,wireframe: true}),22,-(2*R+1.2*R*2),0);
112     let wheel_4 = new Moving_parts(new THREE.CylinderGeometry(2*R,2*R,1,20,5),new THREE.MeshLambertMaterial({color: 0xff0000,wireframe: true}),22,-(2*R+1.2*R*2+.9*R*2+2*R),0);
113     let shaft_3 = new Construction(new THREE.CylinderGeometry(.5,.5,5,20,10),new THREE.MeshLambertMaterial({color: 0xff0000,wireframe: false}),19,-(2*R+1.2*R*2+.9*R*2+2*R),0);
114     let wall_2 = new Construction(new THREE.CubeGeometry(10,5,1),new THREE.MeshLambertMaterial({color: 0xff0000,wireframe: false}),17,-(2*R+1.2*R*2+.9*R*2+2*R),0);
115     wall_1.build(scene,0,Math.PI/2,0);
116     shaft_1.build(scene,0,0,Math.PI/2);
117     wheel_1.build(scene,0,0,Math.PI/2);
118     wheel_2.build(scene,0,0,Math.PI/2);
119     shaft_2.build(scene,0,0,Math.PI/2);
120     wheel_3.build(scene,0,0,Math.PI/2);
121     wheel_4.build(scene,0,0,Math.PI/2);
122     shaft_3.build(scene,0,0,Math.PI/2);
123     wall_2.build(scene,0,Math.PI/2,0);
124 
125     camera.position.x = 20;
126     camera.position.y = 10;
127     camera.position.z = 40;
128     camera.lookAt(scene.position);
129     scene.rotation.y = -.5;
130     scene.position.y = 8.5;
131 
132     let T = solution.dt;
133     let z =.001;
134     let animate;
135     animate = function () {
136         requestAnimationFrame(animate);
137 
138         T = solution.dt;
139         solution.a11 = .5 * (solution.m1 + solution.m2) * Math.pow(solution.R, 2);
140         solution.a22 = .5 * (solution.m3 + solution.m4) * Math.pow(solution.R, 2);
141         solution.c11 = solution.c1 + solution.c2 / 1.44;
142         solution.c22 = solution.c2 / .81 + solution.c3;
143         solution.c12 = (1 / (1.2 * .9)) * solution.c2;
144         solution.D = Math.sqrt(Math.pow(solution.a11 * solution.c22 + solution.a22 * solution.c11, 2) - 4 * solution.a11 * solution.a22 * (solution.c11 * solution.c22 - Math.pow(solution.c12, 2)));
145         solution.k1 = '' + Math.sqrt((solution.a11 * solution.c22 + solution.a22 * solution.c11 + solution.D) / (2 * solution.a11 * solution.a22));
146         solution.k2 = '' + Math.sqrt((solution.a11 * solution.c22 + solution.a22 * solution.c11 - solution.D) / (2 * solution.a11 * solution.a22));
147         solution.p1 = -(solution.c11 - solution.a11 * Math.pow(solution.k1, 2)) / solution.c12;
148         solution.p2 = -(solution.c11 - solution.a11 * Math.pow(solution.k2, 2)) / solution.c12;
149 
150 
151         wheel_1.spin(solution, 1, 1, 1);
152         wheel_2.spin(solution, -1, 1.2, 1);
153         wheel_3.spin(solution, -1, .9, 2);
154         wheel_4.spin(solution, 1, 1, 2);
155 
156         if (solution.t === 0) {
157             z = 0;
158         }
159         if (solution.t > 450) {
160             z -= T;
161         }
162         ctx.clearRect(0, 0, buffer.width, 400);
163         ctx.drawImage(GraphicBulider.bufferDraw(buffer, solution.t, T, Moving_parts.equation(solution, 1, 1, 1, solution.t - T), Moving_parts.equation(solution, 1, 1, 1, solution.t), 'red'), z, 0);
164         ctx1.clearRect(0, 0, buffer.width, 400);
165         ctx1.drawImage(GraphicBulider.bufferDraw(buffer1, solution.t, T, Moving_parts.equation(solution, 1, 1, 0, solution.t - T), Moving_parts.equation(solution, 1, 1, 0, solution.t), 'green'), z, 0);
166         solution.t += T;
167         renderer.render(scene, camera);
168     };
169     animate();
170     const gui = new dat.GUI();
171     gui.add(solution, 'm1',20,70).onChange(solution.redraw);
172     gui.add(solution, 'm2',20,70).onChange(solution.redraw);
173     gui.add(solution, 'm3',20,70).onChange(solution.redraw);
174     gui.add(solution, 'm4',20,70).onChange(solution.redraw);
175     gui.add(solution, 'c1',0,35000).onChange(solution.redraw);
176     gui.add(solution, 'c2',0,35000).onChange(solution.redraw);
177     gui.add(solution, 'dt',0,10).onChange(solution.redraw);
178 
179     gui.add(solution, 'k1').listen();
180     gui.add(solution, 'k2').listen();
181     gui.add(solution, 'redraw');
182     solution.redraw();

Используемые библиотеки[править]

  • three.js
  • stats.min.js
  • dat.gui.js
  • graphicBuilder.js

Скачать работу[править]