39 krn(0.0),dkrn(0.0),psic(0.0),
40 dpsic(0.0),dSe_dpsic(0.0)
47 krn(0.0),dkrn(0.0),psic(0.0),
48 dpsic(0.0),dSe_dpsic(0.0)
50 virtual inline void setParams(
const double* rwork,
const int* iwork = 0)
62 inline void calc(
const double& Sw)
90 Se = (Sw - Sw_min)/(Sw_max-Sw_min);
91 dSe_dSw = 1.0/(Sw_max - Sw_min);
98 bool implemented =
false;
112 inline void calc(
const double& Sw)
117 dkrw = 2.0*Se*dSe_dSw;
119 krn = (1.0-Se)*(1.0-Se);
120 dkrn = 2.0*(Se-1.0)*dSe_dSw;
122 psic = (1.0-Se)/Sw_min;
128 psic =
max(0.0,psicIn);
130 Se = 1.0-psic*Sw_min;
131 Se =
max(0.0,
min(1.0,Se));
134 dkrw = 2.0*Se*dSe_dSw;
136 krn = (1.0-Se)*(1.0-Se);
137 dkrn = 2.0*(Se-1.0)*dSe_dSw;
153 VGMorig(
const double* rwork,
const int* iwork = 0):
166 Se_eps_const = rwork_tol[0];
169 inline void setParams(
const double* rwork,
const int* iwork = 0)
182 if(Se <= Se_eps_const)
184 else if(Se >= (1.0-Se_eps_const))
185 Se_eps=1.0-Se_eps_const;
190 inline void calc(
const double& Sw)
192 double Seovmmo,Seovm,Seovmmh,S,Smmo,S2mmo,Sm,S2m,pcesub1,pcesub2;
196 Seovmmo = pow(Se_eps,((1.0/m)-1.0));
197 Seovm = Seovmmo*Se_eps;
198 Seovmmh = pow(Se_eps,((1.0/m)-0.5));
201 S2mmo = pow(S,2.0*m-1.0);
205 pcesub1 = pow(((1.0/Seovm)-1.0),((1.0/
n)-1.0));
206 pcesub2 = pcesub1*((1.0/Seovm)-1.0);
208 krw = sqrt(Se)*(1.0-Sm)*(1.0-Sm);
209 dkrw = (0.5*(1.0/sqrt(Se_eps))*(1.0-Sm)*(1.0-Sm) + 2.0*(1-Sm)*Smmo*Seovmmh)*dSe_dSw;
211 krn = sqrt(1.0-Se)*S2m;
212 dkrn = (-0.5*(1.0/sqrt(1.0-Se_eps))*S2m - 2.0*sqrt(1.0-Se)*(S2mmo)*Seovmmo)*dSe_dSw;
214 psic = pow((pow(Se_eps,(-1.0/m)) - 1.0),(1.0/
n))/alpha;
215 dpsic = ((-1.0/(alpha*
n*m))*(pow((pow(Se_eps,-1.0/m)-1.0),-m))*(pow(Se_eps,((-1.0/m)-1.0))))*dSe_dSw;
225 VGM(
const double* rwork,
const int* iwork = 0):
229 sqrt_eps_small(1.0e-8)
243 dSe_dpsic=
r.dSe_dpsic;
247 Se_eps_const=
r.Se_eps_const;
249 eps_small=
r.eps_small;
250 sqrt_eps_small=
r.sqrt_eps_small;
255 eps_small = rwork_tol[0];
256 ns_del = rwork_tol[1];
261 Se = (Sw - Sw_min)/(Sw_max-Sw_min);
262 dSe_dSw = 1.0/(Sw_max - Sw_min);
263 Se =
max(eps_small,
min(Se,1.0-eps_small));
266 inline void calc(
const double& Sw)
270 double sBar,psiC,DsBar_DpC,DDsBar_DDpC,DkrW_DpC,DkrN_DpC;
272 alphaPsiC, alphaPsiC_n, alphaPsiC_nM1, alphaPsiC_nM2,
274 sqrt_sBar, sqrt_1minusSbar,
275 sBarByOnePlus_alphaPsiC_n, sBarBy_onePlus_alphaPsiC_n_2;
279 onePlus_alphaPsiC_n = pow(sBar,1.0/-m);
280 alphaPsiC_n = onePlus_alphaPsiC_n - 1.0;
281 alphaPsiC = pow(alphaPsiC_n,1.0/
n);
282 psiC = alphaPsiC/alpha;
284 alphaPsiC_nM1 = alphaPsiC_n/alphaPsiC;
285 sBarByOnePlus_alphaPsiC_n = sBar/onePlus_alphaPsiC_n;
286 sqrt_sBar = sqrt(sBar);
287 sqrt_1minusSbar = sqrt(1.0 - sBar);
289 DsBar_DpC = -alpha*(
n-1.0)*alphaPsiC_nM1
290 *sBarByOnePlus_alphaPsiC_n;
293 vBar = 1.0-alphaPsiC_nM1*sBar;
294 uBar = alphaPsiC_nM1*sBar;
297 krw = sqrt_sBar*vBar*vBar;
298 krn = sqrt_1minusSbar*uBar*uBar;
309 alphaPsiC_nM2 = alphaPsiC_nM1/alphaPsiC;
311 sBarBy_onePlus_alphaPsiC_n_2 = sBarByOnePlus_alphaPsiC_n
312 /onePlus_alphaPsiC_n;
313 DDsBar_DDpC = alpha*alpha*(
n-1.)
314 *((2*
n-1.)*alphaPsiC_nM1*alphaPsiC_nM1
315 *sBarBy_onePlus_alphaPsiC_n_2
318 *sBarByOnePlus_alphaPsiC_n);
322 DkrW_DpC = (0.5/sqrt_sBar)*DsBar_DpC*vBar*vBar
325 (alpha*(
n-1.0)*alphaPsiC_nM2*sBar
326 + alphaPsiC_nM1 * DsBar_DpC);
332 if (sqrt_1minusSbar >= sqrt_eps_small)
334 DkrN_DpC = -(0.5/sqrt_1minusSbar)*DsBar_DpC*uBar*uBar
336 2.0*sqrt_1minusSbar*uBar*
337 (alpha*(
n-1.0)*alphaPsiC_nM2*sBar
338 + alphaPsiC_nM1 * DsBar_DpC);
342 DkrN_DpC =((1.0 - sBar)/eps_small)*2.0*sqrt_eps_small*uBar*
343 (alpha*(
n-1.0)*alphaPsiC_nM2*sBar
344 + alphaPsiC_nM1 * DsBar_DpC)
345 - (DsBar_DpC/eps_small)*sqrt_eps_small*uBar*uBar;
349 if (psiC < ns_del && psiC > 0.0 )
362 double DpC_Dse = 0.0;
363 if (fabs(DsBar_DpC) > 0.0)
364 DpC_Dse = 1.0/DsBar_DpC;
365 double DpC_Dsw = DpC_Dse*dSe_dSw;
366 dkrw = DkrW_DpC*DpC_Dsw;
367 dkrn = DkrN_DpC*DpC_Dsw;
375 double sBar,psiC,DsBar_DpC,DDsBar_DDpC,DkrW_DpC,DkrN_DpC;
377 alphaPsiC, alphaPsiC_n, alphaPsiC_nM1, alphaPsiC_nM2,
379 sqrt_sBar, sqrt_1minusSbar,
380 sBarByOnePlus_alphaPsiC_n, sBarBy_onePlus_alphaPsiC_n_2;
383 psiC =
max(0.0,psicIn);
384 alphaPsiC = alpha*psiC;
385 alphaPsiC_n = pow(alphaPsiC,
n);
386 alphaPsiC_nM1 = alphaPsiC_n/alphaPsiC;
387 onePlus_alphaPsiC_n = 1.0 + alphaPsiC_n;
388 sBar = pow(onePlus_alphaPsiC_n,-m);
389 sBarByOnePlus_alphaPsiC_n = sBar/onePlus_alphaPsiC_n;
390 sqrt_sBar = sqrt(sBar);
391 sqrt_1minusSbar = sqrt(1.0 - sBar);
393 DsBar_DpC = -alpha*(
n-1.0)*alphaPsiC_nM1
394 *sBarByOnePlus_alphaPsiC_n;
396 vBar = 1.0-alphaPsiC_nM1*sBar;
397 uBar = alphaPsiC_nM1*sBar;
400 krw = sqrt_sBar*vBar*vBar;
401 krn = sqrt_1minusSbar*uBar*uBar;
418 alphaPsiC_nM2 = alphaPsiC_nM1/alphaPsiC;
420 sBarBy_onePlus_alphaPsiC_n_2 = sBarByOnePlus_alphaPsiC_n
421 /onePlus_alphaPsiC_n;
422 DDsBar_DDpC = alpha*alpha*(
n-1.)
423 *((2*
n-1.)*alphaPsiC_nM1*alphaPsiC_nM1
424 *sBarBy_onePlus_alphaPsiC_n_2
427 *sBarByOnePlus_alphaPsiC_n);
431 DkrW_DpC = (0.5/sqrt_sBar)*DsBar_DpC*vBar*vBar
434 (alpha*(
n-1.0)*alphaPsiC_nM2*sBar
435 + alphaPsiC_nM1 * DsBar_DpC);
441 if (sqrt_1minusSbar >= sqrt_eps_small)
443 DkrN_DpC = -(0.5/sqrt_1minusSbar)*DsBar_DpC*uBar*uBar
445 2.0*sqrt_1minusSbar*uBar*
446 (alpha*(
n-1.0)*alphaPsiC_nM2*sBar
447 + alphaPsiC_nM1 * DsBar_DpC);
451 DkrN_DpC =((1.0 - sBar)/eps_small)*2.0*sqrt_eps_small*uBar*
452 (alpha*(
n-1.0)*alphaPsiC_nM2*sBar
453 + alphaPsiC_nM1 * DsBar_DpC)
454 - (DsBar_DpC/eps_small)*sqrt_eps_small*uBar*uBar;
458 if (psiC < ns_del && psiC > 0.0 )
481 VGB(
const double* rwork,
const int* iwork = 0):
485 inline void calc(
const double& Sw)
487 double S,Smmo,Sm,alpha,Se1ovMmo;
491 Se1ovMmo = pow(Se_eps,((1.0/m)-1.0));
492 S = 1.0-Se1ovMmo*Se_eps;
493 Smmo = pow(S,(m-1.0));
498 krw = Se_eps*Se_eps*(1.0-pow(1.0-pow(Se_eps,1.0/m),1.0/m));
499 dkrw = (2.0*Se_eps*(1.0-pow(1.0-pow(Se_eps,1.0/m),1.0/m))+Se_eps*pow(1.0-pow(Se_eps,1.0/m),1.0/m)/(m*m)*pow(Se_eps,1.0/m)/(1.0-pow(Se_eps,1.0/m)))*dSe_dSw;
501 krn = pow(1.0-Se_eps,2.0)*pow(1.0-pow(Se_eps,1.0/m),1.0*m);
502 dkrn = (-2.0*(1.0-Se_eps)*pow(1.0-pow(Se_eps,1.0/m),1.0*m)-pow(1.0-Se_eps,2.0)*pow(1.0-pow(Se_eps,1.0/m),1.0*m)*pow(Se_eps,1.0/m)/Se_eps/(1.0-pow(Se_eps,1.0/m)))*dSe_dSw;
509 psic = pow((pow(Se_eps,(-1.0/m)) - 1.0),(1.0/
n))/alpha;
510 dpsic = ((-1.0/(alpha*
n*m))*(pow((pow(Se_eps,-1.0/m)-1.0),-m))*(pow(Se_eps,((-1.0/m)-1.0))))*dSe_dSw;
520 BCM(
const double* rwork,
const int* iwork = 0):
526 inline void setParams(
const double* rwork,
const int* iwork = 0)
533 inline void calc(
const double& Sw)
535 double Value,Expon,krwovSe,Oovbclpo,Oovbcl,X,sqrt1mu;
539 Oovbclpo = Oovbcl+1.0;
542 Expon = ((4.0+5.0*lambda)/(2.0*lambda));
543 krwovSe = pow(Se,(Expon-1.0));
544 sqrt1mu = sqrt(1.0-Se);
547 dkrw = (Expon*krwovSe)*dSe_dSw;
549 krn = sqrt1mu*Value*Value;
550 dkrn = (-0.5*(1.0/sqrt1mu)*Value*Value - 2.0*sqrt1mu*Value*Oovbclpo*X )*dSe_dSw;
553 dpsic = (-Oovbcl/(X*Se))*dSe_dSw;
561 BCB(
const double* rwork,
const int* iwork = 0):
BCM(rwork,iwork)
564 inline void calc(
const double& Sw)
566 double Se2ovL,Se2,Se3,omSe,Expon,Semoovlmo,Se_cutOff;
569 Se2ovL = pow(Se,(2.0/lambda));
573 Expon = (2.0+3.0*lambda)/lambda;
574 Se_cutOff =
max(1.0e-4,Se);
575 Semoovlmo = pow(Se_cutOff,((-1.0/lambda)-1.0));
578 dkrw = Expon*Se2ovL*Se2*dSe_dSw;
580 krn = (omSe*omSe)*(1.0-Se2ovL*Se);
581 dkrn = (2.*omSe*(1.0-Se2ovL*Se) - (omSe*omSe)*(Expon-2.0)*Se2ovL*dSe_dSw)*dSe_dSw;
584 krw = pow(Se,(2.0+3.0*lambda)/lambda);
585 dkrw = (((2.0+3.0*lambda)/lambda)*pow(Se,(2.0+3.0*lambda)/lambda - 1.0))*dSe_dSw;
587 krn = (1.0-Se)*(1.0-Se)*(1.0-pow(Se,(2.0+lambda)/lambda));
588 dkrn = (-2.0*(1.0-Se)*(1.0-pow(Se,(2.0+lambda)/lambda))
589 -((2.0+lambda)/lambda)*(1.0-Se)*(1.0-Se)*pow(Se,(2.0+lambda)/lambda-1.0))*dSe_dSw;
591 psic =
pd*Semoovlmo*Se;
592 dpsic =
pd*(-1.0/lambda)*Semoovlmo*dSe_dSw;
621 lambdaw = density_w.
rho*psk.
krw/muw;
622 dlambdaw =(density_w.
rho/muw)*psk.
dkrw;
624 lambdan =(density_n.
rho*psk.
krn)/mun;
625 dlambdan =(density_n.
rho/mun)*psk.
dkrn;
627 lambdat = lambdaw + lambdan;
628 dlambdat = dlambdaw + dlambdan;
630 fw = lambdaw/lambdat;
631 dfw = (dlambdaw*lambdat - lambdaw*dlambdat)/(lambdat*lambdat);
633 fn = lambdan/lambdat;
634 dfn = (dlambdan*lambdat - lambdan*dlambdat)/(lambdat*lambdat);
657 lambdaw = density_w.
rho*psk.
krw/muw;
658 dlambdaw = (density_w.
rho/muw)*psk.
dkrw;
662 drhon_psiw = density_n.
drho;
664 lambdan = (density_n.
rho*psk.
krn)/mun;
665 dlambdan = (1.0/mun)*(psk.
dkrn*density_n.
rho + drhon*psk.
krn);
666 dlambdan_psiw = drhon_psiw*(psk.
krn/mun);
668 lambdat = lambdaw + lambdan;
669 dlambdat = dlambdaw + dlambdan;
670 dlambdat_psiw = dlambdaw_psiw + dlambdan_psiw;
672 fw = lambdaw/lambdat;
673 dfw = (dlambdaw*lambdat - lambdaw*dlambdat)/(lambdat*lambdat);
674 dfw_psiw = (dlambdaw_psiw*lambdat - lambdaw*dlambdat_psiw)/(lambdat*lambdat);
676 fn = lambdan/lambdat;
677 dfn = (dlambdan*lambdat - lambdan*dlambdat)/(lambdat*lambdat);
678 dfn_psiw = (dlambdan_psiw*lambdat - lambdan*dlambdat_psiw)/(lambdat*lambdat);
709 virtual inline void calc(
const double& Sw)
721 splineArray+uinvOffset*nknots);
730 splineArray+krwOffset*nknots);
738 splineArray+krnOffset*nknots);
752 splineArray+uinvOffset*nknots);
761 splineArray+krwOffset*nknots);
769 splineArray+krnOffset*nknots);
772 virtual inline void setParams(
const double* rwork,
const int* iwork = 0)