-
Notifications
You must be signed in to change notification settings - Fork 3
Sandu split Allen-Cahn #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adrian-sandu
wants to merge
6
commits into
master
Choose a base branch
from
sandu_polished
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
66cb5bb
Allen Cahn splitting added
adrian-sandu 4b3de2c
AS on AllenCahn
adrian-sandu ff2533c
Linear-nonlinear splitting of Allen-Cahn
adrian-sandu 7f5567e
Split Allen-Cahn into diffusion and reaction parts
adrian-sandu bc1e13d
Fixed Allen-Cahn PR feedback
adrian-sandu dfeb7bd
Added the alternative RHSs to problem and tests
AndreyAPopov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| function validateqg | ||
|
|
||
| fprintf(' Testing Allen-Cahn Equations\n'); | ||
|
|
||
| forcings = {8, @(t, ~, ~) cos(t)}; | ||
|
|
||
| for fi = 1:numel(forcings) | ||
| forcing = forcings{fi}; | ||
|
|
||
| model = otp.allencahn.presets.Canonical('Size', 16, 'Forcing', forcing); | ||
| model.Parameters.LinearizationPoint = model.Y0; | ||
|
|
||
| %% Linear | ||
| [~] = otp.utils.Solver.Nonstiff(model.RHSLinear.F, model.TimeSpan, model.Y0); | ||
| fprintf(' Alternate RHSLinear RHS passed\n'); | ||
|
|
||
| %% Non-Linear | ||
| [~] = otp.utils.Solver.Nonstiff(model.RHSLinear.F, model.TimeSpan, model.Y0); | ||
| fprintf(' Alternate RHSNonlinear RHS passed\n'); | ||
|
|
||
| %% Reaction | ||
| [~] = otp.utils.Solver.Nonstiff(model.RHSReaction.F, model.TimeSpan, model.Y0); | ||
| fprintf(' Alternate RHSReaction RHS passed\n'); | ||
|
|
||
| tc = model.TimeSpan(1); | ||
| y0 = model.Y0; | ||
|
|
||
| f = @(t, y) model.RHSReaction.F(t, y); | ||
| japprox = model.RHSReaction.Jacobian(tc, y0); | ||
| jtrue = otp.utils.derivatives.jacobian(f, tc, y0); | ||
|
|
||
| normj = norm(jtrue); | ||
|
|
||
| if normj < eps | ||
| err = norm(jtrue - japprox); | ||
| else | ||
| err = norm(jtrue - japprox)/normj; | ||
| end | ||
|
|
||
| tol = 1e-6; | ||
| assert(err < tol); | ||
|
|
||
| fprintf(' Reaction Jacobian passed\n'); | ||
|
|
||
| %% Diffusion | ||
| [~] = otp.utils.Solver.Nonstiff(model.RHSDiffusion.F, model.TimeSpan, model.Y0); | ||
| fprintf(' Alternate RHSDiffusion RHS passed\n'); | ||
|
|
||
| tc = model.TimeSpan(1); | ||
| y0 = model.Y0; | ||
|
|
||
| f = @(t, y) model.RHSDiffusion.F(t, y); | ||
| japprox = model.RHSDiffusion.Jacobian(tc, y0); | ||
| jtrue = otp.utils.derivatives.jacobian(f, tc, y0); | ||
|
|
||
| normj = norm(jtrue); | ||
|
|
||
| if normj < eps | ||
| err = norm(jtrue - japprox); | ||
| else | ||
| err = norm(jtrue - japprox)/normj; | ||
| end | ||
|
|
||
| tol = 1e-6; | ||
| assert(err < tol); | ||
|
|
||
| fprintf(' Diffusion Jacobian passed\n'); | ||
|
|
||
| end | ||
|
|
||
| end | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| % Process splitting: | ||
| % f = f_diffusion + f_reaction | ||
| % Jacobian = Jacobian_diffusion + Jacobian_reaction | ||
| % | ||
| function du = fDiffusion(~, u, L, alpha, ~, ~) | ||
|
|
||
| du = alpha*L*u; | ||
|
|
||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| % Linear-nonlinear splitting: f = f_linear + f_nonlinear | ||
| % f_linear(u) = Jac(uL)*u, f_nonlinear(u) = f(u)-Jac(uL)*u | ||
| % uL = linearization point, typically the solution at the beginning of the | ||
| % time step | ||
|
|
||
|
|
||
| function du = fLinear(~, u, L, alpha, beta, ~, uL) | ||
|
|
||
| du = alpha*L*u + beta*(u - 3*(uL.^2).*u); | ||
|
|
||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| % Linear-nonlinear splitting: f = f_linear + f_nonlinear | ||
| % f_linear(u) = Jac*u, f_nonlinear(u) = f(u)-Jac*u | ||
| % uL = linearization point, typically the solution at the beginning of the | ||
| % time step | ||
|
|
||
| function du = fNonlinear(t, u, ~, ~, beta, forcing, uL) | ||
|
|
||
| du = beta*( - u.^3 + 3*(uL.^2).*u ) + forcing(t); | ||
|
|
||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| % Process splitting: | ||
| % f = f_diffusion + f_reaction | ||
| % Jacobian = Jacobian_diffusion + Jacobian_reaction | ||
| % | ||
| function du = fReaction(t, u, ~, ~, beta, forcing) | ||
|
|
||
| du = beta*(u - u.^3) + forcing(t); | ||
|
|
||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| % Process splitting: | ||
| % f = f_diffusion + f_reaction | ||
| % Jacobian = Jacobian_diffusion + Jacobian_reaction | ||
| % | ||
| function j = jacobianDiffusion(~, ~, L, alpha, ~, ~) | ||
|
|
||
| j = alpha*L; | ||
|
|
||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| % Process splitting: | ||
| % f = f_diffusion + f_reaction | ||
| % Jacobian = Jacobian_diffusion + Jacobian_reaction | ||
| % | ||
| function j = jacobianReaction(~, u, L, ~, beta, ~) | ||
|
|
||
| j = spdiags(beta*(1 - 3*u.^2), 0, size(L, 1), size(L, 2)); | ||
|
|
||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| <deployment-project plugin="plugin.toolbox" plugin-version="1.0"> | ||
| <configuration name="ODE Test Problems" target="target.toolbox" target-name="Package Toolbox"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please don't commit this file, so please git revert this file |
||
| <configuration file="/Users/sandu/GIT/GitHub/ODE-Test-Problems/toolboxPackaging.prj" location="/Users/sandu/GIT/GitHub/ODE-Test-Problems" name="toolboxPackaging" target="target.toolbox" target-name="Package Toolbox"> | ||
| <param.appname>ODE Test Problems</param.appname> | ||
| <param.authnamewatermark>Steven Roberts, Andrey A. Popov, Arash Sarshar, Adrian Sandu</param.authnamewatermark> | ||
| <param.email /> | ||
|
|
@@ -14,7 +14,7 @@ | |
| <param.products.version /> | ||
| <param.platforms /> | ||
| <param.guid>0970ed36-a788-484f-beca-105eecd2562a</param.guid> | ||
| <param.exclude.filters></param.exclude.filters> | ||
| <param.exclude.filters /> | ||
| <param.exclude.pcodedmfiles>true</param.exclude.pcodedmfiles> | ||
| <param.examples /> | ||
| <param.demosxml /> | ||
|
|
@@ -85,5 +85,59 @@ | |
| <fileset.depfun.included /> | ||
| <fileset.depfun.excluded /> | ||
| <fileset.package /> | ||
| <build-deliverables> | ||
| <file location="${PROJECT_ROOT}" name="ODE Test Problems.mltbx" optional="false">/Users/sandu/GIT/GitHub/ODE-Test-Problems/ODE Test Problems.mltbx</file> | ||
| </build-deliverables> | ||
| <workflow /> | ||
| <matlab> | ||
| <root>/Applications/MATLAB_R2024b.app</root> | ||
| <toolboxes> | ||
| <toolbox name="matlabcoder" /> | ||
| <toolbox name="embeddedcoder" /> | ||
| <toolbox name="fixedpoint" /> | ||
| <toolbox name="matlabhdlcoder" /> | ||
| <toolbox name="neuralnetwork" /> | ||
| </toolboxes> | ||
| <toolbox> | ||
| <matlabcoder> | ||
| <enabled>true</enabled> | ||
| </matlabcoder> | ||
| </toolbox> | ||
| <toolbox> | ||
| <embeddedcoder> | ||
| <enabled>true</enabled> | ||
| </embeddedcoder> | ||
| </toolbox> | ||
| <toolbox> | ||
| <fixedpoint> | ||
| <enabled>true</enabled> | ||
| </fixedpoint> | ||
| </toolbox> | ||
| <toolbox> | ||
| <matlabhdlcoder> | ||
| <enabled>true</enabled> | ||
| </matlabhdlcoder> | ||
| </toolbox> | ||
| <toolbox> | ||
| <neuralnetwork> | ||
| <enabled>true</enabled> | ||
| </neuralnetwork> | ||
| </toolbox> | ||
| </matlab> | ||
| <platform> | ||
| <unix>true</unix> | ||
| <mac>true</mac> | ||
| <windows>false</windows> | ||
| <win2k>false</win2k> | ||
| <winxp>false</winxp> | ||
| <vista>false</vista> | ||
| <linux>false</linux> | ||
| <solaris>false</solaris> | ||
| <osver>15.5</osver> | ||
| <os32>true</os32> | ||
| <os64>false</os64> | ||
| <arch>maci64</arch> | ||
| <matlab>true</matlab> | ||
| </platform> | ||
| </configuration> | ||
| </deployment-project> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Steven: We need to add these functions to the problem file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, here is an example
ODE-Test-Problems/toolbox/+otp/+brusselator/BrusselatorProblem.m
Lines 88 to 94 in 167bdc1