/* test program... */ int main() { int i; double z,w,err; for (i=0; i<100; i++) { z=i/100.0-0.3678794411714423215955; w=LambertW(z); err=exp(w)-z/w; printf("W(%8.4f)=%22.16f, check: exp(W(z))-z/W(z)=%e\n",z,w,err); } for (i=0; i<100; i++) { z=i/1.0e-1-0.3; w=LambertW(z); err=exp(w)-z/w; printf("W(%8.4f)=%22.16f, check: exp(W(z))-z/W(z)=%e\n",z,w,err); } return 0; }
Real RichardsSeff1BWsmall::seff(std::vector<VariableValue *> p, unsigned int qp) const { Real pp = (*p[0])[qp]; if (pp >= 0) return 1.0; Real x = (_c - 1)*std::exp(_c - 1 - _c*pp/_las); Real th = _c/(1 + LambertW(x)); // use branch 0 for positive x return _sn + (_ss - _sn)*th; }
int main() { int i,n=1000; double w,z,s=0,err; for (i=1; i<=n; i++) { z=i/(double)n; w=LambertW(1/z)/(1+z); s+=w; printf("%8.4f %8.4f\n",z,w); } fprintf(stderr,"%8.4f\n",exp(s/n/log(2))); return 0; }
void RichardsSeff1BWsmall::d2seff(std::vector<VariableValue *> p, unsigned int qp, std::vector<std::vector<Real> > &result) const { result[0][0] = 0.0; Real pp = (*p[0])[qp]; if (pp >= 0) return; Real x = (_c - 1)*std::exp(_c - 1 - _c*pp/_las); Real lamw = LambertW(x); result[0][0] = -std::pow(_c, 3)/std::pow(_las, 2)*lamw*(1 - 2*lamw)/std::pow(1 + lamw, 5); }
void RichardsSeff1BWsmall::dseff(std::vector<const VariableValue *> p, unsigned int qp, std::vector<Real> &result) const { result[0] = 0.0; Real pp = (*p[0])[qp]; if (pp >= 0) return; Real x = (_c - 1)*std::exp(_c - 1 - _c*pp/_las); Real lamw = LambertW(x); result[0] = std::pow(_c, 2)/_las*lamw/std::pow(1 + lamw, 3); }
void RichardsSeff1BWsmall::d2seff(std::vector<const VariableValue *> p, unsigned int qp, std::vector<std::vector<Real>> & result) const { result[0][0] = 0.0; Real pp = (*p[0])[qp]; if (pp >= 0) return; Real x = (_c - 1) * std::exp(_c - 1 - _c * pp / _las); Real lamw = LambertW(x); result[0][0] = -Utility::pow<3>(_c) / Utility::pow<2>(_las) * lamw * (1.0 - 2.0 * lamw) / Utility::pow<5>(1 + lamw); }