Мещерский 48.2

Материал из Department of Theoretical and Applied Mechanics
Перейти к: навигация, поиск

Мещерский Задача 48.2

Визуализация 3D-задачи по динамике на JavaScript

Исполнитель: Сызранцев Денис

Группа 23632/2 Кафедра Теоретической механики

Условие задачи

Барабан центрифуги приводится во вращение электродвигателем через двухступенчатый редуктор. Заданы момент инерции J0 электродвигателя, момент инерции J2 барабана, момент инерции J1 промежуточного вала редуктора, передаточные числа i01 и i12 ступеней редуктора. К ротору электродвигателя приложен вращающий момент M0 и момент сил сопротивления M0s, к валу редуктора и к барабану — моменты сил сопротивления M1s и M2s соответственно. Составить дифференциальное уравнение вращения барабана центрифуги.

Решение задачи

[math] d(δT/δw)/dt - δT/δφ = 0[/math]
[math]T_0 = -J_0 w_0^2/2[/math]
[math]T_1 = -J_1 w_1^2/2[/math]
[math]T_2 = -J_2 w_2^2/2[/math]
[math]i_1 = w_0/w_1[/math]
[math]i_2 = w_1/w_2[/math]
[math]d(δT/δw)/dt = J_0 i_01^2 i_2^2 + J_0 i_2^2 + J_2) b_0[/math]
[math](J_0 i_1^2 i_2^2 + J_0 i_2^2 + J_2) b_0 = (M - M_0) i_1 i_2 - M_1 i_2 - M_2[/math]

Визуализация

Код программы

Текст программы на языке JavaScript:
  1 <!DOCTYPE html>
  2 <html lang="en">
  3 	<head>
  4 		<title>48.2</title>
  5 		<meta charset="utf-8">
  6 		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7 		<style>
  8 			body {
  9 				font-family: Monospace;
 10 				background-color: #f0f0f0;
 11 				margin: 0px;
 12 				overflow: hidden;
 13 			}
 14 		</style>
 15 	</head>
 16 	<body>
 17 
 18 		<script src = "http://tm.spbstu.ru/htmlets/Belousova/Statika/three.js">
 19 		</script>
 20 		<script src ="http://tm.spbstu.ru/htmlets/Belousova/Statika/stats.min.js">
 21 		</script>
 22 		<script src ="http://tm.spbstu.ru/htmlets/Belousova/Statika/OrbitControls.js">
 23 		</script>
 24 		<script src ="http://tm.spbstu.ru/htmlets/Belousova/Statika/dat.gui.js">
 25 		</script>
 26 
 27 		<script>
 28 
 29 			var container, stats;
 30 
 31 			var camera, controls, scene, renderer;
 32 
 33 			var start = Date.now();
 34 			
 35 			var A2 , w0, w1, w2;
 36 
 37 			
 38 			var c = new function() {
 39 				this.i01 = 2;
 40 				this.i12 = 3;
 41 				this.J0 = 80;
 42 				this.J1 = 40;
 43 				this.J2 = 80;
 44 				this.M0 = 3;
 45 				this.M0s = 2;
 46 				this.M1s = 1.6;
 47 				this.M2s = 1;
 48 				this.stop = false;
 49 				this.restart = function(){
 50 				start = Date.now()
 51 				ED.rotation.x = 0;
 52 				rot.rotation.x =  0;
 53 				B.rotation.x = 0;
 54 				}
 55 				
 56 				this.w2 = 0.0;
 57 				this.A2 = ((this.M0-this.M0s)*this.i01*this.i12-this.M1s*this.i12-this.M2s)/(this.J0*(this.i01*this.i12)^2+this.J1*this.i12^2+this.J2a)
 58 			}
 59 			
 60 			
 61 			var width = window.innerWidth;
 62 			var height = window.innerHeight;
 63 			var le1 = 7;
 64 			var le2 = 3;
 65 			var re1 = 2;
 66 			var re2 = 0.3;
 67 			var lb1 = 9;
 68 			var rb1 = 3;
 69 			var rr1 = re1/c.i01;
 70 			var rb3 = rb1/c.i12;
 71 			var rr3 = rb1;
 72 			
 73 			var texture = new THREE.TextureLoader().load( "texture.jpg" );
 74 				texture.wrapS = THREE.RepeatWrapping;
 75 				texture.wrapT = THREE.RepeatWrapping;
 76 				texture.repeat.set( 3, 3 );
 77 			var material = new THREE.MeshLambertMaterial({color: 0xFFC673,map:texture});
 78 
 79 			function physics(t,c) {
 80 			
 81 				rr1 = re1/c.i01;
 82 				rb3 = rb1/c.i12;
 83 				
 84 				ED.position.y = -re1-rr1;
 85 				B.position.y = rb1+rr3;
 86 				rot.remove(rot1);
 87 				rot1 = new THREE.Mesh( new THREE.CylinderGeometry( rr1, rr1, 0.01, 64 ), material );
 88 				rot1.rotation.z = - Math.PI / 2;
 89 				rot1.position.x = -le2/2-5;
 90 				rot1.castShadow = true;	
 91 				rot.add( rot1 );
 92 				B.remove(B3);
 93 				B3 = new THREE.Mesh( new THREE.CylinderGeometry( rb3, rb3, 0.01, 64 ), material );
 94 				B3.rotation.z = - Math.PI / 2;
 95 				B3.position.x = le2/2-5;
 96 				B3.castShadow = true;
 97 				B.add( B3 );
 98 				B.position.y = rb3+rr3;
 99 				
100 				if (c.stop == false){
101 					var w1,w0;
102 					c.A2 = ((c.M0-c.M0s)*c.i01*c.i12-c.M1s*c.i12-c.M2s)/(c.J0*(c.i01*c.i12)^2+c.J1*c.i12^2+c.J2a);
103 					if ((c.A2<0)&&(c.w2 <= 0)){
104 					c.A2 = 0;
105 					c.w2 = 0;
106 					} else {
107 					c.w2 = c.A2*t;
108 					w1 = c.w2/c.i12;
109 					w0 = w1/c.i01;
110 					
111 				
112 					ED.rotation.x = t * w0*Math.pow(10, -3);
113 					rot.rotation.x =  - t * w1*Math.pow(10, -3);
114 					B.rotation.x = t * c.w2*Math.pow(10, -3);
115 					}
116 				}
117 				
118 				
119 
120 			}
121 			
122 			function init() {
123 				
124 				
125 				container = document.createElement( 'div' );
126 				document.body.appendChild( container );
127 				
128 				scene = new THREE.Scene();
129 				scene.background = new THREE.Color( 0xbfd1e5 );
130 
131 				camera = new THREE.PerspectiveCamera( 45, width / height, 0.1, 1000 );
132 				camera.position.x = -20;
133 				camera.position.y = 5;
134 				camera.position.z = 20;
135 				camera.lookAt(0,0,0)
136 
137 				
138 
139 				
140 
141 				
142 				
143 				var ambient = new THREE.AmbientLight( 0xffffff, 0.3 );
144 				scene.add( ambient );
145 				
146 				spotLight = new THREE.SpotLight( 0xffffff, 2 );
147 				spotLight.position.set( -30, 45, 35 );
148 				spotLight.angle = Math.PI / 3;
149 				spotLight.penumbra = 0.05;
150 				spotLight.decay = 2;
151 				spotLight.distance = 200;
152 				spotLight.castShadow = true;
153 				spotLight.shadow.mapSize.width = 1024;
154 				spotLight.shadow.mapSize.height = 1024;
155 				spotLight.shadow.camera.near = 10;
156 				spotLight.shadow.camera.far = 200;
157 				scene.add( spotLight );
158 				
159 				
160 				ED = new THREE.Object3D;
161 				ED1 = new THREE.Mesh( new THREE.CylinderGeometry( re1, re1, le1, 64 ), material );
162 				ED1.rotation.z = - Math.PI / 2;
163 				ED1.position.x = -le1/2-3*le2/2-5;
164 				ED1.castShadow = true;
165 				ED.add(ED1);
166 				ED2 = new THREE.Mesh( new THREE.CylinderGeometry( re2, re2, le2, 64 ), material );
167 				ED2.rotation.z = - Math.PI / 2;
168 				ED2.position.x = -le2-5;
169 				ED2.castShadow = true;
170 				ED.add(ED2);
171 				ED3 = new THREE.Mesh( new THREE.CylinderGeometry( re1, re1, 0.01, 64 ), material );
172 				ED3.rotation.z = - Math.PI / 2;
173 				ED3.position.x = -le2/2-5;
174 				ED3.castShadow = true;
175 				ED.add( ED3 );
176 				ED.position.y = -re1-rr1;
177 				scene.add( ED );
178 				
179 				rot = new THREE.Object3D;
180 				rot1 = new THREE.Mesh( new THREE.CylinderGeometry( rr1, rr1, 0.01, 64 ), material );
181 				rot1.rotation.z = - Math.PI / 2;
182 				rot1.position.x = -le2/2-5;
183 				rot1.castShadow = true;				
184 				rot.add( rot1 );
185 				rot2 = new THREE.Mesh( new THREE.CylinderGeometry( re2, re2, le2, 64 ), material );
186 				rot2.rotation.z = - Math.PI / 2;
187 				rot2.position.x = -5;
188 				rot2.castShadow = true;	
189 				rot.add( rot2 );
190 				rot3 = new THREE.Mesh( new THREE.CylinderGeometry( rr3, rr3, 0.01, 64 ), material );
191 				rot3.rotation.z = - Math.PI / 2;
192 				rot3.position.x = le2/2-5;
193 				rot3.castShadow = true;	
194 				rot.add( rot3 );
195 				scene.add( rot );
196 				
197 				B = new THREE.Object3D;
198 				B1 = new THREE.Mesh( new THREE.CylinderGeometry( rb1, rb1, lb1, 64 ), material );
199 				B1.rotation.z = - Math.PI / 2;
200 				B1.position.x = lb1/2+3*le2/2-5;
201 				B1.castShadow = true;	
202 				B.add(B1);
203 				B2 = new THREE.Mesh( new THREE.CylinderGeometry( re2, re2, le2, 64 ), material );
204 				B2.rotation.z = - Math.PI / 2;
205 				B2.position.x = le2-5;
206 				B2.castShadow = true;
207 				B.add(B2);
208 				B3 = new THREE.Mesh( new THREE.CylinderGeometry( rb3, rb3, 0.01, 64 ), material );
209 				B3.rotation.z = - Math.PI / 2;
210 				B3.position.x = le2/2-5;
211 				B3.castShadow = true;
212 				B.add( B3 );
213 				B.position.y = rb3+rr3;
214 				scene.add( B );
215 
216 				plane = new THREE.Mesh( new THREE.BoxGeometry( 2000, 1, 2000 ), new THREE.MeshPhongMaterial( { color: 0x679ED2, dithering: true } ) );
217 				plane.position.y = - 15;
218 				plane.receiveShadow = true;
219 				scene.add( plane );
220 				
221 				renderer = new THREE.WebGLRenderer();
222 				renderer.setSize( width, height );
223 				renderer.shadowMap.enabled = true;
224 				renderer.shadowMap.type = THREE.PCFSoftShadowMap;
225 				container.appendChild( renderer.domElement );
226 				
227 				controls = new THREE.OrbitControls( camera,renderer.domElement );
228 				
229 				var gui = new dat.GUI();
230 					gui.add(c, 'i01',1,5);
231 					gui.add(c, 'i12',1,5);
232 					gui.add(c, 'J0',1,1000);
233 					gui.add(c, 'J1',1,1000);
234 					gui.add(c, 'J2',1,1000);
235 					gui.add(c, 'M0',0,10);
236 					gui.add(c, 'M0s',0,10);
237 					gui.add(c, 'M1s',0,10);
238 					gui.add(c, 'M2s',0,10);
239 					gui.add(c, 'stop');
240 					gui.add(c, 'restart');
241 					gui.add(c, 'w2').listen();
242 					gui.add(c, 'A2').listen();
243 			}
244 
245 			function onWindowResize() {
246 
247 				camera.aspect = window.innerWidth / window.innerHeight;
248 				camera.updateProjectionMatrix();
249 
250 				renderer.setSize( window.innerWidth, window.innerHeight );
251 				
252 
253 			}
254 
255 			//
256 
257 			function animate() {
258 				
259 					requestAnimationFrame( animate );
260 					render();
261 			}
262 
263 			function render() {
264 
265 				var t = Date.now() - start;
266 				
267 				physics(t,c)
268 				
269 				ED.update;
270 				B.update;
271 				rot.update;
272 					
273 				controls.update();
274 
275 				renderer.render( scene, camera );
276 
277 			}
278 			
279 			init();
280 			animate();
281 			
282 
283 		</script>
284 	</body>
285 </html>