Commit b09d6104 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

simple interface for particle settling

parent 890353f1
......@@ -816,6 +816,7 @@ int dgParticleTracker2D::isSettled(double t, int m)
case 0:
return 0;
case 1: /* Flat settling rate (coral larvae) */
settRate = 1-pow(1-_settRate_max, _dt/(24*3600));
if ( _settRate_max > ((randoraw()/2.0)+0.5) ) return 1;
else return 0;
case 2: /* Pyramidal settling rate (fish larvae) */
......@@ -823,6 +824,7 @@ int dgParticleTracker2D::isSettled(double t, int m)
if (t<=_t_settMax) settRate = _settRate_max * (t - _t_preComp)/(_t_settMax - _t_preComp);
if (t>_t_settMax) settRate = _settRate_max * (_t_postComp - t)/(_t_postComp - _t_settMax);
//B. Check if particle settles
settRate = 1-pow(1-_settRate_max, _dt/(24*3600));
if ( settRate > ((randoraw()/2.0)+0.5) ) return 1;
else return 0;
case 3: /* Flat settling rate if competent*/
......
......@@ -301,7 +301,7 @@ private:
double _dt;
int _N;
int _settleType, _mortType, _swimType, _windDragType, _settleOverWhichReefType, _nbOfShallowReefs;
double _t_preComp, _t_postComp, _t_settMax, _settRate_max, _compAcquisitionRate, _compAcquisitionProb, _compLossRate;
double _t_preComp, _t_postComp, _t_settMax, _settRate_max, _compAcquisitionRate, _compLossRate;
double _mortRate_max, _mortLambda, _mortNu;
double _swimSpeed, _swimDist, _swimStart;
double _windDragStart, _windDragStop, _windDragCoeff;
......@@ -335,6 +335,7 @@ public:
_swimFlag = false;
_connectivityExposureTimeFlag = false;
_windFlag = false;
_settleOverWhichReefType = 0;
//Load model:
_neighbourMap = new dgNeighbourMap(*_group);
......@@ -379,42 +380,49 @@ public:
}
/** Activate particle settling and load parameters */
/*
* settleParams :
* [0] : settlingType :
* 0: no settling
* 1: flat settling all particles can settle at any time with probabylity given py [4] settleRateMax
* 2: all particle can settle with a probability that increases linearly between 0 in [1] tPreComp and [4] settleRateMax in [3] tSettleMax then decreases linearly to 0 in [2] tPostComp
* 3: all particles settles when they are competents, competency is aquired and lost with flat rate [5] compAquisitionRate and [6] compLossRate
* [7] : settleOverWhichReefType :
* 0: all reefs
* 1: only shallow reefs
* 2: only deep reefs
* reefs :
* a dof container with the id of the reef by element (0 = no reef)
* nbOfShallowReefs :
* reefs with id <= nbOfShallowReefs are shallow reefs, the others are deep reefs
*/
void addSettling(fullMatrix<double>* settleParams, dgDofContainer* reefs, int nbOfShallowReefs) {
/* reefs :
* a dof container with the id of the reef by element (0 = no reef)*/
/* flat settling all particles can settle between tPreComp and tPostComp with probabylity by day given py settleRate*/
void setFlatSettling(double settleRate, dgDofContainer* reefs, double tPreComp, double tPostComp){
_settleFlag = true;
_settleType = 1;
_settRate_max = settleRate;
_t_preComp = tPreComp;
_t_postComp = tPostComp;
_reefs = reefs;
}
/* all particle can settle with a probability that increases linearly between 0 in [1] tPreComp and [4] settleRateMax in [3] tSettleMax then decreases linearly to 0 in [2] tPostComp */
void setLinearSettling(double maxRate, dgDofContainer* reefs, double tPreComp, double tPostComp, double tSettleMax) {
_settleFlag = true;
_settleType = static_cast<int>(settleParams->get(0,0)+0.1);
_t_preComp = settleParams->get(0,1);
_t_postComp = settleParams->get(0,2);
_t_settMax = settleParams->get(0,3);
_settRate_max = settleParams->get(0,4);
_compAcquisitionRate = settleParams->get(0,5); //(Connolly & Baird 2010): a
_compLossRate = settleParams->get(0,6); //(Connolly & Baird 2010): b
_settleOverWhichReefType = settleParams->get(0,7);
//Get settlement probability in time interval dt
_compAcquisitionProb = 1 - exp( -_compAcquisitionRate * (_dt/(24.0*3600)) );
//Convert competency acquisition & loss rates to (dt-1)
_compAcquisitionRate = (_dt/(24.0*3600.0)) * _compAcquisitionRate;
_compLossRate = (_dt/(24.0*3600.0)) * _compLossRate;
std::cout << "\nTEMP COMPARISON: _compAcquisitionRate: " <<_compAcquisitionRate<< ", _compAcquisitionProb: "<<_compAcquisitionProb<<'\n';
_settleType = 2;
_settRate_max = maxRate;
_t_preComp = tPreComp;
_t_postComp = tPostComp;
_t_settMax = tSettleMax;
_reefs = reefs;
}
/* all particles settles when they are competents, competency is aquired and lost with flat rate [5] compAquisitionRate and [6] compLossRate*/
void setCompetentSettling(dgDofContainer* reefs, double tPreComp, double tPostComp, double compAcquisitionRate, double compLossRate) {
_settleFlag = true;
_settleType = 3;
_compAcquisitionRate = 1-pow(1-compAcquisitionRate, _dt/(24.0*3600.0));
_compLossRate = 1-pow(1-compLossRate, _dt/(24.0*3600.0));
_reefs = reefs;
_nbOfShallowReefs = nbOfShallowReefs;
_t_preComp = tPreComp;
_t_postComp = tPostComp;
}
/* type :
* 0: all reefs
* 1: only shallow reefs (ie with idx < nbShallowReefs)
* 2: only deep reefs (ie with idx > nbShallowReefs)
*/
void setSettlingOverWhichReefs(int type, int nbShallowReefs) {
_settleOverWhichReefType = type;
_nbOfShallowReefs = nbShallowReefs;
}
/** Calculate connectivity matrix using exposure time method */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment