diff --git a/assets/nacele_126m_80.stl b/assets/nacele_126m_80.stl new file mode 100644 index 0000000..f117b20 Binary files /dev/null and b/assets/nacele_126m_80.stl differ diff --git a/assets/nacele_126m_90.stl b/assets/nacele_126m_90.stl new file mode 100644 index 0000000..8aa55ff Binary files /dev/null and b/assets/nacele_126m_90.stl differ diff --git a/index.html b/index.html index 25c2b0a..a026ae2 100644 --- a/index.html +++ b/index.html @@ -31,7 +31,7 @@ function hide() { function help() { show('

Simulador de Aerogeneradores y Parques Eólicos (SAPE)

' + - '

Desarrollado por:

'); + '

Desarrollado por:

'); } function up() { light.shadow.camera.top += 1; light.shadow.camera.updateProjectionMatrix(); helper.update()} @@ -51,7 +51,15 @@ function up() { light.shadow.camera.top += 1; light.shadow.camera.updateProjecti
¡SIMULAR!
-
?
+
+ +

Rotá tu
dispositivo

diff --git a/js/main.js b/js/main.js index 2df352c..b7e3acb 100644 --- a/js/main.js +++ b/js/main.js @@ -28,6 +28,10 @@ class WindSimulation { this.simulation = null; this.xhr = null; + this.rotation = Math.PI; + this.targetRotation = Math.PI; + this.dir = 0; + this.checkBoard = checkBoard(width, height); scene.add(this.checkBoard); @@ -59,7 +63,7 @@ class WindSimulation { } for(var i = 0; i < this.mills; i++) { var wm = new WindMill(); - wm.position.set(i + 0.5, i + 0.5, 0); + wm.position.set(4 + 0.5, i + 5 - Math.ceil(this.mills / 2) + 0.5, 0); wm.rotation.z = Math.PI; scene.add(wm); this.wms.push(wm); @@ -114,17 +118,41 @@ class WindSimulation { } } - for(var i = 0; i < this.wms.length; i++) { + for(var i = 0; i < this.wms.length; i++) this.wms[i].animate(); - //this.wms[i].rotation.z += 0.01; + + var speed = 0.02; + if(Math.abs(this.targetRotation - this.rotation) > speed) { + var step = speed * Math.sign(this.targetRotation - this.rotation); + this.rotation += step; + for(var i = 0; i < this.wms.length; i++) { + this.wms[i].animate(); + this.wms[i].rotation.z += step; + } + this.flag.rotation.z += step; } - //this.flag.rotation.z += 0.01; this.flag.animate(); renderer.render(scene, camera); } + setRotation(dir) { + if(this.simulation) { + scene.remove(this.simulation); + this.simulation = null; + } + + var rotations = {}; + rotations[0] = Math.PI; + rotations[270] = Math.PI / 2; + rotations[270 + 45] = Math.PI * 3 / 4; + rotations[270 - 45] = Math.PI / 4; + if(! (dir in rotations)) return false; + this.dir = dir; + this.targetRotation = rotations[dir]; + } + simulate() { if(this.xhr != null) this.xhr.abort(); @@ -144,7 +172,7 @@ class WindSimulation { var pos = []; for(var i = 0; i < this.wms.length; i++) pos.push([this.wms[i].position.y, this.wms[i].position.x]); - var data = JSON.stringify({"pos": pos}); + var data = JSON.stringify({"pos": pos, "dir": this.dir}); xhr.send(data); } diff --git a/js/windmill.js b/js/windmill.js index 7fa79e7..7251fc6 100644 --- a/js/windmill.js +++ b/js/windmill.js @@ -12,7 +12,8 @@ class WindMill extends THREE.Group { loader.load('assets/aspas_126m_85.stl', function(geometry) { WindMill.geometryBlades = geometry; }); - loader.load('assets/cuerpo_126m_50.stl', function(geometry) { + loader.load('assets/nacele_126m_90.stl', function(geometry) { + //loader.load('assets/cuerpo_126m_50.stl', function(geometry) { WindMill.geometryBody = geometry; }); } @@ -41,7 +42,15 @@ class WindMill extends THREE.Group { this.meshBody.scale.set(0.0075, 0.0075, 0.0075); this.meshBody.position.z = 90/126; - var geometry = new THREE.CircleGeometry(0.5, 20); + var geometry = new THREE.CylinderGeometry(0.02, 0.025, 90/126, 15); + this.meshPole = new THREE.Mesh(geometry, this.material); + this.meshPole.castShadow = true; + this.meshPole.receiveShadow = true; + this.meshPole.rotateX(Math.PI/2); + this.meshPole.position.z = 90/126/2; + this.meshPole.position.x = 0.02; + + geometry = new THREE.CircleGeometry(0.5, 20); this.meshCircle = new THREE.Mesh(geometry, this.materialCircle); this.meshCircle.receiveShadow = true; this.meshCircle.position.z = 0.001; @@ -49,6 +58,7 @@ class WindMill extends THREE.Group { this.add(this.meshBlades); this.add(this.meshBody); + this.add(this.meshPole); this.add(this.meshCircle); this.spring1 = new Spring(0.5, 2, 20, 6, 1, new THREE.MeshBasicMaterial({color: 0xff0000})); diff --git a/server.py b/server.py index 1b6a220..25386f8 100644 --- a/server.py +++ b/server.py @@ -10,11 +10,13 @@ def index(): if request.method != 'POST' or not request.data: return abort(400); params = json.loads(request.data.decode(encoding='utf-8')) - pos = params['pos']; - ws = xxx.run(pos); + pos = params['pos'] + direction = params['dir'] + ws = xxx.run(direction, pos); return { 'pos': pos, 'ws': ws, + 'dir': direction, } if __name__ == "__main__": diff --git a/style.css b/style.css index 83c9bcb..e5fec23 100644 --- a/style.css +++ b/style.css @@ -26,7 +26,7 @@ body { overflow-x: hidden; overflow-y: scroll; width: auto; - border: solid #fff 5px; + border: solid #fff .5vh; height: auto; background: #00000088; padding: 4vh; @@ -73,13 +73,21 @@ body { #help { position: absolute; right: 4vh; - top: 18vh; - border: solid white 3px; + top: 16vh; font-weight: 800; + font-size: .8em; +} + +#help li { + display: block; + float: left; + border: solid white .5vh; padding: .1vh 1vh; border-radius: 1vh; - font-size: .8em; - cursor: help; + cursor: pointer; + margin-left: 1vh; + width: 2.5vh; + text-align: center; } #copyright { diff --git a/xxx.py b/xxx.py index c3d485c..0a5bd90 100644 --- a/xxx.py +++ b/xxx.py @@ -71,20 +71,20 @@ def py_wake_Initial_Cong(D,name,h,U_ref,initial_position=initial_position): windTurbines = py_wake_Initial_Cong(D, 'NREL_5MW', h, U_ref) -def run(initial_position=initial_position, U_ref=U_ref): +def run(direction=0, initial_position=initial_position, U_ref=U_ref): initial_position = np.array(initial_position); - #site = UniformSite(p_wd=[1], - # ws=U_ref, - # initial_position=initial_position*D) - ds = xr.Dataset( - data_vars={'P': ('wd', [1])}, - coords={'wd': [0]}) - ds['TI'] = 0.1 - site = XRSite(ds, interp_method='nearest', initial_position=initial_position*D, default_ws=np.atleast_1d(U_ref)) + site = UniformSite(p_wd=[1] * 8, + ws=U_ref, + initial_position=initial_position*D) + #ds = xr.Dataset( + # data_vars={'P': ('wd', [1, 1, 1, 1])}, + # coords={'wd': [0, 90, 180, 270]}) + #ds['TI'] = 0.1 + #site = XRSite(ds, interp_method='nearest', initial_position=initial_position*D, default_ws=np.atleast_1d(U_ref)) wt_x, wt_y = site.initial_position.T/D wfm = PropagateDownwind(site, windTurbines, wake_deficitModel=TurboGaussianDeficit()) grid = XYGrid(x=np.arange(0, 10.01, 0.1)*126, y=np.arange(0, 10.01, 0.1)*126) - xa = wfm(x=wt_x*126, y=wt_y*126, wd=0, yaw=0).flow_map(grid) + xa = wfm(x=wt_x*126, y=wt_y*126, wd=direction, yaw=0).flow_map(grid) ws = xa.WS_eff return ws[:,:,0,0].values[:,:,0].tolist()