cas1.edp 5.39 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
load "iovtk"
load "resizeCSR"
load "BinaryIO";
include "myMacro.edp";
include "defGeomGen.edp"
include "defDofsGen.edp"

include "defTigerVar.edp"

include "paramsTS.edp";
int numRun=0;
int NnumRun=10;
if (ARGV.n>2){
  numRun=atoi(ARGV[2]);
  NnumRun=10;
}
if (ARGV.n>3){
  NnumRun=atoi(ARGV[3]);
}
int scenarioLow=0;
int scenarioMedian=1;
int scenarioHight=2;
int scenario=scenarioHight;
int seed = 1234+numRun;
randinit ( seed );
//include "defPluginVaraibleGen.edp"
//real nu=0.0;//1.0;//2D to 1D
//real mu=0.0;//0.5;//1D to 2D /ok
//real alpha1D=0.0;
int freqAff=1000;
real B0=0;
real betamodel=0;
real alphaw0,alphaw1;
//exp(-2*h0/365)=0.8;
//h0=-365*ln(0.8)/2=40.7;
alphaw0=40.7;
alphaw1=1;
//h0 tel que exp(-(2 jour)*h0) = 0.8
//exp(-2*h0/364)=0.8
//h0/364~0.1
//h0=36.4
//real lifeexpectancy=1.0/12.0;
43

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
real h0=36.4;
//deathrate=1/lifeexpected
real deathrate=12;
real mupowm1=0;
int freqVtk=100000;
real Tw=1.0;
real Rstar=0.14*365.0;
string GDDTHRESHOLD="GDD_269/";
if (scenario==scenarioLow){
  Rstar=0.12*365;
  Tw=2;
  GDDTHRESHOLD="GDD_294/";
   
}
if (scenario==scenarioHight){
  Rstar=0.15*365;
  Tw=0;
  GDDTHRESHOLD="GDD_246/";
}

real K=1.0;
65
66
67
//real Ru2=(Rstar-deathrate)/K;
real maxGt=0.11*365.0;
real Ru2=maxGt - deathrate;
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
include "defOutputGen.edp";
real[int] u6(6);
//real[int] grad6(6);
include "inputParam.edp";
cout<<"u6="<<u6<<endl;
real dirichlet0=1;
include "defParamsGen.edp";
include "mat1D2Duseful.edp";
include "postTraitementLoad.edp";
//system("export OUTPUTDIR="+OUTPUTDIR+";./outputScript.sh");

real gamma0min=100000;
real gamma0max=-100000;
real gamma1min=100000;
real gamma1max=-100000;
real w0min=100000;
real w0max=-100000;
real w1min=100000;
real w1max=-100000;

real RRmin=100000;
real RRmax=-100000;

macro  printInfoYear(XX){
        XX<<"simulation year "<<CURYEAR<<" ended"<<endl;
        XX<<"uminDensity="<<uminDensity<<endl;
        XX<<"umaxDensity="<<umaxDensity<<endl;
        XX<<"w0min="<<w0min<<endl;
        XX<<"w0max="<<w0max<<endl;
        XX<<"w1min="<<w1min<<endl;
        XX<<"w1max="<<w1max<<endl;
        XX<<"gamma0min="<<h0*gamma0min<<endl;
        XX<<"gamma0max="<<h0*gamma0max<<endl;
        XX<<"gamma1min="<<gamma1min<<endl;
        XX<<"gamma1max="<<gamma1max<<endl;
        XX<<"RRmin="<<RRmin<<endl;
        XX<<"RRmax="<<RRmax<<endl;
}//
int nbCallSave;
func real J(real[int] & u)
    {
      real coefLength=969000/12;
      //real coefExpo=2*log(coefLength)/log(10.0);
      D2DXu0=pow(10,u[0])*coefLength*coefLength;
      D2DYu0=D2DXu0;
      D1Du1=pow(10,u[1])*coefLength*coefLength;
      D1Du0=D1Du1;
      real R=pow(10,u[2]);
      muu1=u[3]*u[3];
      nuu1=coefLength*u[4]*u[4];
      dirichlet0=0.1*u[5]*u[5]/coefLength;
      betamodel=coefLength*coefLength;
      RR0=R;RR1=R;RR2=R;RR3=R;RR4=R;RR5=R;RR6=R;RR7=R;RR8=R;RR9=R;RR10=R;RR11=R;RR12=R;RR13=R;RR14=R;
      cout<<"PostTrait u("<<u[0]<<","<<u[1]<<","<<u[2]<<","<<u[3]<<","<<u[4]<<","<<u[5]<<")"<<endl;
      cout<<"PostTrait J("<<D2DXu0<<","<<D2DYu0<<","<<D1Du1<<","<<R<<","<<muu1<<","<<nuu1<<","<<dirichlet0<<")"<<endl;
      include "defVarfGen.edp";
      include "defMatGen.edp";

      //include "buildMatGenW01.edp";
      include "defIC.edp";
cout<<"end ic\n";
      ofstream infoFileNull("infosimu.txt");
      nbCallSave=0;
cout<<"begin loop\n";
      for (CURYEAR=FIRSTYEAR; CURYEAR<=LASTYEAR; CURYEAR++){
        if (CURYEAR>2016){
          real p;
          p=randreal1();
          int rg=p/0.2+1;
          CURYEARRAND=2011+rg;
          if (CURYEARRAND>2016)
            CURYEARRAND=2016;
          cout<<"CURYEAR "<<CURYEAR<<" use data "<<CURYEARRAND<<endl;
        }
        ofstream infoFile("infosimu.txt",append);
        if (CURYEAR==2011){
          nbSteps=nbSteps2011;
          T0=1-122.0/365.0;
        }else{
          nbSteps=nbStepsByYear;
          T0=0;
        }
        gamma0min=100000;
        gamma0max=-100000;
        gamma1min=100000;
        gamma1max=-100000;
        w0min=100000;
        w0max=-100000;
        w1min=100000;
        w1max=-100000;
        RRmin=100000;
        RRmax=-100000;
        if (CURYEAR!=FIRSTYEAR){
          include "zeroAdultAndW1.edp";
        }
   
        cout<<"doing timestepping with nbSteps="<<nbSteps<<endl;
        include "timeSteppingGen.edp";
        printInfoYear(infoFile);
        printInfoYear(cout);
        
        /*
          visuScal("2D",Th0,u2d0,10);
          {
          ofstream fileU("fileU");
          //fileU<<pu1d0s1;
          }
          {
          ofstream pyFile("vtktopngGen.py");
          int aux=nbSteps/freqVtk;
          pyFile<<"#this file is generated during FF simulation\n"<<endl;
          pyFile<<"nbStep="<<aux<<";\n";
          pyFile<<"step="<<freqVtk<<";\n";
          pyFile<<"firstStep=1;\n";
          pyFile<<"nbOmega="<<Nwires<<";\n";
          pyFile<<"OUTPUTDIR=\""<<OUTPUTDIR<<"\";\n";
          umaxDensity=1.6e-10;
          include "vtktopngGen.edp";
          }*/
        include "saveStatew1.edp"
        include "interAnnualStage.edp"
      }
      include "saveStateSetSize.edp"
      numRun=numRun+1;
      return Tllh;
    }

// func real[int] DJ(real[int] &u)
//     { 
//       for (int i=0;i<u.n;i++)
// 	u[i]=(i+1)*u[i]-b[i];
//       return u;  // return of global variable ok 
//     };


real resTllh;
for (int ii=0; ii<NnumRun;ii++)
       resTllh=J(u6);
//grad6=DJ(u6);
//cout<<"PostTrait "<<grad6(0)<<" "<<grad6(1)<<" "<<grad6(2)<<" "<<grad6(3)<<" "<<grad6(4)<<endl;;
//BFGS(J,DJ,u6,eps=1.e-6,nbiter=500,nbiterline=5);