Skip to content
Snippets Groups Projects
Commit 131abb5e authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

e field matrix drawing

parent 78e2fe43
No related branches found
No related tags found
No related merge requests found
...@@ -160,6 +160,7 @@ require.config({ ...@@ -160,6 +160,7 @@ require.config({
latticeESim: 'simulation/electronics/LatticeEsim', latticeESim: 'simulation/electronics/LatticeEsim',
eSimCell: 'simulation/electronics/cells/eSimCell', eSimCell: 'simulation/electronics/cells/eSimCell',
eSimSuperCell: 'simulation/electronics/cells/eSimSuperCell', eSimSuperCell: 'simulation/electronics/cells/eSimSuperCell',
eSimField: 'simulation/electronics/eSimField',
//cam //cam
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
* Created by aghassaei on 6/30/15. * Created by aghassaei on 6/30/15.
*/ */
define(['lattice', 'appState', 'threeModel', 'eSim', 'eSimCell', 'eSimSuperCell'], function(lattice, appState, three, eSim){ define(['lattice', 'appState', 'three', 'threeModel', 'eSim', 'eSimCell', 'eSimSuperCell'],
function(lattice, appState, THREE, three, eSim){
...@@ -70,6 +71,12 @@ define(['lattice', 'appState', 'threeModel', 'eSim', 'eSimCell', 'eSimSuperCell' ...@@ -70,6 +71,12 @@ define(['lattice', 'appState', 'threeModel', 'eSim', 'eSimCell', 'eSimSuperCell'
}, },
calcEField: function(conductorGroups, resolution){ calcEField: function(conductorGroups, resolution){
if (this.numCells == 0){
console.warn("no cells!");
return;
}
var eFieldMat = []; var eFieldMat = [];
//init size of field mat and fill with zeros, +2 puts a shell of zeros at boundary (infinity) //init size of field mat and fill with zeros, +2 puts a shell of zeros at boundary (infinity)
for (var x=0;x<resolution*this.cells.length+2;x++){ for (var x=0;x<resolution*this.cells.length+2;x++){
...@@ -82,6 +89,7 @@ define(['lattice', 'appState', 'threeModel', 'eSim', 'eSimCell', 'eSimSuperCell' ...@@ -82,6 +89,7 @@ define(['lattice', 'appState', 'threeModel', 'eSim', 'eSimCell', 'eSimSuperCell'
} }
} }
//input conductor potentials
this._loopCells(this.cells, function(cell, x, y, z){ this._loopCells(this.cells, function(cell, x, y, z){
if (!cell) return; if (!cell) return;
for (var i=0;i<resolution;i++){ for (var i=0;i<resolution;i++){
...@@ -94,6 +102,13 @@ define(['lattice', 'appState', 'threeModel', 'eSim', 'eSimCell', 'eSimSuperCell' ...@@ -94,6 +102,13 @@ define(['lattice', 'appState', 'threeModel', 'eSim', 'eSimCell', 'eSimSuperCell'
}); });
console.log(eFieldMat); console.log(eFieldMat);
console.log(this.get("cellsMin"));
var offset = this.get("cellsMin").clone().sub(new THREE.Vector3(1/(2*resolution)+this.xScale(0)/2, 1/(2*resolution)+this.yScale(0)/2, 1/(2*resolution)+this.zScale(0)/2));
console.log(offset);
require(['eSimField'], function(ESimField){
eSim.set("electricField", new ESimField(eFieldMat, offset, resolution));
});
}, },
calcCapacitance: function(){ calcCapacitance: function(){
......
/**
* Created by aghassaei on 8/10/15.
*/
//hold and display data for various fields
define(['underscore', 'threeModel'], function(_, threeModel){
function ESimField(data, offset, resolution){
this._data = data;
this._offset = offset;
this._createThreeObjects(data, offset, 1/resolution);
}
ESimField.prototype._createThreeObjects = function(data, offset, size){
var threeObjects = [];
for (var x=0;x<data.length;x++){
threeObjects.push([]);
for (var y=0;y<data[0].length;y++){
threeObjects[x].push([]);
for (var z=0;z<data[0][0].length;z++){
var box = new THREE.Mesh(new THREE.BoxGeometry(size, size, size), new THREE.MeshLambertMaterial({color:"#ff0000"}));
box.position.set(x*size+offset.x, y*size+offset.y, z*size+offset.z);
threeModel.sceneAdd(box);
threeObjects[x][y].push(box);
}
}
}
threeModel.render();
};
ESimField.prototype.show = function(height){
var data = [];
for (var x=0;x<this._data.length;x++){
data.push([]);
for (var y=0;y<this._data[x].length;y++){
data[x].push(this._data[x][y][height]);
}
}
};
ESimField.prototype.hide = function(){
};
ESimField.prototype._loopCells = function(data, callback){
for (var x=0;x<data.length;x++){
for (var y=0;y<data[0].length;y++){
for (var z=0;z<data[0][0].length;z++){
callback(data[x][y][z], x, y, z, this);
}
}
}
};
return ESimField;
});
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment