I'm looking at the instabilities of few modes, and tried to reproduce the net work, W, which is an output attribute with dW_dx and x which can be found in the output mode files.
Looking at the two files /nad/gyre_mode.f90 and /nad/gyre_util.f90, I see how W is simply calculated:
Code: Select all
W = integrate(this%x, this%dW_dx())
Code: Select all
function integrate_r_ (x, y) result (int_y)
real(WP), intent(in) :: x(:)
real(WP), intent(in) :: y(:)
real(WP) :: int_y
integer :: n
! Integrate y(x) using trapezoidal quadrature
n = SIZE(x)
int_y = SUM(0.5_WP*(y(2:) + y(:n-1))*(x(2:) - x(:n-1)))
! Finish
return
end function integrate_r_
Code: Select all
dx = dic['x'][1 : ] - dic['x'][ : -1]
integrand= (dic['dW_dx'][1 : ] + dic['dW_dx'][ : -1]) / 2.
W_cumul = np.zeros(nz-1)
W_net = 0.0
for i in range(nz-1):
W_cumul[i] = np.sum(integrand[0:i+1] * dx[0:i+1])
W_net += integrand[i] * dx[i]
Am I making a mistake here?
dW_dx from gyre_nad is still a real array?
Do I need to provide any file? inlist? mode info? input model?
Thanks in advance.
Ehsan.