Title: ?e?t?st?p???s? st? ANSYS
1- ?e?t?st?p???s? st? ANSYS µe ???s? e??te?????
????sµ????
2Ge????
G????? ?e?a??te?? p??ß??µa ße?t?st?p???s?? de?
?p???e? µ???d?? p?? ?a d??e? t? ß??t?st? se ??e?
t?? pe??pt?se?? ?a? µe t? µ????te?? p?????
???se?? t?? a?t??e?µe????? s????t?s??
(evaluations). ??t??eta, ?p?????? p????? µ???d??
p??, ?p? s?????e?, ap?te???? ??a??p???t????
µ???d?? ??a t?? ep???s? p??ß??µ?t??
ße?t?st?p???s??
ANSYS ?d?a?te?a d??at? ep???t? ??a ??a s?µa?t???
p????? p??ß??µ?t??, µ??a?????, ?e?µ????,
e?ast????, e?ast?d??aµ????, s??d?asµ???? s???????
(multiphysics) ?t?. ?e?????sµ??? p?????
ße?t?st?p???t?? ?? p??? t? µ???d?
t? ep????? pa?aµ?t???
S????OS a?a??te?ta? t??p?? ???s?? t?? ????sµ????
Ansys (ep???t?? ?S) ?a? ????? ??d??a ? ????sµ????
?? ße?t?st?p???t?.
3??de?????µe?? µe??d?????a
?p?????st??? µ???d?? ANSYS ?e?t?st?p???s?
Matlab ? Fortran
S??e??as?a d?? ????sµ????
- µ?s? a??e??? ?p??? - ????? (s??e??? a?a???s?
ded?µ???? ap? s????? d?s??) ?p?fe????ta?
p??ß??µata ep????????a? st? µ??µ? - µ?s? µ??µ?? ?/? ?????? ep?p?d?? ?a??? -
???ß??µata ep????????a?
?p????? µ?s? e?d??µes?? a??e??? se d?? f?se??
ep????????a?
?e????, ?a?e?ta? µ?a s????t?s? ? ?p????t??a
(function ? subroutine) ??a t?? ?p?????sµ? t??
µe?e??? p?? s?µµet????? st? s????t?s? ??st???
(ANSYS) ?a? t?? s????t?s?? ??st??? ?a? µ?a ??a
t?? ???p???s? t?? ße?t?st?p???s??
Kata??af? t?? a??e??? d?a??sµat?? (1? F?s?) ???s?
t?? ????sµ???? ??a t?? ep???s? ??????s? t?? t?µ??
t?? s????t?s?? ??st??? (2? F?s?).
4?e??e??µe?? a??e??? ep????????a?
1? F?s? ep????????a? ???e?? ???? d?a??sµat??
µetaß??t?? s?ed?as??
- ? ße?t?st?p???t?? pa???e? d????sµa t?µ?? t??
µetaß??t?? s?ed?as?? - p??pe? ?a ???e? a?????s? t?? t?µ?? a?t?? ap? t??
ep???t? ?a? ??a ep???s?
S????OS p??pe? ?a ??afe? se t?t??a µ??f? ?ste ?a
e??a? e????a a???p???s?µ? ap? t? Ansys
2? F?s? ep????????a? ???e?? t?µ?? s????t?s??
??st???
- t? Ansys ?p??????e? t?? t?µ? t?? s????t?s??
??st??? (.lgw) - p??pe? ?a t?? d?se? st? ße?t?st?p???t? ?ste
- µet? ap? d?ad??as?a s?????s?? µe t?? p??????µe??
t?µ? ?a epa?a??f??? ? ß????? ße?t?st?p???s??
S????OS p??pe? ?a ??afe? se t?t??a µ??f? ?ste ?a
e??a? e????a a???p???s?µ? ap? t?? ße?t?st?p???t?
5?e????af? ???ß??µat??
u(x)
L10
y
y
c
d
L10
b
a
x
61? F?s? ep????????a?
?ata??af? µetaß??t?? s?ed?as?? se a??e??
Matlab ?.? ?? s?ed?as?? af????? st? µ??e??? ?a?
t? ??s? ?p??. S??teta?µ??e? ???t??? ?(x1,y1) ?a?
a?t??a r1. fid fopen('newx1','w') ?????µa
a??e??? newx1 ??a e???af? w
fprintf(fid,'x1 20.15f\n',x(1)) ?1 ??af?
character fprintf(fid,'y1
20.15f\n',x(2)) 20.15f 20 st???e?a 15
de?ad??? fprintf(fid,'r1
20.15f\n',x(3)) \n se ??a ??aµµ?
fclose(fid) ??e?s?µ? t?? a??e??? st?
µetaß??t? fid ?? ? ße?t?st?p???t?? e??a? se
Fortran µe t?? ?d?a ?????? ?? e?t???? e??a?
open(12,file 'newx1') ?????µa a??e??? newx1
(12) write(12,) 'x1', x(1) ?ata??af? x1
????? µ??f?p???s? write(12,) 'y1,
x(2) write(12,) 'r1', x(3) close(12) ??e?s?µ?
a??e??? 12
?a?at???s? ?? ANSYS e??a? ßas?sµ??? st? Fortran,
?p?te de ??e???eta? e?d??? µ??f?p???s? t? a??e??
72? F?s? ep????????a?
?ata??af? t?? t?µ?? t?? a?t??e?µe????? s????t?s??
(fun) se a??e?? (f.txt). ANSYS CFOPEN,'f','txt'
,' ' ?????µa a??e??? f µe ?at?????
txt VWRITE,fun, , , , , , , , , ?ata??af?
d?a??sµat?? (vector) fun (f29.14) µe µ??f? 29
st???e??? ?a? 14 de?ad???? CFCLOS ??e?se t?
a??e??
??????s? a??e??? Matlab ? load f.txt Fortran ?
open(13,file'f.txt') read(13,)f
close(13)
8function f my_fun4(x) global hist_all hist_best
nfv fmin xx' f0 x1(1)x(1) x1(2)x(2)
x1(3)x(3) fid fopen('newx1','w')
fprintf(fid,'20.15f\n',x1(1))
fprintf(fid,'20.15f\n',x1(2))b
fprintf(fid,'20.15f\n',x1(3)) fclose(fid) !"C
\Program Files\Ansys Inc\v120\ANSYS\bin\Intel\ANSY
S.EXE" -p STRUCT -b nolist -i INPUT1.lgw -o
out1.out load f.txt if flt10e10 nfvnfv1 if
fmingtf fminf hist_besthist_best nfv
fmin x1 end hist_allhist_all nfv f x1
end end
9clear all clc for i110 format long global
hist_all hist_best nfv fmin hist_best
hist_all nfv0 fmin10e9 optionsgaoptimset
('Generations',150,'StallTimeLimit',Inf,'StallGenL
imit',Inf,'PopInitRange',0.510,'PopulationSize'
,24) i x2 fval, reason ga(_at_my_fun4,
4,options) if i1 save ga1.mat elseif i2
save ga2.mat elseif i3 save
ga3.mat .. elseif i10 save ga10.mat
end xfminsearch(_at_my_fun4,x2) if i1 save
fmin1.mat elseif i2 save fmin2.mat . elseif
i10 save fmin10.mat end end
optionsgaoptimset('Generations',100,'StallTimeL
imit',Inf,'StallGenLimit',Inf,'PopInitRange',0.5
10,'PopulationSize',36,'PlotFcns',_at_gaplotbestf,'P
lotFcns',_at_gaplotbestindiv,'HybridFcn',_at_fminsearch)
10??ad??as?a st? ANSYS
ANSYS ?atas?e?? a??e??? Ansys Input.lgw
(pe????af? f?s???? p??ß??µat??) ?p?? se pe??pt?s?
???s?? es?te????? ??d??a ße?t?st?p???s?? ?atas?e?
? ß????t???? a??e??? ?p?? ?a pe???aµß????ta? ??
??e? t?µ?? t?? pa?aµ?t??? (µetaß??t?? s?ed?as??)
??a t? ??a ep???s? ?atas?e?? ß????t???? a??e???
µe t? t?µ? t?? a?t??e?µe????? s????t?s??
??af???? st? Input.lgw 1.???s???? e?t???? /INPUT
? PARRES µet? ap? t?? ??aµµ?? ?p?? ??????ta? ??
t?µ?? t?? µetaß??t?? s?ed?as?? (µp??e? ?a ???e?
?a? a?t??at?stas? t???) 2.?ata??af? t?? t?µ?? t??
a?t??e?µe????? s????t?s?? se a??e?? (vwrite
?ata??af? t?µ?? pa?aµ?t??? se a??e??)
??te?e?ta? t? input a??e?? (?p?? ?at? t??
es?te???? ße?t?st?p???s?) a??? ? a??a?? t?? t?µ??
t?? µetaß??t?? ???eta? ap? t? a??e??
newx1 PARRES,CHANGE,'newx1',, ' (µp??e? ap??
?a a??????e? sß??e? t?? p??????µe?e?
t?µ??) ?p??e? ?a ???e? ?a? µe t?? e?t??? /input
11???s? t?? Ansys ??a ep???s?
- G?a Matlab
- !"C\Program Files\Ansys Inc\v100\ANSYS\bin\Intel\
ANSYS.EXE" -p STRUCT -b nolist -i input1.lgw -o
out1.out - ! ??t??es? e?t????
- -p ep????? ap? t? Ansys (st?? pa???sa pe??pt?s?
t? Structural) - -b nolist ep????? ?ste ?a µ? ?ata???feta? t?
a??e?? input st? out - G?a Fortran
- ISystem('ansys1.bat') e?te?e?ta? t? a??e?? .bat
t? ?p??? pe????e? - _at_ECHO OFF
- set ANS_CONSECYES
- set ANSYS_LOCKOFF
- set ANSEXE"ansys100.EXE"
- ANSEXE -p STRUCT -b nolist -i input1.lgw -o
out1.out - GOTO EOF
12????d?? Fminsearch
????
13FminSearch
?a??de??µa 1 The Rosenbrock banana function is a
classic test example for multidimensional
minimization Th
e minimum is at (1,1) and has the value 0. The
traditional starting point is (-1.2,1). The
anonymous function shown here defines the
function and returns a function handle called
banana banana _at_(x)100(x(2)-x(1)2)2(1-x(1))
2 Pass the function handle to fminsearch x,fval
fminsearch(banana,-1.2, 1) This produces x
1.0000 1.0000 fval 8.1777e-010 This indicates
that the minimizer was found to at least four
decimal places with a value near zero.
14?a??de??µa 2 If fun is parameterized, you can use
anonymous functions to capture the
problem-dependent parameters. For example,
suppose you want to minimize the objective
function myfun defined by the following M-file
function. function f myfun(x,a) f x(1)2
ax(2)2 Note that myfun has an extra parameter
a, so you cannot pass it directly to fminsearch.
To optimize for a specific value of a, such as a
1.5. Assign the value to a. a 1.5 define
parameter first Call fminsearch with a
one-argument anonymous function that captures
that value of a and calls myfun with two
arguments x fminsearch(_at_(x) myfun(x,a),0,1)
15?a??de??µa 3 You can modify the first example by
adding a parameter a to the second term of the
banana function T
his changes the location of the minimum to the
point a,a2. To minimize this function for a
specific value of a, for example a sqrt(2),
create a one-argument anonymous function that
captures the value of a. a sqrt(2) banana
_at_(x)100(x(2)-x(1)2)2(a-x(1))2 Then the
statement x,fval fminsearch(banana, -1.2,
1, ... optimset('TolX',1e-8)) seeks the minimum
sqrt(2), 2 to an accuracy higher than the
default on x.
16Sequential Quadratic Programming (Fmincon)
- ???µ???s? t?? Hessian p??a?a t?? s????t?s??
Lagrange. - ?p???s? t?? Quadratic Programming Problem.
- ??e??a ??aµµ?? ?a? ?p?????sµ?? t??
p??????p???µ???? s????t?s??.
17- Find values of x that minimize f(x) x1x2x3,
starting at the point x 101010, subject to
the constraints - 0 x1 2x2 2x3 72.
- Write a file that returns a scalar value f of the
objective function evaluated at x - function f myfun(x) f -x(1) x(2) x(3)
- Rewrite the constraints as both less than or
equal to a constant, - x12x22x3 0x1 2x2 2x3 72
- Since both constraints are linear, formulate them
as the matrix inequality Ax b, where -
- Supply a starting point and invoke an
optimization routine - x0 101010 Starting guess at the solution
x,fval fmincon(_at_myfun,x0,A,b) - After 11 iterations, the solution is
- x 24.0000 12.0000 12.0000
- where the function value is
- fval -3.4560e03
- and linear inequality constraints evaluate to be
less than or equal to 0 - Ax-b -72 0
18Ge?et???? ???????µ??
- ??µ?????e? t??a?? p????sµ?.
- ?a?µ????e? ???e ?t?µ? a?????a µe t?? t?µ? t??
a?t??e?µe????? s????t?s??, st?? ?p??a
a?t?st???e?. - ???µa???e? t?? ßa?µ?????e? t?? ???e at?µ?? ?ste
?a ta µetat???e? se p?? ???s?µ? e???? t?µ??. - ?p????e? t??? ???e?? a?????a µe t?? t?µ? t??
a?t??e?µe????? s????t?s?? st?? ?p??a
a?t?st??????. - ?a???e? ta pa?d?? ap? t??? ???e?? (µet???a??,
d?asta???s?). - ??t??a??st? t?? t?????ta p????sµ? µe ta pa?d??
??a ?a s??µat?se? t?? ep?µe?? ?e?e?. - ? a??????µ?? staµat?e? ?ta? ??a??p????e? ??a
s???e???µ??? ???t????. - ???at?t?ta efa?µ???? t?? ?? ?ß??d??? µ???d?
19GA
Example Given the following inequality
constraints and lower bounds t
he following code finds the minimum of the
function, lincontest6, that is provided your
software A 1 1 -1 2 2 1 b 2 2 3 lb
zeros(2,1) x,fval,exitflag
ga(_at_lincontest6,... 2,A,b,,,lb) Optimization
terminated average change in the fitness value
less than options.TolFun. x 0.7794 1.2205 fval
-8.03916 exitflag 1