File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -460,21 +460,21 @@ def cor(self, h):
460460
461461 def spectral_density (self , k ): # noqa: D102
462462 k = np .asarray (k , dtype = np .double )
463- x = (k * self .len_rescaled / 2.0 ) ** 2
463+ fac = (0.5 * self .len_rescaled / np .sqrt (np .pi )) ** self .dim
464+ lim = fac * self .nu / (self .nu + self .dim )
464465 # for nu > 50 we just use an approximation of the gaussian model
465466 if self .nu > 50.0 :
466- return (
467- (0.5 * self .len_rescaled / np .sqrt (np .pi )) ** self .dim
468- * np .exp (- x )
469- * self .nu
470- / (self .nu + self .dim )
471- * (1.0 + 2 * x / (self .nu + self .dim + 2 ))
472- )
473- return (
474- self .nu
475- / (x ** (self .nu * 0.5 ) * 2 * (k * np .sqrt (np .pi )) ** self .dim )
476- * inc_gamma_low ((self .nu + self .dim ) / 2.0 , x )
477- )
467+ x = (k * self .len_rescaled / 2 ) ** 2
468+ return lim * np .exp (- x ) * (1 + 2 * x / (self .nu + self .dim + 2 ))
469+ # separate calculation at origin
470+ s = (self .nu + self .dim ) / 2
471+ res = np .empty_like (k )
472+ k_gz = np .logical_not (np .isclose (k , 0 ))
473+ x = (k [k_gz ] * self .len_rescaled / 2 ) ** 2
474+ # limit at k=0 (inc_gamma_low(s, x) / x**s -> 1/s for x -> 0)
475+ res [np .logical_not (k_gz )] = lim
476+ res [k_gz ] = 0.5 * self .nu * fac / x ** s * inc_gamma_low (s , x )
477+ return res
478478
479479 def calc_integral_scale (self ): # noqa: D102
480480 return (
You can’t perform that action at this time.
0 commit comments