Skip to content
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

"solvePDE" function broken #9

Open
SA8416 opened this issue Sep 2, 2022 · 4 comments
Open

"solvePDE" function broken #9

SA8416 opened this issue Sep 2, 2022 · 4 comments

Comments

@SA8416
Copy link

SA8416 commented Sep 2, 2022

It seems the "solvePDE" set of functions cause my terminal to crash when attempting to solve a PDE. The error I receive is:

The terminal process "D:\Programs\Julia-1.8.0\bin\julia.exe '--color=yes', '--startup-file=no', '--history-file=no', '--project=d:\Github\CRUD.jl', 'c:\Users\sa8416.vscode\extensions\julialang.language-julia-1.7.6\scripts\debugger\run_debugger.jl', '\.\pipe\vsc-jl-dbg-9aa81c39-1399-435d-9fb6-f07804f28e12', '\.\pipe\vsc-jl-cr-e272cddf-e589-4ef3-9716-a35a7693db3e'" terminated with exit code: 1.

Edit: It seems the issue lies in the matrix of coefficients 'M' being a sparse matrix, temporary fix is to convert it to a dense matrix:

x=(collect(M))\RHS

@simulkade
Copy link
Owner

Hi @SA8416 , let me investigate it and come back to you. Converting M to a dense matrix is not a memory-efficient fix. I will come back with a better solution.

@simulkade
Copy link
Owner

I cannot reproduce this error with the master branch of JFVM and julia 1.8

using JFVM #, JFVMvis
function diff()
    Nx = 10
    Lx = 1.0
    m = createMesh1D(Nx, Lx)
    BC = createBC(m)
    BC.left.a[:].=BC.right.a[:].=0.0
    BC.left.b[:].=BC.right.b[:].=1.0
    BC.left.c[:].=1.0
    BC.right.c[:].=0.0
    c_init = 0.0 # initial value of the variable
    c_old = createCellVariable(m, 0.0, BC)
    D_val = 1.0 # value of the diffusion coefficient
    D_cell = createCellVariable(m, D_val) # assigned to cells
    # Harmonic average
    D_face = harmonicMean(D_cell)
    N_steps = 20 # number of time steps
    dt= sqrt(Lx^2/D_val)/N_steps # time step
    M_diff = diffusionTerm(D_face) # matrix of coefficient for diffusion term
    (M_bc, RHS_bc)=boundaryConditionTerm(BC) # matrix of coefficient and RHS for the BC
    for i =1:5
        (M_t, RHS_t)=transientTerm(c_old, dt, 1.0)
        M=M_t-M_diff+M_bc # add all the [sparse] matrices of coefficient
        RHS=RHS_bc+RHS_t # add all the RHS's together
        c_old = solveLinearPDE(m, M, RHS) # solve the PDE
    end
    return c_old
    #visualizeCells(c_old)
end

diff()

@SA8416
Copy link
Author

SA8416 commented Sep 5, 2022

Strange, even after re-installing julia the error seems to persist- I have found a more memory-efficient workaround by using the LinearSolve.jl package instead of the julia "" solver.

@simulkade
Copy link
Owner

a more memory-efficient workaround by using the LinearSolve.jl package

Very good idea. Let me know if it is faster too. I saw a talk about this package and it is nice to use it instead of the default Julia backslash solver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants