From 1d1c8497379b96c6094c77a42488fa9faab54392 Mon Sep 17 00:00:00 2001 From: Louis Wonnell Date: Thu, 30 Jan 2020 14:48:01 -0500 Subject: [PATCH 1/3] Created moment_integral.m to take moments of some test function with respect to a distribution function, --- moment_integral.m | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 moment_integral.m diff --git a/moment_integral.m b/moment_integral.m new file mode 100644 index 00000000..ee2c0321 --- /dev/null +++ b/moment_integral.m @@ -0,0 +1,43 @@ +function MomentValue = moment_integral(pde, fval_realspace, gfunc) + +xmin = pde.dimensions{1,1}.domainMin; +xmax = pde.dimensions{1,1}.domainMax; +Lev = pde.lev_vec; +h = (xmax - xmin)/2^(Lev(1)); +deg = pde.deg; +num_dimensions = length(pde.dimensions); + +[quad_xx, quad_ww] = lgwt(deg, -1, 1); + +quad_ww = 2^(-Lev(1))/2*quad_ww; + +ww = repmat(quad_ww, 2^Lev(1), 1); + +ww = ww.*(xmax - xmin); %for 2D use Kronmult + +if num_dimensions >= 2 + for i = 2:num_dimensions + domainMin = pde.dimensions{1,i}.domainMin; + domainMax = pde.dimensions{1,i}.domainMax; + ww = kron(ww,ww)*(domainMax - domainMin); + end +end + +[x, w] = lgwt(deg, 0, h); + +points = []; +%num = 2^Lev*deg; + + +for i = 0:2^Lev-1 + points = [points; xmin + x + i*h]; +end + +%points2 = repmat(points, [num 1]); + +%points2 = reshape(reshape(points2,num,num)',num*num,1); + +MomentValue = sum(ww.*fval_realspace.*gfunc); + +end + From b4b9d4e1d5ebcac49ac304b73e917a3384d635b6 Mon Sep 17 00:00:00 2001 From: Louis Wonnell Date: Thu, 30 Jan 2020 15:43:08 -0500 Subject: [PATCH 2/3] Added commented lines inside asgard to allow for user to call moment_integral for some test function. --- asgard.m | 7 +++++++ two_scale/two_scale_rel_3.mat | Bin 0 -> 511 bytes 2 files changed, 7 insertions(+) create mode 100644 two_scale/two_scale_rel_3.mat diff --git a/asgard.m b/asgard.m index 69283e88..60f849b4 100644 --- a/asgard.m +++ b/asgard.m @@ -148,6 +148,13 @@ fval_realspace = wavelet_to_realspace(pde,opts,Meval,fval,hash_table); fval_realspace_analytic = get_analytic_realspace_solution_D(pde,opts,coord,t); +%test_func = 1; %test function + +%Taking the moment of test_func with respect to the numerical distribution +%function + +%test_moment = moment_integral(pde, fval_realspace, test_func); + err_wavelet = sqrt(mean((fval(:) - fval_analytic(:)).^2)); err_realspace = sqrt(mean((fval_realspace(:) - fval_realspace_analytic(:)).^2)); if ~opts.quiet diff --git a/two_scale/two_scale_rel_3.mat b/two_scale/two_scale_rel_3.mat new file mode 100644 index 0000000000000000000000000000000000000000..940d582ece1dfc31ca0de8044b4e9b1a4e501e79 GIT binary patch literal 511 zcmeZu4DoSvQZUssQ1EpO(M`+DN!3vZ$Vn_o%P-2cQgHY2i*PhE(NSF`tk$W{yR-f>e@re7{*O#B^R-~<8cS7@$`QwjuY$hAHb?VRVD_ePU z=~n%DNhk7|Ps?v+XV}syHUngAAU;pGA1I@it;^)knF{)SZ8L#Mbix2#ve;9mfeoue7`Lw*T+>Gp(OUj?KbTeP6WiN9$B75P8EW;vw Gb5j6&cfa}o literal 0 HcmV?d00001 From 8ef33369bce8eb23c8cda4203f8fa73544673a7c Mon Sep 17 00:00:00 2001 From: Louis Wonnell Date: Mon, 10 Feb 2020 16:28:17 -0500 Subject: [PATCH 3/3] Moved the normalization of Gaussian weights in moment_integral.m to the proper location after the for loop. Function now gives proper answers for test_moment inside asgard.m --- asgard.m | 4 ++-- moment_integral.m | 14 +++++++------- two_scale/two_scale_rel_2.mat | Bin 413 -> 0 bytes two_scale/two_scale_rel_3.mat | Bin 511 -> 0 bytes 4 files changed, 9 insertions(+), 9 deletions(-) delete mode 100644 two_scale/two_scale_rel_2.mat delete mode 100644 two_scale/two_scale_rel_3.mat diff --git a/asgard.m b/asgard.m index 60f849b4..bfed80b9 100644 --- a/asgard.m +++ b/asgard.m @@ -148,12 +148,12 @@ fval_realspace = wavelet_to_realspace(pde,opts,Meval,fval,hash_table); fval_realspace_analytic = get_analytic_realspace_solution_D(pde,opts,coord,t); -%test_func = 1; %test function +test_func = 1; %test function %Taking the moment of test_func with respect to the numerical distribution %function -%test_moment = moment_integral(pde, fval_realspace, test_func); +test_moment = moment_integral(pde, fval_realspace, test_func); err_wavelet = sqrt(mean((fval(:) - fval_analytic(:)).^2)); err_realspace = sqrt(mean((fval_realspace(:) - fval_realspace_analytic(:)).^2)); diff --git a/moment_integral.m b/moment_integral.m index ee2c0321..89b8b9e8 100644 --- a/moment_integral.m +++ b/moment_integral.m @@ -13,8 +13,6 @@ ww = repmat(quad_ww, 2^Lev(1), 1); -ww = ww.*(xmax - xmin); %for 2D use Kronmult - if num_dimensions >= 2 for i = 2:num_dimensions domainMin = pde.dimensions{1,i}.domainMin; @@ -23,15 +21,17 @@ end end -[x, w] = lgwt(deg, 0, h); +ww = ww.*(xmax - xmin); + +%[x, w] = lgwt(deg, 0, h); -points = []; +%points = []; %num = 2^Lev*deg; -for i = 0:2^Lev-1 - points = [points; xmin + x + i*h]; -end +%for i = 0:2^Lev(i)-1 +% points = [points; xmin + x + i*h]; +%end %points2 = repmat(points, [num 1]); diff --git a/two_scale/two_scale_rel_2.mat b/two_scale/two_scale_rel_2.mat deleted file mode 100644 index be26675300ee3321d8c4587d9f7f84dd0031c344..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 413 zcmeZu4DoSvQZUssQ1EpO(M`+DN!3vZ$Vn_o%P-2cQgHY2i*PhE(NS}aZCnRt%B$+8Z zYq+Fvfa|HTqoMMIF9rz-4_G#dHvCvoT6=2`>-jfVMJ-)_rP7a zJf}d$*y1*(#2jLbgusKHU~{g&>2G+M{`;v2*syKv4EO)>ya5?v2{)tz%`H>n=ggTg zS!({A^PDN#1_}qX=68sP-mbgtTp|A^@ezYz9_KNT0UmGzRv;O$nZZz4z}V?2myyxq w$)6=9EE;pz74E$f{F`tk$W{yR-f>e@re7{*O#B^R-~<8cS7@$`QwjuY$hAHb?VRVD_ePU z=~n%DNhk7|Ps?v+XV}syHUngAAU;pGA1I@it;^)knF{)SZ8L#Mbix2#ve;9mfeoue7`Lw*T+>Gp(OUj?KbTeP6WiN9$B75P8EW;vw Gb5j6&cfa}o