Public Member Functions
DepthDistribution Class Reference

Brief description of class still missing. More...

#include <DepthDistribution.h>

List of all members.

Public Member Functions

double a () const
bool calculate ()
 DepthDistribution ()
double derivative (double q) const
int layerCount () const
double maximumDepth (int i) const
double maximumWavelength () const
double minimumDepth (int i) const
double minimumWavelength () const
double q () const
void report (QTextStream &s) const
bool setLayerCount (int layerCount)
void setMaximumWavelength (double m)
void setMinimumWavelength (double m)
double thickness (int i) const
double y (double q) const

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

Description of constructor still missing

References TRACE.

{
  TRACE;
  _n=1;
  _minimumWavelength=1.0;
  _a=0.25;
  _maximumWavelength=100.0;
}

Member Function Documentation

double DepthDistribution::a ( ) const [inline]
{return _a;}

References QGpCoreTools::endl(), QGpCoreTools::RootSolverTemplate< double, FunctionClass >::halving(), QGpCoreTools::RootSolverTemplate< double, FunctionClass >::lower(), QGpCoreTools::RootSolverTemplate< double, FunctionClass >::setInterval(), QGpCoreTools::RootSolverTemplate< double, FunctionClass >::setPrecision(), QGpCoreTools::tr(), TRACE, and y().

Referenced by main().

{
  TRACE;
  _depths.clear();
  double z=0.0;
  if(_n==1) {
    _q=1;
    _depths.append(0);
    _depths.append(_a);
    _depths.append(0.5*_maximumWavelength);
  } else {
    // To have one solution, the derivative at 1 must be negative
    // n*a>max
    if(_n*_a>=0.5*_maximumWavelength) {
      App::stream() << tr("No solution, decrease the number of layers or increase the ratio between min and max wavelength") << endl;
      return false;
    }
    // Search root with a step that doubles at each iteration
    double dx=1e-15;
    while(y(1.0+dx)<0.0) {
      dx*=2;
    }
    RootSolver<DepthDistribution> solver(this);
    solver.setPrecision(1e-10);
    solver.setInterval(1.0+dx*0.5, 1.0+dx);
    //solver.newtonRaphson();
    solver.halving();
    _q=solver.lower();
    // Calculate depths at top of each layer
    for(int i=0;i<_n+2;i++) {
      _depths.append(z);
      z+=_a*pow(_q,i);
    }
  }
  return true;
}
double DepthDistribution::derivative ( double  q) const
{
  return _n*_a*pow(q,_n-1)
        -0.5*_maximumWavelength;
}
int DepthDistribution::layerCount ( ) const [inline]

Referenced by main(), and setLayerCount().

{return _n;}
double DepthDistribution::maximumDepth ( int  i) const

References TRACE.

Referenced by main().

{
  TRACE;
  if(i==_n-1) {
    return 0.5*_maximumWavelength;
  } else {
    return _depths[i+1]+0.5*(_depths[i+2]-_depths[i+1]);
  }
}
double DepthDistribution::maximumWavelength ( ) const [inline]
{return _maximumWavelength;}
double DepthDistribution::minimumDepth ( int  i) const

References TRACE.

Referenced by main().

{
  TRACE;
  return _depths[i]+0.5*(_depths[i+1]-_depths[i]);
}
double DepthDistribution::minimumWavelength ( ) const [inline]
{return _minimumWavelength;}
double DepthDistribution::q ( ) const [inline]
{return _q;}
void DepthDistribution::report ( QTextStream &  s) const

References QGpCoreTools::endl(), and TRACE.

Referenced by main().

{
  TRACE;
  s << "# h[i]=" << _a << "*" << _q << "^i" << endl;
  s << "# i | h | z at top | z at bottom | min[z] | max[z]" << endl;
  for(int i=0;i<_n;i++) {
    double z=_depths[i];
    double dz1=_depths[i+1]-z;
    double dz2=_depths[i+2]-_depths[i+1];
    s << i << " " << dz1 << " " << z << " " << z+dz1 << " " << z+0.5*dz1 << " " << z+dz1+0.5*dz2 << endl;
  }
  s << _n << " inf " << _depths[_n] << endl;
}
bool DepthDistribution::setLayerCount ( int  layerCount)

If layerCount==1 => returns just a range based on min and max

References layerCount(), and TRACE.

Referenced by main().

{
  TRACE;
  if(layerCount<=0) return false;
  _n=layerCount;
  return true;
}
void DepthDistribution::setMaximumWavelength ( double  m) [inline]

Referenced by main().

{_maximumWavelength=m;}

References TRACE.

Referenced by main().

{
  TRACE;
  _minimumWavelength=m;
  _a=0.25*_minimumWavelength;
}
double DepthDistribution::thickness ( int  i) const

References TRACE.

Referenced by main().

{
  TRACE;
  return _depths[i+1]-_depths[i];
}
double DepthDistribution::y ( double  q) const

Referenced by calculate().

{
  return _a*pow(q,_n)
        -0.5*_maximumWavelength*q+
         0.5*_maximumWavelength-_a;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines