-
Notifications
You must be signed in to change notification settings - Fork 2
/
kedsolver_fh.m
44 lines (33 loc) · 1.08 KB
/
kedsolver_fh.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function [ kedsolver_fh ] = kedsolver_fh(Nelem, dx, Tol)
% provides a handle to a function which can return density and kinetic
% energy density.
if nargin<3
RelTol = eps;
AbsTol = eps;
else
RelTol = Tol;
AbsTol = Tol;
end
shoot = shoot_fh(Nelem,dx);
dens = @(E,v,vL,vR) ldos(shoot(E,v,vL,vR));
% return function handle
kedsolver_fh = @kedsolve;
function [n,ts] = kedsolve(mu,v,vL,vR)
E0 = min(v)-1;
R = (E0+mu)/2;
A = mu-R;
E = @(theta) R + A*exp(1i*theta);
dEdt = @(theta) 1i*A*exp(1i*theta);
n = integral(@(theta) dens(E(theta),v,vL,vR)*dEdt(theta),0,pi,...
'ArrayValued',true,...
'RelTol',RelTol,...
'AbsTol',AbsTol);
n = n+conj(n);
e = integral(@(theta) E(theta)*dens(E(theta),v,vL,vR)*dEdt(theta),0,pi,...
'ArrayValued',true,...
'RelTol',RelTol,...
'AbsTol',AbsTol);
e = e+conj(e);
ts = e - v.*n;
end
end