Skip to content
Snippets Groups Projects
Commit 2f729192 authored by Sumbel Shangareeva's avatar Sumbel Shangareeva
Browse files

added dy/dx for all functions

parent b955e20c
No related branches found
No related tags found
No related merge requests found
...@@ -38,15 +38,19 @@ contains ...@@ -38,15 +38,19 @@ contains
fun_kit%dfun => dfun_lin fun_kit%dfun => dfun_lin
case('exp') case('exp')
fun_kit%fun => fun_exp fun_kit%fun => fun_exp
fun_kit%dfun => dfun_exp
case('hyp') case('hyp')
fun_kit%fun => fun_hyp fun_kit%fun => fun_hyp
fun_kit%dfun => dfun_hyp
case('mm') case('mm')
fun_kit%fun => fun_mm fun_kit%fun => fun_mm
fun_kit%dfun => dfun_mm
case('step') case('step')
fun_kit%fun => fun_step fun_kit%fun => fun_step
fun_kit%dfun => dfun_step fun_kit%dfun => dfun_step
case('PieWise1') case('PieWise1')
fun_kit%fun => fun_PieWise1 fun_kit%fun => fun_PieWise1
fun_kit%dfun => dfun_PieWise1
case('PieWise2') case('PieWise2')
fun_kit%fun => fun_PieWise2 fun_kit%fun => fun_PieWise2
fun_kit%dfun => dfun_PieWise2 fun_kit%dfun => dfun_PieWise2
...@@ -136,6 +140,15 @@ contains ...@@ -136,6 +140,15 @@ contains
y = pars(3) / (args(1) - pars(2)) + pars(1) y = pars(3) / (args(1) - pars(2)) + pars(1)
end function fun_hyp end function fun_hyp
!> Deriv of hyperbolic function: y' = -k/(x-x0)**2
function dfun_hyp(args, pars) result(dy)
implicit none
real, intent(in) :: args(narg_default)
real, intent(in) :: pars(npar_default)
real :: dy
dy = - pars(3) / ((args(1) - pars(2)) * (args(1) - pars(2)))
end function dfun_hyp
!> Michaelis-Menthen function: y = k*x/(x-x0) + y0 !> Michaelis-Menthen function: y = k*x/(x-x0) + y0
function fun_mm(args, pars) result(y) function fun_mm(args, pars) result(y)
implicit none implicit none
...@@ -145,6 +158,15 @@ contains ...@@ -145,6 +158,15 @@ contains
y = pars(3) * args(1) / (args(1) - pars(2)) + pars(1) y = pars(3) * args(1) / (args(1) - pars(2)) + pars(1)
end function fun_mm end function fun_mm
!> Deriv of Michaelis-Menthen function: y' = -k*x0/(x-x0)**2
function dfun_mm(args, pars) result(dy)
implicit none
real, intent(in) :: args(narg_default)
real, intent(in) :: pars(npar_default)
real :: dy
dy = - (pars(3) * pars(2)) / ((args(1) - pars(2)) * (args(1) - pars(2)))
end function dfun_mm
!> Step function: y = k*θ(x-x0) + y0 !> Step function: y = k*θ(x-x0) + y0
function fun_step(args, pars) result(y) function fun_step(args, pars) result(y)
implicit none implicit none
...@@ -155,6 +177,7 @@ contains ...@@ -155,6 +177,7 @@ contains
y = pars(1) + pars(3) * theta y = pars(1) + pars(3) * theta
end function fun_step end function fun_step
!> Deriv of step function: y' = 0
function dfun_step(args, pars) result(dy) function dfun_step(args, pars) result(dy)
implicit none implicit none
real, intent(in) :: args(narg_default) real, intent(in) :: args(narg_default)
...@@ -172,6 +195,15 @@ contains ...@@ -172,6 +195,15 @@ contains
y = pars(5) * pars(4)**( pars(3) * (args(1) - pars(2)) ) + pars(1) y = pars(5) * pars(4)**( pars(3) * (args(1) - pars(2)) ) + pars(1)
end function fun_exp end function fun_exp
!> Deriv of exponent function: y' = amp*a**[k*(x-x0)]*k*ln(a)
function dfun_exp(args, pars) result(dy)
implicit none
real, intent(in) :: args(narg_default)
real, intent(in) :: pars(npar_default)
real :: dy
dy = pars(5) * pars(4) ** (pars(3) * (args(1) - pars(2))) * pars(3) * log(pars(4))
end function dfun_exp
!> Piecewise1 function: y = θ1(x1-x)*(k1*x + b1) + θ2(x-x1)*(k2*x + b2) !> Piecewise1 function: y = θ1(x1-x)*(k1*x + b1) + θ2(x-x1)*(k2*x + b2)
function fun_PieWise1(args, pars) result(y) function fun_PieWise1(args, pars) result(y)
implicit none implicit none
...@@ -183,6 +215,17 @@ contains ...@@ -183,6 +215,17 @@ contains
y = theta1*(pars(3)*args(1) + pars(7)) + theta2*(pars(4)*args(1) + pars(8)) y = theta1*(pars(3)*args(1) + pars(7)) + theta2*(pars(4)*args(1) + pars(8))
end function fun_PieWise1 end function fun_PieWise1
!> Deriv of piecewise1 function: y' = θ1(x1-x)*k1 + θ2(x-x1)*k2
function dfun_PieWise1(args, pars) result(dy)
implicit none
real, intent(in) :: args(narg_default)
real, intent(in) :: pars(npar_default)
real :: dy, theta1, theta2
theta1 = 0.5*(1. + sign(1.,pars(2) - args(1)))
theta2 = 0.5*(1. + sign(1.,(args(1) - pars(2))))
dy = theta1*pars(3) + theta2*pars(4)
end function dfun_PieWise1
!> Piecewise2 function: y = θ1(x1-x)*(k1*x + b1) + θ2(x-x1)(x2-x)*(k2*x + b2) + θ3(x-x2)*(k3*x + b3) !> Piecewise2 function: y = θ1(x1-x)*(k1*x + b1) + θ2(x-x1)(x2-x)*(k2*x + b2) + θ3(x-x2)*(k3*x + b3)
function fun_PieWise2(args, pars) result(y) function fun_PieWise2(args, pars) result(y)
implicit none implicit none
...@@ -196,6 +239,7 @@ contains ...@@ -196,6 +239,7 @@ contains
& theta3*(pars(5)*args(1) + pars(6)) & theta3*(pars(5)*args(1) + pars(6))
end function fun_PieWise2 end function fun_PieWise2
!> Deriv of piecewise2 function: y' = θ1(x1-x)*k1 + θ2(x-x1)(x2-x)*k2 + θ3(x-x2)*k3
function dfun_PieWise2(args, pars) result(dy) function dfun_PieWise2(args, pars) result(dy)
implicit none implicit none
real, intent(in) :: args(narg_default) real, intent(in) :: args(narg_default)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment