Git Product home page Git Product logo

Comments (6)

ChrisRackauckas avatar ChrisRackauckas commented on May 27, 2024

How are you using those versions? MOL v0.2 requires ModelingToolkit v8. It won't let you install that set.

from methodoflines.jl.

ruvilecamwasam avatar ruvilecamwasam commented on May 27, 2024

Sorry, I mistranscribed. I am running ModelingToolkit v8.5.5 (I double checked and the other version numbers I wrote are correct).

from methodoflines.jl.

xtalax avatar xtalax commented on May 27, 2024

Complex equations are not currently supported but I will be working on this, can you reformulate as a system of equations in terms of the real and imaginary parts of
A?

from methodoflines.jl.

ruvilecamwasam avatar ruvilecamwasam commented on May 27, 2024

Thanks, I gave it a try but it doesn't seem to be working.

The PDE is the nonlinear Schrödinger equation:

im Dx(A)+Dzz(A)=-|A|^2A,

where Dx=d/dx, and Dzz=d^2/dz^2. Defining A(x,z)=a(x,z)+im b(x,z) for real functions a(x,z) and b(x,z), this becomes

-Dx(b)+Dzz(a)=-(a^2+b^2)a
Dx(a)+Dzz(b) = -(a^2+b^2)b

Following the tutorial for the Brusselator, I coded this up as below (discretising over z):

using ModelingToolkit, MethodOfLines, OrdinaryDiffEq, DomainSets

@parameters x z
@variables a(..) b(..)
Dx   = Differential(x)
Dz   = Differential(z)
Dzz  = Differential(z)^2

xmin = 0.
xmax = 1e-1
zmax = 10.
zmin = -zmax

c0 = 1.
A0(x,z) = c0*sech(c0*z/sqrt(2))*exp(im*c0^2*x/2) #Initial condition for complex PDE
A0r(x,z) = c0*sech(c0*z/sqrt(2))*cos(c0^2*x/2) #Real part of initial condition
A0i(x,z) = c0*sech(c0*z/sqrt(2))*sin(c0^2*x/2) #Imaginary part of initial condition

domains = [x ∈ Interval(xmin,xmax), z ∈ Interval(zmin,zmax)]

eq = [-Dx(b(x,z))+Dzz(a(x,z)) ~ -(a(x,z)^2+b(x,z)^2)*a(x,z),
       Dx(a(x,z))+Dzz(b(x,z)) ~ -(a(x,z)^2+b(x,z)^2)*b(x,z)]

bcs = [a(xmin,z) ~ A0r(xmin,z), 
        b(xmin,z) ~ A0i(xmin,z),
        a(x,zmin) ~ 0, b(x,zmin) ~ 0,
        a(x,zmax) ~ 0, b(x,zmax) ~ 0]

@named pdesys = PDESystem(eq,bcs,domains,[x,z],[a(x,z),b(x,z)])

N       = 10 #Also tried running for N=100, got same result
dz      = 1/N
order   = 2

discretization = MOLFiniteDifference([z=>dz], x, approx_order=order)

@time prob = discretize(pdesys,discretization)

This gave me a very long error, they key parts of are below. I can't seem to find the problem in my code though.

Discretization failed, please post an issue on https://github.com/SciML/MethodOfLines.jl with the failing code and system at low point count.
ERROR: ExtraVariablesSystemException: The system is unbalanced. There are 402 highest order derivative variables and 398 equations.
More variables than equations, here are the potential extra variable(s):
Stacktrace:
 [1] error_reporting(state::TearingState{ODESystem}, bad_idxs::Vector{Int64}, n_highest_vars::Int64, iseqs::Bool)
   @ ModelingToolkit.StructuralTransformations C:\Users\ruvil\.julia\packages\ModelingToolkit\a7NhS\src\structural_transformation\utils.jl:35
 [2] check_consistency(state::TearingState{ODESystem})
   @ ModelingToolkit.StructuralTransformations C:\Users\ruvil\.julia\packages\ModelingToolkit\a7NhS\src\structural_transformation\utils.jl:66
 [3] structural_simplify(sys::ODESystem; simplify::Bool)
   @ ModelingToolkit C:\Users\ruvil\.julia\packages\ModelingToolkit\a7NhS\src\systems\abstractsystem.jl:923
 [4] structural_simplify(sys::ODESystem)
   @ ModelingToolkit C:\Users\ruvil\.julia\packages\ModelingToolkit\a7NhS\src\systems\abstractsystem.jl:920
 [5] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{MethodOfLines.CenterAlignedGrid})
   @ MethodOfLines C:\Users\ruvil\.julia\packages\MethodOfLines\9MLPx\src\discretization\MOL_discretization.jl:151
 [6] top-level scope
   @ .\timing.jl:220

from methodoflines.jl.

xtalax avatar xtalax commented on May 27, 2024

This seems to be above board, this is a bug. I'll take a closer look at this soon.

from methodoflines.jl.

ruvilecamwasam avatar ruvilecamwasam commented on May 27, 2024

Thanks! Let me know if you want me to try anything else.

from methodoflines.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.