Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tutorials
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
conveks
tutorials
Commits
af63cbcf
Commit
af63cbcf
authored
6 years ago
by
Erin Kuci
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://gitlab.onelab.info/optlab/tutorials
parents
a6186eb1
7ecb9e25
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Lbracket/topo.py
+8
-8
8 additions, 8 deletions
Lbracket/topo.py
Team25/shape.pro
+2
-2
2 additions, 2 deletions
Team25/shape.pro
Team25/shape.py
+10
-11
10 additions, 11 deletions
Team25/shape.py
with
20 additions
and
21 deletions
Lbracket/topo.py
+
8
−
8
View file @
af63cbcf
...
@@ -68,7 +68,7 @@ elements = np.array(d[1::2]) # [ele1, ..., eleN ]
...
@@ -68,7 +68,7 @@ elements = np.array(d[1::2]) # [ele1, ..., eleN ]
#x = np.array(d[2::2]) # [xe1, ..., xeN]
#x = np.array(d[2::2]) # [xe1, ..., xeN]
x
=
0.5
*
np
.
ones
(
numElements
)
x
=
0.5
*
np
.
ones
(
numElements
)
print
'
number of elements in topology optimization:
'
,
numElements
print
(
'
number of elements in topology optimization:
'
,
numElements
)
# This function serializes the python variables 'ele' and 'var' into
# This function serializes the python variables 'ele' and 'var' into
# an ElementTable variable [N, ele1, xe1, ..., eleN, xeN]
# an ElementTable variable [N, ele1, xe1, ..., eleN, xeN]
...
@@ -175,11 +175,11 @@ while change > maxChange and it <= maxIter and c.getString('topo/Action') != 'st
...
@@ -175,11 +175,11 @@ while change > maxChange and it <= maxIter and c.getString('topo/Action') != 'st
objective
*=
fscale
objective
*=
fscale
grad_objective
*=
fscale
grad_objective
*=
fscale
print
'
*
'
*
50
print
(
'
*
'
*
50
)
print
'
iteration:
'
,
it
print
(
'
iteration:
'
,
it
)
print
'
change:
'
,
change
print
(
'
change:
'
,
change
)
print
'
objective:
'
,
objective
print
(
'
objective:
'
,
objective
)
print
'
constraints:
'
,
constraints
print
(
'
constraints:
'
,
constraints
)
c
.
sendInfo
(
'
Optimization: it. {}, obj. {}, constr. {}, change {}
'
.
format
(
it
,
objective
,
constraints
[
0
],
change
))
c
.
sendInfo
(
'
Optimization: it. {}, obj. {}, constr. {}, change {}
'
.
format
(
it
,
objective
,
constraints
[
0
],
change
))
# call MMA and update the current point
# call MMA and update the current point
...
...
This diff is collapsed.
Click to expand it.
Team25/shape.pro
+
2
−
2
View file @
af63cbcf
...
@@ -332,8 +332,8 @@ PostOperation {
...
@@ -332,8 +332,8 @@ PostOperation {
Format
SimpleTable
,
File
StrCat
[
Opt_ResDir
,
"bMag.txt"
]];
Format
SimpleTable
,
File
StrCat
[
Opt_ResDir
,
"bMag.txt"
]];
Print
[
az
,
OnElementsOf
Domain
,
Format
NodeTable
,
File
""
,
Print
[
az
,
OnElementsOf
Domain
,
Format
NodeTable
,
File
""
,
SendToServer
StrCat
[
Opt_ResDir_Onelab
,
"a"
],
Hidden
1
];
SendToServer
StrCat
[
Opt_ResDir_Onelab
,
"a"
],
Hidden
1
];
//
Print
[
bMag
,
OnElementsOf
Domain
,
File
StrCat
[
Opt_ResDir
,
"az.pos"
]];
Print
[
bMag
,
OnElementsOf
Domain
,
File
StrCat
[
Opt_ResDir
,
"az.pos"
]];
//
Print
[
az
,
OnElementsOf
Domain
,
File
StrCat
[
Opt_ResDir
,
"az.pos"
]];
Print
[
az
,
OnElementsOf
Domain
,
File
StrCat
[
Opt_ResDir
,
"az.pos"
]];
Print
[
bTarget
,
OnGrid
{(
9.5
e
-
3
+
2.25
e
-
3
)
*
Cos
[
$
A
],(
9.5
e
-
3
+
2.25
e
-
3
)
*
Sin
[
$
A
],
0
}{
0
:
50
*
Pi
/
180
:
5
*
Pi
/
180
,
0
,
0
},
Print
[
bTarget
,
OnGrid
{(
9.5
e
-
3
+
2.25
e
-
3
)
*
Cos
[
$
A
],(
9.5
e
-
3
+
2.25
e
-
3
)
*
Sin
[
$
A
],
0
}{
0
:
50
*
Pi
/
180
:
5
*
Pi
/
180
,
0
,
0
},
File
StrCat
[
Opt_ResDir
,
"bTarget.pos"
]];
File
StrCat
[
Opt_ResDir
,
"bTarget.pos"
]];
Print
[
b
,
OnGrid
{(
9.5
e
-
3
+
2.25
e
-
3
)
*
Cos
[
$
A
],(
9.5
e
-
3
+
2.25
e
-
3
)
*
Sin
[
$
A
],
0
}{
0
:
50
*
Pi
/
180
:
5
*
Pi
/
180
,
0
,
0
},
Print
[
b
,
OnGrid
{(
9.5
e
-
3
+
2.25
e
-
3
)
*
Cos
[
$
A
],(
9.5
e
-
3
+
2.25
e
-
3
)
*
Sin
[
$
A
],
0
}{
0
:
50
*
Pi
/
180
:
5
*
Pi
/
180
,
0
,
0
},
...
...
This diff is collapsed.
Click to expand it.
Team25/shape.py
+
10
−
11
View file @
af63cbcf
# Open this file with Gmsh (interactively with File->Open->
penning
.py, or on the
# Open this file with Gmsh (interactively with File->Open->
shape
.py, or on the
# command line with 'gmsh
penning
.py')
# command line with 'gmsh
shape
.py')
#
#
from
shutil
import
copyfile
import
numpy
as
np
import
numpy
as
np
import
optlab
import
optlab
import
onelab
import
onelab
...
@@ -39,8 +39,7 @@ c.openProject(file_geo)
...
@@ -39,8 +39,7 @@ c.openProject(file_geo)
# dry getdp run (without -solve or -pos option) to get model parameters in the GUI
# dry getdp run (without -solve or -pos option) to get model parameters in the GUI
c
.
runSubClient
(
'
myGetDP
'
,
mygetdp
)
c
.
runSubClient
(
'
myGetDP
'
,
mygetdp
)
# define now optimization parameters
# define optimization parameters as Onelab parameter (editable in the GUI)
# some of them as Onelab parameter, to be editable in the GUI
maxIter
=
c
.
defineNumber
(
'
Optimization/00Max iterations
'
,
value
=
100
)
maxIter
=
c
.
defineNumber
(
'
Optimization/00Max iterations
'
,
value
=
100
)
maxChange
=
c
.
defineNumber
(
'
Optimization/01Max change
'
,
value
=
1e-5
)
maxChange
=
c
.
defineNumber
(
'
Optimization/01Max change
'
,
value
=
1e-5
)
...
@@ -163,12 +162,12 @@ while it <= maxIter and c.getString('shape/Action') != 'stop':
...
@@ -163,12 +162,12 @@ while it <= maxIter and c.getString('shape/Action') != 'stop':
objective
*=
fscale
objective
*=
fscale
grad_objective
*=
fscale
grad_objective
*=
fscale
print
'
*
'
*
50
print
(
'
*
'
*
50
)
print
'
iteration:
'
,
it
print
(
'
iteration:
'
,
it
)
print
'
change:
'
,
change
print
(
'
change:
'
,
change
)
print
'
current point:
'
,
xFromMMA
print
(
'
current point:
'
,
xFromMMA
)
print
'
objective:
'
,
objective
print
(
'
objective:
'
,
objective
)
print
'
constraints:
'
,
constraints
print
(
'
constraints:
'
,
constraints
)
c
.
sendInfo
(
'
Optimization: it. {}, obj. {}, constr. {}
'
.
format
(
it
,
objective
,
constraints
[
0
]))
c
.
sendInfo
(
'
Optimization: it. {}, obj. {}, constr. {}
'
.
format
(
it
,
objective
,
constraints
[
0
]))
# call MMA and update the current point
# call MMA and update the current point
...
...
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