Skip to content
Snippets Groups Projects
Commit af63cbcf authored by Erin Kuci's avatar Erin Kuci
Browse files
parents a6186eb1 7ecb9e25
No related branches found
No related tags found
No related merge requests found
......@@ -68,7 +68,7 @@ elements = np.array(d[1::2]) # [ele1, ..., eleN ]
#x = np.array(d[2::2]) # [xe1, ..., xeN]
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
# an ElementTable variable [N, ele1, xe1, ..., eleN, xeN]
......@@ -175,11 +175,11 @@ while change > maxChange and it <= maxIter and c.getString('topo/Action') != 'st
objective *= fscale
grad_objective *= fscale
print '*'*50
print 'iteration: ', it
print 'change: ', change
print 'objective:', objective
print 'constraints:', constraints
print('*'*50)
print('iteration: ', it)
print('change: ', change)
print('objective:', objective)
print('constraints:', constraints)
c.sendInfo('Optimization: it. {}, obj. {}, constr. {}, change {}'.format(it,objective,constraints[0], change))
# call MMA and update the current point
......
......@@ -332,8 +332,8 @@ PostOperation {
Format SimpleTable, File StrCat[Opt_ResDir,"bMag.txt"]];
Print[az, OnElementsOf Domain, Format NodeTable, File "",
SendToServer StrCat[Opt_ResDir_Onelab,"a"], Hidden 1];
//Print[bMag, OnElementsOf Domain, File StrCat[Opt_ResDir,"az.pos"]];
//Print[az, 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[bTarget, OnGrid {(9.5e-3+2.25e-3)*Cos[$A],(9.5e-3+2.25e-3)*Sin[$A],0}{0:50*Pi/180:5*Pi/180,0,0},
File StrCat[Opt_ResDir,"bTarget.pos"]];
Print[b, OnGrid {(9.5e-3+2.25e-3)*Cos[$A],(9.5e-3+2.25e-3)*Sin[$A],0}{0:50*Pi/180:5*Pi/180,0,0},
......
# Open this file with Gmsh (interactively with File->Open->penning.py, or on the
# command line with 'gmsh penning.py')
# Open this file with Gmsh (interactively with File->Open->shape.py, or on the
# command line with 'gmsh shape.py')
#
from shutil import copyfile
import numpy as np
import optlab
import onelab
......@@ -39,8 +39,7 @@ c.openProject(file_geo)
# dry getdp run (without -solve or -pos option) to get model parameters in the GUI
c.runSubClient('myGetDP', mygetdp)
# define now optimization parameters
# some of them as Onelab parameter, to be editable in the GUI
# define optimization parameters as Onelab parameter (editable in the GUI)
maxIter = c.defineNumber('Optimization/00Max iterations', value=100)
maxChange = c.defineNumber('Optimization/01Max change', value=1e-5)
......@@ -163,12 +162,12 @@ while it <= maxIter and c.getString('shape/Action') != 'stop':
objective *= fscale
grad_objective *= fscale
print '*'*50
print 'iteration: ', it
print 'change: ', change
print 'current point:', xFromMMA
print 'objective:', objective
print 'constraints:', constraints
print('*'*50)
print('iteration: ', it)
print('change: ', change)
print('current point:', xFromMMA)
print('objective:', objective)
print('constraints:', constraints)
c.sendInfo('Optimization: it. {}, obj. {}, constr. {}'.format(it,objective,constraints[0]))
# call MMA and update the current point
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment