Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DMDesign
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amanda Ghassaei
DMDesign
Commits
543d99b7
Commit
543d99b7
authored
9 years ago
by
Amanda Ghassaei
Browse files
Options
Downloads
Patches
Plain Diff
eod
parent
de3aac14
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
js/simulation/electronics/LatticeEsim.js
+60
-19
60 additions, 19 deletions
js/simulation/electronics/LatticeEsim.js
with
60 additions
and
19 deletions
js/simulation/electronics/LatticeEsim.js
+
60
−
19
View file @
543d99b7
...
...
@@ -77,14 +77,14 @@ define(['lattice', 'appState', 'three', 'threeModel', 'numeric', 'eSim', 'eSimFi
return
;
}
var
eField
Mat
=
[];
var
potential
Mat
=
[];
//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
++
){
eField
Mat
.
push
([]);
potential
Mat
.
push
([]);
for
(
var
y
=
0
;
y
<
resolution
*
this
.
cells
[
0
].
length
+
2
;
y
++
){
eField
Mat
[
x
].
push
([]);
potential
Mat
[
x
].
push
([]);
for
(
var
z
=
0
;
z
<
resolution
*
this
.
cells
[
0
][
0
].
length
+
2
;
z
++
){
eField
Mat
[
x
][
y
].
push
(
0
);
potential
Mat
[
x
][
y
].
push
(
0
);
}
}
}
...
...
@@ -95,7 +95,7 @@ define(['lattice', 'appState', 'three', 'threeModel', 'numeric', 'eSim', 'eSimFi
for
(
var
i
=
0
;
i
<
resolution
;
i
++
){
for
(
var
j
=
0
;
j
<
resolution
;
j
++
){
for
(
var
k
=
0
;
k
<
resolution
;
k
++
){
if
(
cell
)
eField
Mat
[
resolution
*
x
+
i
+
1
][
resolution
*
y
+
j
+
1
][
resolution
*
z
+
k
+
1
]
=
if
(
cell
)
potential
Mat
[
resolution
*
x
+
i
+
1
][
resolution
*
y
+
j
+
1
][
resolution
*
z
+
k
+
1
]
=
conductorGroups
[
cell
.
getConductorGroupNum
()].
voltage
;
}
}
...
...
@@ -109,8 +109,8 @@ define(['lattice', 'appState', 'three', 'threeModel', 'numeric', 'eSim', 'eSimFi
});
//create potential field
var
potentialData
=
numeric
.
clone
(
eField
Mat
);
//create
raw
potential field
var
potentialData
=
numeric
.
clone
(
potential
Mat
);
if
(
eSim
.
get
(
"
rawPotentialField
"
)){
eSim
.
get
(
"
rawPotentialField
"
).
setData
(
potentialData
,
offset
,
resolution
,
eSim
.
get
(
"
simZHeight
"
),
dataRange
);
}
else
{
...
...
@@ -120,36 +120,77 @@ define(['lattice', 'appState', 'three', 'threeModel', 'numeric', 'eSim', 'eSimFi
for
(
var
i
=
0
;
i
<
numRelaxationSteps
;
i
++
){
var
temp
=
numeric
.
clone
(
eFieldMat
);
console
.
log
(
temp
[
5
][
5
][
4
]);
var
temp
=
numeric
.
clone
(
potentialMat
);
for
(
var
x
=
0
;
x
<
temp
.
length
;
x
++
){
for
(
var
y
=
0
;
y
<
temp
[
x
].
length
;
y
++
){
for
(
var
z
=
0
;
z
<
temp
[
x
][
y
].
length
;
z
++
){
if
(
potentialData
[
x
][
y
][
z
]
!=
0
)
continue
;
var
avg
=
0
;
if
(
x
>
0
)
avg
+=
eField
Mat
[
x
-
1
][
y
][
z
];
if
(
x
<
temp
.
length
-
1
)
avg
+=
eField
Mat
[
x
+
1
][
y
][
z
];
if
(
y
>
0
)
avg
+=
eField
Mat
[
x
][
y
-
1
][
z
];
if
(
y
<
temp
[
x
].
length
-
1
)
avg
+=
eField
Mat
[
x
][
y
+
1
][
z
];
if
(
z
>
0
)
avg
+=
eField
Mat
[
x
][
y
][
z
-
1
];
if
(
z
<
temp
[
x
][
y
].
length
-
1
)
avg
+=
eField
Mat
[
x
][
y
][
z
+
1
];
if
(
x
>
0
)
avg
+=
potential
Mat
[
x
-
1
][
y
][
z
];
if
(
x
<
temp
.
length
-
1
)
avg
+=
potential
Mat
[
x
+
1
][
y
][
z
];
if
(
y
>
0
)
avg
+=
potential
Mat
[
x
][
y
-
1
][
z
];
if
(
y
<
temp
[
x
].
length
-
1
)
avg
+=
potential
Mat
[
x
][
y
+
1
][
z
];
if
(
z
>
0
)
avg
+=
potential
Mat
[
x
][
y
][
z
-
1
];
if
(
z
<
temp
[
x
][
y
].
length
-
1
)
avg
+=
potential
Mat
[
x
][
y
][
z
+
1
];
temp
[
x
][
y
][
z
]
=
avg
/
6.0
;
}
}
}
eFieldMat
=
numeric
.
clone
(
temp
)
;
potentialMat
=
temp
;
console
.
log
(
"
hi
"
);
}
//create
electric
field
//create
potential
field
if
(
eSim
.
get
(
"
potentialField
"
)){
eSim
.
get
(
"
potentialField
"
).
setData
(
eField
Mat
,
offset
,
resolution
,
eSim
.
get
(
"
simZHeight
"
),
dataRange
);
eSim
.
get
(
"
potentialField
"
).
setData
(
potential
Mat
,
offset
,
resolution
,
eSim
.
get
(
"
simZHeight
"
),
dataRange
);
}
else
{
eSim
.
set
(
"
potentialField
"
,
new
ESimField
(
eField
Mat
,
offset
,
resolution
,
eSim
.
get
(
"
simZHeight
"
),
dataRange
));
eSim
.
set
(
"
potentialField
"
,
new
ESimField
(
potential
Mat
,
offset
,
resolution
,
eSim
.
get
(
"
simZHeight
"
),
dataRange
));
}
eSim
.
set
(
"
visibleStaticSim
"
,
"
potentialField
"
);
//will cause render
//create electric field
var
eFieldMat
=
numeric
.
clone
(
potentialMat
);
for
(
var
x
=
0
;
x
<
eFieldMat
.
length
-
1
;
x
++
){
for
(
var
y
=
0
;
y
<
eFieldMat
[
x
].
length
-
1
;
y
++
){
for
(
var
z
=
0
;
z
<
eFieldMat
[
x
][
y
].
length
-
1
;
z
++
){
var
currentVal
=
eFieldMat
[
x
][
y
][
z
];
eFieldMat
[
x
][
y
][
z
]
=
Math
.
sqrt
(
Math
.
pow
(
eFieldMat
[
x
+
1
][
y
][
z
]
-
currentVal
,
2
)
+
Math
.
pow
(
eFieldMat
[
x
][
y
+
1
][
z
]
-
currentVal
,
2
)
+
Math
.
pow
(
eFieldMat
[
x
][
y
][
z
+
1
]
-
currentVal
,
2
))
}
}
}
if
(
eSim
.
get
(
"
electricField
"
)){
eSim
.
get
(
"
electricField
"
).
setData
(
eFieldMat
,
offset
,
resolution
,
eSim
.
get
(
"
simZHeight
"
),
dataRange
);
}
else
{
eSim
.
set
(
"
electricField
"
,
new
ESimField
(
eFieldMat
,
offset
,
resolution
,
eSim
.
get
(
"
simZHeight
"
),
dataRange
));
}
eSim
.
set
(
"
visibleStaticSim
"
,
"
electricField
"
);
//will cause render
//create charge distribution
var
chargeMat
=
numeric
.
clone
(
potentialMat
);
for
(
var
x
=
0
;
x
<
eFieldMat
.
length
-
1
;
x
++
){
for
(
var
y
=
0
;
y
<
eFieldMat
[
x
].
length
-
1
;
y
++
){
for
(
var
z
=
0
;
z
<
eFieldMat
[
x
][
y
].
length
-
1
;
z
++
){
var
sum
=
0
;
if
(
x
>
0
)
sum
+=
potentialMat
[
x
-
1
][
y
][
z
];
if
(
x
<
temp
.
length
-
1
)
sum
+=
potentialMat
[
x
+
1
][
y
][
z
];
if
(
y
>
0
)
sum
+=
potentialMat
[
x
][
y
-
1
][
z
];
if
(
y
<
temp
[
x
].
length
-
1
)
sum
+=
potentialMat
[
x
][
y
+
1
][
z
];
if
(
z
>
0
)
sum
+=
potentialMat
[
x
][
y
][
z
-
1
];
if
(
z
<
temp
[
x
][
y
].
length
-
1
)
sum
+=
potentialMat
[
x
][
y
][
z
+
1
];
chargeMat
[
x
][
y
][
z
]
=
10
*
(
sum
+
6
*
eFieldMat
[
x
][
y
][
z
]);
}
}
}
if
(
eSim
.
get
(
"
chargeField
"
)){
eSim
.
get
(
"
chargeField
"
).
setData
(
chargeMat
,
offset
,
resolution
,
eSim
.
get
(
"
simZHeight
"
),
dataRange
);
}
else
{
eSim
.
set
(
"
chargeField
"
,
new
ESimField
(
chargeMat
,
offset
,
resolution
,
eSim
.
get
(
"
simZHeight
"
),
dataRange
));
}
eSim
.
set
(
"
visibleStaticSim
"
,
"
chargeField
"
);
//will cause render
// -10*(P15+Q14+R15+Q16-4*Q15)
},
calcCapacitance
:
function
(){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment