You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a 1D system x coupled to a harmonic oscillator y with a frequency of omega, so f_yy should be omega^2.
However, when the frequency of the harmonic oscillator is fairly small, like 5e-5, H[2, 2] returned from Calculus.hessian is 0, though Calculus.second_derivative still give the right result.
Simple code to reproduce the problem
using Calculus
# parameters
omega =5e-5
chi =0.02
a =1.9657
b =25.2139
c =9.04337# potentialv(x) =4.254987695360661e-5x^4-0.00278189309952x^2# couplinginter(x, q) =sqrt(2omega) * chi * (a*x-b*tanh(x/c)) * q
# harmonic oscillator vp(q) =0.5* omega^2* q^2# total potentialu(x, q) =inter(x, q) +v(x) +vp(q)
# hessian
h = Calculus.hessian(x ->u(x[1], x[2]))
# printprintln(h([0.0, 0.0]), " hessian")
println(Calculus.second_derivative(vp, 0.0), " 2nd derivative")
The output of the first println is [-0.005563827244039653 -0.0001644434349728066; -0.0001644434349728066 0.0] (H[2, 2] is 0), while the second one gives right value 2.5e-9.
For the time being, I just replace the element h[2, 2] = omega^2 as a work-around.
I understand the value vp gets really really small, so it's kind of difficult to obtain nuermical derivatives, but why would second_derivative work, yet hessian doesn't?
The text was updated successfully, but these errors were encountered:
I have a 1D system
x
coupled to a harmonic oscillatory
with a frequency ofomega
, sof_yy
should beomega^2
.However, when the frequency of the harmonic oscillator is fairly small, like
5e-5
,H[2, 2]
returned fromCalculus.hessian
is 0, thoughCalculus.second_derivative
still give the right result.Simple code to reproduce the problem
The output is
The output of the first
println
is[-0.005563827244039653 -0.0001644434349728066; -0.0001644434349728066 0.0]
(H[2, 2] is 0), while the second one gives right value2.5e-9
.For the time being, I just replace the element
h[2, 2] = omega^2
as a work-around.I understand the value
vp
gets really really small, so it's kind of difficult to obtain nuermical derivatives, but why wouldsecond_derivative
work, yethessian
doesn't?The text was updated successfully, but these errors were encountered: