Skip to content
Snippets Groups Projects
Commit df123c4b authored by Elias Pipping's avatar Elias Pipping Committed by Elias Pipping
Browse files

Clean up RuinaFunction

Drop members a, V_0, K
Move a into coefficientProduct
Move V_0 into V_m

Add comments that show what we're computing
parent 21832026
No related branches found
No related tags found
No related merge requests found
...@@ -38,56 +38,62 @@ class NiceFunction { ...@@ -38,56 +38,62 @@ class NiceFunction {
} }
}; };
// phi(V) = V log(V/V_m) - V + V_m if V >= V_m
// = 0 otherwise
// with V_m = V_0 exp(-K/a),
// i.e. K = -a log(V_m / V_0) = mu_0 + b log(V_0 / L) + b alpha
class RuinaFunction : public NiceFunction { class RuinaFunction : public NiceFunction {
public: public:
RuinaFunction(double coefficient, double a, double mu_0, double V_0, RuinaFunction(double coefficient, double a, double mu_0, double V_0,
double normalStress, double b, double state, double L) double normalStress, double b, double state, double L)
: NiceFunction(), : NiceFunction(),
a(a), coefficientProduct(coefficient * a * normalStress),
V_0(V_0),
coefficientProduct(coefficient * normalStress),
// state is assumed to be logarithmic // state is assumed to be logarithmic
K(mu_0 + b * (state + std::log(V_0 / L))), V_m(V_0 * std::exp(-(mu_0 + b * (state + std::log(V_0 / L))) / a))
V_m(std::exp(-K / a)) {} // We could also compute V_m as
// V_0 * std::exp(-(mu_0 + b * state)/a)
// * std::pow(V_0 / L, -b/a)
// which would avoid the std::exp(std::log())
{}
double virtual evaluate(double V) const { double virtual evaluate(double V) const {
double const arg = V / V_0; assert(V >= 0);
if (arg <= V_m) if (V <= V_m)
return 0; return 0;
return coefficientProduct * // V log(V/V_m) - V + V_m
(+a * arg * (std::log(arg) - 1) + K * arg + a * V_m); return coefficientProduct * (V * std::log(V / V_m) - V + V_m);
} }
// log(V/V_m) if V >= V_0
// 0 otherwise
double virtual leftDifferential(double V) const { double virtual leftDifferential(double V) const {
double const arg = V / V_0; assert(V >= 0);
if (arg <= V_m) if (V <= V_m)
return 0; return 0;
double const ret = a * std::log(arg) + K; return coefficientProduct * std::log(V / V_m);
return coefficientProduct * ret;
} }
double virtual rightDifferential(double V) const { double virtual rightDifferential(double V) const {
return leftDifferential(V); return leftDifferential(V);
} }
// 1/V if V > V_0
// undefined if V == V_0
// 0 if V < V_0
double virtual second_deriv(double V) const { double virtual second_deriv(double V) const {
assert(V >= 0); assert(V >= 0);
assert(V_0 > 0); if (V <= V_m)
double const arg = V / V_0;
if (arg <= V_m)
return 0; return 0;
return coefficientProduct * a / V; return coefficientProduct / V;
} }
double virtual regularity(double V) const { double virtual regularity(double V) const {
assert(V >= 0); assert(V >= 0);
assert(V_0 > 0);
double const arg = V / V_0;
// TODO: Make this controllable // TODO: Make this controllable
if (std::abs(arg - V_m) < 1e-14) if (std::abs(V - V_m) < 1e-14)
return std::numeric_limits<double>::infinity(); return std::numeric_limits<double>::infinity();
return std::abs(second_deriv(V)); return std::abs(second_deriv(V));
...@@ -96,10 +102,7 @@ class RuinaFunction : public NiceFunction { ...@@ -96,10 +102,7 @@ class RuinaFunction : public NiceFunction {
bool virtual smoothesNorm() const { return true; } bool virtual smoothesNorm() const { return true; }
private: private:
double const a;
double const V_0;
double const coefficientProduct; double const coefficientProduct;
double const K;
double const V_m; double const V_m;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment