root / Final-Parameters_sm_fsn_fss_fsv / pulvinus4optimize.cpp @ 15
Historique | Voir | Annoter | Télécharger (7,55 ko)
1 |
include "getARGV.idp"
|
---|---|
2 |
|
3 |
func real lineD(real xA, real xB, real yA, real yB) |
4 |
{ return (yB-yA)/(xB-xA);
|
5 |
} |
6 |
|
7 |
func real lineC(real xA, real xB, real yA, real yB) |
8 |
{ return (yA*xB-yB*xA)/(xB-xA);
|
9 |
} |
10 |
|
11 |
func real angleToVertical(real Mx, real My, real Nx, real Ny) |
12 |
{ /* Computes the angle between the MN vector and Oy (in degrees) */
|
13 |
return asin((Nx-Mx)/sqrt((Mx-Nx)^2+(My-Ny)^2))*180/pi; |
14 |
} |
15 |
|
16 |
|
17 |
/*************************************************************
|
18 |
* PARAMETERS
|
19 |
* **********************************************************/
|
20 |
|
21 |
// reading script arguments
|
22 |
for (int i=0;i<ARGV.n;++i) |
23 |
{ cout << ARGV[i] << " ";}
|
24 |
cout<<endl; |
25 |
|
26 |
//verbosity = getARGV("-vv", 0);
|
27 |
//int vdebug = getARGV("-d", 1);
|
28 |
|
29 |
// hydrophobicity as swelling ability
|
30 |
real sm = -getARGV("-sm", 0.568354);// mesophyl swelling property |
31 |
real fsn = getARGV("-fsn", 0.899975);// nectary sn/sm |
32 |
real fss = getARGV("-fss", 1.19112);// side ss/sm |
33 |
real fsv = getARGV("-fsv", 0.491088);// vasculature sv/sm |
34 |
string outputfile = getARGV("-outfile", "test.csv"); |
35 |
|
36 |
// ---------------- geometrical parameters
|
37 |
|
38 |
// (lengths are measured in micrometers)
|
39 |
real units=200;
|
40 |
|
41 |
// pulvinus dimensions
|
42 |
real lx=491.0/units; //sd =34.4 |
43 |
real ly= 240.0/units; //sd=36.0 |
44 |
|
45 |
// nectary height
|
46 |
real hnect = 38.8/units; //sd=9.6 |
47 |
real R=363.0/units; //sd=49.4 |
48 |
|
49 |
// side dimensions
|
50 |
real hside=91.4/units; //12.6 |
51 |
real lside=47.6/units; //6.6 |
52 |
|
53 |
// vasculature dimensions
|
54 |
real vthickness=34.3/units;//5.5 |
55 |
real cwidth=74.8/units; //15.2 |
56 |
real cwidthdry=44.2/units; //8.4 |
57 |
|
58 |
// vasculature displacement (from vascular bundle distance)
|
59 |
real vd=(cwidth-cwidthdry)/2;
|
60 |
real vposition=lx/2-vthickness-hnect/ly*(lx/2-cwidth/2-vthickness); //cout<<"vposition="<<vposition<<endl; |
61 |
|
62 |
// mesh parameters
|
63 |
int nvertex=20; cout << "nvertex="<<nvertex<<endl; |
64 |
real pinned=lx/nvertex/2;
|
65 |
|
66 |
|
67 |
// ---------------- Material properties
|
68 |
|
69 |
real nu = 0.29; // Poisson's ratio |
70 |
|
71 |
// Young modulus
|
72 |
real Ev; // vasculature Young modulus
|
73 |
real fEm; // mesophyl Em/Ev
|
74 |
real fEn; // nectary En/Ev
|
75 |
real fEs; // side Es/Ev
|
76 |
|
77 |
// measured values for the density
|
78 |
//Region,Mean_tissue_density,SD_tissue_density
|
79 |
real dm=0.668060839; //sd=0.04091249 |
80 |
real dn=1.01896008; //sd=0.015464575 |
81 |
real ds=0.918032482; //sd=0.075097509 |
82 |
real dv=0.882171532; //sd=0.066651037 |
83 |
|
84 |
real nEd=1.0; |
85 |
|
86 |
// Young modulus
|
87 |
Ev=1; // vasculature Young modulus |
88 |
fEm=(dm/dv)^nEd; // mesophyl Em/Ev
|
89 |
fEn=(dn/dv)^nEd; // nectary En/Ev
|
90 |
fEs=(ds/dv)^nEd; // side Es/Ev
|
91 |
|
92 |
|
93 |
/*************************************************************
|
94 |
* GEOMETRY and MESH
|
95 |
* **********************************************************/
|
96 |
|
97 |
include "geometry1.cpp";
|
98 |
|
99 |
// -------------------- define the finite element space
|
100 |
|
101 |
fespace Vh(Th,[P2,P2]); // vector on the mesh (displacement vector)
|
102 |
Vh [u1,u2], [v1,v2]; |
103 |
|
104 |
fespace Sh(Th, P2); // scalar on the mesh, P2 elements
|
105 |
fespace Sh0(Th,P0); // scalar on the mesh, P0 elements
|
106 |
fespace Sh1(Th,P1); // scalar on the mesh, P1 elements
|
107 |
|
108 |
// macro to redefine variables on the displaced mesh
|
109 |
macro redefineVariable(vvv) |
110 |
{ real[int] temp(vvv[].n);
|
111 |
temp=vvv[]; vvv=0; vvv[]=temp;
|
112 |
vvv=vvv; |
113 |
}//
|
114 |
|
115 |
real sqrt2=sqrt(2.);
|
116 |
macro epsilon(u1,u2) [dx(u1),dy(u2),(dy(u1)+dx(u2))/sqrt2] // EOM
|
117 |
//the sqrt2 is because we want: epsilon(u1,u2)'* epsilon(v1,v2) $== \epsilon(\bm{u}): \epsilon(\bm{v})$
|
118 |
macro div(u1,u2) ( dx(u1)+dy(u2) ) // EOM
|
119 |
|
120 |
/*************************************************************
|
121 |
* MECHANICS
|
122 |
* **********************************************************/
|
123 |
|
124 |
// definition of integer functions for the structural domains
|
125 |
func vasculature=int(vasculatureBool(x,y));
|
126 |
func nectary=int(nectaryBool(x,y));
|
127 |
func side=int(sideBool(x,y));
|
128 |
func mesophyl=int(mesophylBool(x,y));
|
129 |
func geometry = 1*vasculature + 3*nectary + 2*side + 4*mesophyl; |
130 |
|
131 |
// definition of FE variables for the structural domains
|
132 |
Sh0 vasculatureh=vasculature; |
133 |
Sh0 nectaryh=nectary; |
134 |
Sh0 sideh=side; |
135 |
Sh0 mesophylh=mesophyl; |
136 |
|
137 |
Sh0 geometryh=geometry; |
138 |
//string fname=output+"/geometry-original.png";
|
139 |
//plot(geometryh,fill=1, ps=fname, bb=bb);
|
140 |
|
141 |
// spatial dependence of Young modulus
|
142 |
func E=Ev*(vasculature + fEn*nectary + fEs*side + fEm*mesophyl); |
143 |
Sh0 Eh=E; |
144 |
|
145 |
// spatial dependence of the swelling property
|
146 |
func s=sm*(fsv*vasculature + fsn*nectary + fss*side + mesophyl); |
147 |
Sh0 sh=s; |
148 |
|
149 |
func mu=E/(2*(1+nu)); |
150 |
func lambda=E*nu/((1+nu)*(1-2*nu)); |
151 |
//func K=lambda+2*mu/3;
|
152 |
func K=lambda+mu; |
153 |
|
154 |
|
155 |
/*************************************************************
|
156 |
* SOLVING THE FEM
|
157 |
* **********************************************************/
|
158 |
|
159 |
solve Lame([u1,u2],[v1,v2])= |
160 |
int2d(Th)( |
161 |
lambda*div(u1,u2)*div(v1,v2) |
162 |
+ 2.*mu*( epsilon(u1,u2)'*epsilon(v1,v2) ) |
163 |
) |
164 |
- int2d(Th) ( K*sh*div(v1,v2)) |
165 |
+ on(32,u1=vd,u2=0) |
166 |
+ on(33,u1=-vd,u2=0) |
167 |
; |
168 |
|
169 |
/*************************************************************
|
170 |
* Measuring angles
|
171 |
* **********************************************************/
|
172 |
|
173 |
real Nx=lx/2+u1(lx/2.,0), Ny=u2(lx/2.,0); |
174 |
|
175 |
// compute tangentangle
|
176 |
real height=ly/nvertex/100;
|
177 |
real Mx=lx/2+u1(lx/2.,-height), My=-height+u2(lx/2.,-height); |
178 |
real tangentangle=angleToVertical(Mx, My, Nx, Ny); |
179 |
|
180 |
// compute sideangle
|
181 |
height=hside; |
182 |
Mx=lx/2+u1(lx/2.,-height); My=-height+u2(lx/2.,-height); |
183 |
real sideangle=angleToVertical(Mx, My, Nx, Ny); |
184 |
|
185 |
|
186 |
/*************************************************************
|
187 |
* Measuring original areas
|
188 |
* **********************************************************/
|
189 |
|
190 |
// original volumes
|
191 |
real voltotal0=int2d(Th)(1);
|
192 |
real volvasculature0=int2d(Th)(vasculatureh); |
193 |
real volnectary0=int2d(Th)(nectaryh); |
194 |
real volmesophyl0=int2d(Th)(mesophylh); |
195 |
real volside0=int2d(Th)(sideh); |
196 |
|
197 |
|
198 |
/*************************************************************
|
199 |
* Measuring strain anisotropies
|
200 |
* **********************************************************/
|
201 |
|
202 |
Sh0 e11=dx(u1)+1.;
|
203 |
Sh0 e12=1/2.*(dx(u2) + dy(u1)); |
204 |
Sh0 e22=dy(u2)+1.;
|
205 |
|
206 |
Sh0 strain=e11+e22 ; |
207 |
Sh0 Det=e11*e22-e12*e12; |
208 |
|
209 |
Sh0 l1=abs(strain+sqrt(strain*strain-4*Det))/2.; |
210 |
Sh0 l2=abs(strain-sqrt(strain*strain-4*Det))/2.; |
211 |
|
212 |
Sh0 lmax=(l1-l2+abs(l1-l2))/2.+l2;
|
213 |
Sh0 lmin=(l1-l2-abs(l1-l2))/2.+l2;
|
214 |
|
215 |
Sh0 strainanisotropy=lmin/lmax; |
216 |
|
217 |
|
218 |
// compute mean strain anisotropy per region
|
219 |
real satotal=int2d(Th)(strainanisotropy)/voltotal0; |
220 |
real savasculature=int2d(Th)(strainanisotropy*vasculatureh)/volvasculature0; |
221 |
real sanectary=int2d(Th)(strainanisotropy*nectaryh)/volnectary0; |
222 |
real saside=int2d(Th)(strainanisotropy*sideh)/volside0; |
223 |
real samesophyl=int2d(Th)(strainanisotropy*mesophylh)/volmesophyl0; |
224 |
|
225 |
|
226 |
/*************************************************************
|
227 |
* Measuring area changes
|
228 |
* **********************************************************/
|
229 |
|
230 |
// deformed volumes
|
231 |
Th=movemesh(Th,[x+u1,y+u2]); |
232 |
|
233 |
|
234 |
redefineVariable(vasculatureh); |
235 |
redefineVariable(nectaryh); |
236 |
redefineVariable(sideh); |
237 |
redefineVariable(mesophylh); |
238 |
|
239 |
|
240 |
real voltotal=int2d(Th)(1);
|
241 |
real volvasculature=int2d(Th)(vasculatureh); |
242 |
real volnectary=int2d(Th)(nectaryh); |
243 |
real volside=int2d(Th)(sideh); |
244 |
real volmesophyl=int2d(Th)(mesophylh); |
245 |
|
246 |
real am=volmesophyl0/volmesophyl; |
247 |
real an=volnectary0/volnectary; |
248 |
real as=volside0/volside; |
249 |
real av=volvasculature0/volvasculature; |
250 |
|
251 |
|
252 |
|
253 |
/*************************************************************
|
254 |
* Writing results
|
255 |
* **********************************************************/
|
256 |
cout<<"sm;fsn;fss;fsv;sideangle;am;an;as;av;sam;san;sas;sav;"<<endl;
|
257 |
|
258 |
string toprint=string(sm)+";"+string(fsn)+";"+string(fss)+";"+string(fsv)+";" |
259 |
+string(sideangle/38)+";" |
260 |
+string(am)+";"+string(an)+";"+string(as)+";"+string(av)+";" |
261 |
+string(samesophyl)+";"+string(sanectary)+ ";"+string(saside)+";"+string(savasculature); |
262 |
|
263 |
cout<<toprint<<endl; |
264 |
|
265 |
ofstream textfile(outputfile); |
266 |
textfile<<toprint<<endl; |
267 |
|
268 |
|