Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
getdp
cim
Commits
df929b41
Commit
df929b41
authored
8 years ago
by
Nicolas Marsic
Browse files
Options
Downloads
Patches
Plain Diff
getdp: computing eigenvectors and dumping them as GetDP post-processing views. seems ok.
parent
2a06ad21
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
beyn.py
+4
-3
4 additions, 3 deletions
beyn.py
main.py
+19
-5
19 additions, 5 deletions
main.py
maxwell.pro
+11
-4
11 additions, 4 deletions
maxwell.pro
solver.py
+23
-2
23 additions, 2 deletions
solver.py
with
57 additions
and
14 deletions
beyn.py
+
4
−
3
View file @
df929b41
...
...
@@ -17,7 +17,7 @@ def simple(operator, origin, radius,
rankTol -- the tolerance for the rank test (optional)
verbose -- should I be verbose? (optional)
Returns the computed eigenvalues
Returns the computed eigenvalues
and eigenvectors
"""
# Display the parameter used
...
...
@@ -71,13 +71,14 @@ def simple(operator, origin, radius,
A1
=
integrate
(
operator
,
myPath
,
1
,
vHat
)
B
=
V0
.
H
*
A1
*
W0
*
S0Inv
# Eigenvalues
of B
# Eigenvalues
& eigenvectors
if
(
verbose
):
print
"
Solving linear EVP...
"
myLambda
,
QHat
=
numpy
.
linalg
.
eig
(
B
)
Q
=
V0
*
QHat
;
# Done
if
(
verbose
):
print
"
Done!
"
return
myLambda
return
myLambda
,
Q
## Import only simple (other functions are just helpers)
...
...
This diff is collapsed.
Click to expand it.
main.py
+
19
−
5
View file @
df929b41
...
...
@@ -6,19 +6,33 @@ import numpy as np
pro
=
"
maxwell.pro
"
mesh
=
"
square.msh
"
resolution
=
"
Maxwell
"
post
=
"
Maxwell
"
# Initialise GetDP
operator
=
Solver
.
GetDPWave
(
pro
,
mesh
,
resolution
)
# Compute
v
=
Beyn
.
simple
(
operator
,
complex
(
9e8
,
0
),
1e8
)
l
,
V
=
Beyn
.
simple
(
operator
,
complex
(
9e8
,
0
),
1e8
)
# Display the computed eigenvalues
print
print
"
Eigenvalues:
"
print
"
-----------
"
for
i
in
range
(
v
.
shape
[
0
]):
print
"
(
"
+
format
(
np
.
real
(
v
[
i
]).
tolist
(),
'
+e
'
)
+
"
)
"
,
for
i
in
range
(
l
.
shape
[
0
]):
print
"
#
"
+
str
(
i
)
+
"
:
"
,
print
"
(
"
+
format
(
np
.
real
(
l
[
i
]).
tolist
(),
'
+e
'
)
+
"
)
"
,
print
"
+
"
,
print
"
(
"
+
format
(
np
.
imag
(
v
[
i
]).
tolist
(),
'
+e
'
)
+
"
)*j
"
print
"
(
"
+
format
(
np
.
imag
(
l
[
i
]).
tolist
(),
'
+e
'
)
+
"
)*j
"
print
"
-----------
"
print
"
Found:
"
+
str
(
v
.
shape
[
0
])
print
"
Found:
"
+
str
(
l
.
shape
[
0
])
# Generate GetDP views for eigenvectors
print
print
"
Generating eigenvector views...
"
for
i
in
range
(
l
.
shape
[
0
]):
operator
.
view
(
V
[:,
i
],
post
,
"
beyn
"
+
str
(
i
)
+
"
.pos
"
)
print
"
# View:
"
+
str
(
i
)
+
"
done!
"
# Done
print
print
"
return 0;
"
This diff is collapsed.
Click to expand it.
maxwell.pro
+
11
−
4
View file @
df929b41
...
...
@@ -21,7 +21,9 @@ Function{
d
()
=
{}];
//
DoFs
//
Control
data
//
DefineConstant
[
imposeRHS
=
0
];
//
Should
I
use
an
imposed
RHS
?
DefineConstant
[
imposeRHS
=
0
,
//
Should
I
use
an
imposed
RHS
?
viewOnly
=
0
,
//
Should
I
use
X
for
postpro
only
?
fileName
=
"eig.pos"
];
//
Postpro
file
name
}
Jacobian
{
...
...
@@ -93,8 +95,13 @@ Resolution{
CopyRightHandSide
[
b
(),
A
];
EndIf
Solve
[
A
];
CopySolution
[
A
,
x
()];
If
(!
viewOnly
)
Solve
[
A
];
CopySolution
[
A
,
x
()];
EndIf
If
(
viewOnly
)
CopySolution
[
x
(),
A
];
EndIf
}
}
}
...
...
@@ -110,7 +117,7 @@ PostProcessing{
PostOperation
{
{
Name
Maxwell
;
NameOfPostProcessing
Maxwell
;
Operation
{
Print
[
e
,
OnElementsOf
Omega
,
File
"maxwell.pos"
];
Print
[
e
,
OnElementsOf
Omega
,
File
fileName
];
}
}
}
This diff is collapsed.
Click to expand it.
solver.py
+
23
−
2
View file @
df929b41
...
...
@@ -12,6 +12,8 @@ class GetDPWave:
b -- the right hand side (RHS) to use
x -- the solution vector computed by GetDP
imposeRHS -- should the imposed RHS be taken into account?
viewOnly -- should x be used for post-processing only
fileName -- post-processing file name
"""
def
__init__
(
self
,
pro
,
mesh
,
resolution
):
...
...
@@ -49,8 +51,27 @@ class GetDPWave:
GetDP
.
GetDPSetNumber
(
"
imposeRHS
"
,
1
)
GetDP
.
GetDP
([
"
getdp
"
,
self
.
__pro
,
"
-msh
"
,
self
.
__mesh
,
"
-cal
"
,
self
.
__resolution
,
"
-v
"
,
"
2
"
])
"
-cal
"
])
GetDP
.
GetDPSetNumber
(
"
imposeRHS
"
,
0
)
def
view
(
self
,
x
,
posName
,
fileName
):
"""
Generates a post-processing view
Keyword arguments:
x -- the solution vector to use
posName -- the post-operation to use (from the .pro file)
fileName -- the post-precessing file name
This method generates a linear system
"""
GetDP
.
GetDPSetNumber
(
"
x
"
,
self
.
__toGetDP
(
x
))
GetDP
.
GetDPSetNumber
(
"
viewOnly
"
,
1
)
GetDP
.
GetDPSetString
(
"
fileName
"
,
fileName
)
GetDP
.
GetDP
([
"
getdp
"
,
self
.
__pro
,
"
-msh
"
,
self
.
__mesh
,
"
-cal
"
,
"
-pos
"
,
posName
])
GetDP
.
GetDPSetNumber
(
"
viewOnly
"
,
0
)
@staticmethod
def
__toNumpy
(
vGetDP
):
...
...
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