Skip to content

Sandu split Allen-Cahn - #142

Open
adrian-sandu wants to merge 6 commits into
masterfrom
sandu_polished
Open

Sandu split Allen-Cahn#142
adrian-sandu wants to merge 6 commits into
masterfrom
sandu_polished

Conversation

@adrian-sandu

Copy link
Copy Markdown

Added Allen Cahn splitting into linear/nonlinear parts, and diffusion/reaction parts.

Comment thread toolbox/+otp/+allencahn/f_diffusion.m Outdated
% f = f_diffusion + f_reaction
% Jacobian = Jacobian_diffusion + Jacobian_reaction
%
function du = f_diffusion(~, u, L, alpha, ~, ~)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename to fDiffusion, we do not use underscores in OTP

Comment thread toolbox/+otp/+allencahn/f_linear.m Outdated
% Linear-nonlinear splitting: f = f_linear + f_nonlinear
% f_linear(u) = Jac*u, f_nonlinear(u) = f(u)-Jac*u

function du = f_linear(~, u, L, alpha, beta, ~)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fLinear

Comment thread toolbox/+otp/+allencahn/f_nonlinear.m Outdated
% Linear-nonlinear splitting: f = f_linear + f_nonlinear
% f_linear(u) = Jac*u, f_nonlinear(u) = f(u)-Jac*u

function du = f_nonlinear(t, u, ~, ~, beta, forcing)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fNonlinear

Comment thread toolbox/+otp/+allencahn/f_reaction.m Outdated
% f = f_diffusion + f_reaction
% Jacobian = Jacobian_diffusion + Jacobian_reaction
%
function du = f_reaction(t, u, ~, ~, beta, forcing)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fReaction

% f = f_diffusion + f_reaction
% Jacobian = Jacobian_diffusion + Jacobian_reaction
%
function j = jacobian_diffusion(~, ~, L, alpha, ~, ~)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jacobianDiffusion

% f = f_diffusion + f_reaction
% Jacobian = Jacobian_diffusion + Jacobian_reaction
%
function j = jacobian_reaction(~, u, L, ~, beta, ~)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jacobianReaction

Comment thread toolboxPackaging.prj
@@ -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">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't commit this file, so please git revert this file

@@ -0,0 +1,9 @@
% Process splitting:

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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

obj.RHSLinear = otp.RHS(@(t, y) otp.brusselator.fLinear(t, y, a, b), ...
'Jacobian', otp.brusselator.jacobianLinear(a, b), ...
'Vectorized', 'on');
obj.RHSNonlinear = otp.RHS(@(t, y) otp.brusselator.fNonlinear(t, y, a, b), ...
'Jacobian', @(t, y) otp.brusselator.jacobianNonlinear(t, y, a, b), ...
'Vectorized', 'on');

@@ -0,0 +1,9 @@
% Process splitting:

Copy link
Copy Markdown
Member

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

obj.RHSLinear = otp.RHS(@(t, y) otp.brusselator.fLinear(t, y, a, b), ...
'Jacobian', otp.brusselator.jacobianLinear(a, b), ...
'Vectorized', 'on');
obj.RHSNonlinear = otp.RHS(@(t, y) otp.brusselator.fNonlinear(t, y, a, b), ...
'Jacobian', @(t, y) otp.brusselator.jacobianNonlinear(t, y, a, b), ...
'Vectorized', 'on');

Comment thread toolbox/+otp/+allencahn/f_linear.m Outdated

function du = f_linear(~, u, L, alpha, beta, ~)

du = alpha*L*u + beta * (u - 3*u.^3);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? It looks like it has nonlinear terms.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to create the splitting $y' = J(y) y + (f(y) - J(y) y)$ where the linear split term is $y' = J(y) y$. So this is correct given the nonlinear term $f(u) = u - u^3$.
However, we may want separate evaluation of $ J(z) y$ ( e.g. $J(y_{n}) y$) but, I think that maybe out of scope here for now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. In that case, I think the names are ok as long as it is documented. Alternatively, you could consider calling them RHSJacobian and RHSRemainder.

@alexander-novo alexander-novo added the enhancement New feature or request label Sep 2, 2026
@AndreyAPopov

Copy link
Copy Markdown
Member

@Steven-Roberts Without Documentation, but does work right now, please check.

@AndreyAPopov

Copy link
Copy Markdown
Member

@adrian-sandu I fixed some of the code and added it correctly to the problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants