This is my program:
Code: Select all
$set n 10
set j /0*%n%/;
sets
jlast(j)
jnotlast(j);
jlast(j)$(ord(j)=card(j))=yes;
jnotlast(j)=not jlast(j);
scalar
w_x basicwind direction x axis /10/
w_y basic wind direction y axis /0/
n number of intervals /%n%/
variable
time,
u_x(j),
u_y(j),
x(j),
y(j);
positive variable
step;
equation
diffx(j),
diffy(j),
lim_control(j),
obj;
obj.. time =e= n*step;
lim_control[j].. u_x(j)*u_x(j)=e=1-u_y(j)*u_y(j);
diffx[j]$(jnotlast(j)).. x(j+1)-x(j)=e= 0.5*(w_x*y(j+1)*y(j+1)*y(j+1)+u_x(j+1)+w_x*y(j)*y(j)*y(j)+u_x(j));
diffy[j]$(jnotlast(j)).. y(j+1)-y(j)=e= 0.5*(u_y(j+1)+u_y(j));
y.fx('0') = 1;
y.fx('%n%') = 0;
x.fx('0') = 2.25;
x.fx('%n%') = 0;
model brahstron1 /all/;
option
nlp=ipopt;
solve brahstron1 using nlp minimize time;
Code: Select all
file dem /output/; put dem;
put "time = ", time; put /;
loop(j, put x[j]1:n put y[j] 1:n put /;);
Thank you very much.