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

FENICSX error thrown but FESTIM solving #18

Closed
kaelyndunnell opened this issue Oct 16, 2024 · 5 comments · Fixed by #25
Closed

FENICSX error thrown but FESTIM solving #18

kaelyndunnell opened this issue Oct 16, 2024 · 5 comments · Fixed by #25

Comments

@kaelyndunnell
Copy link
Owner

From PR #12: simulation solves, plots, and then spits out FENICSx error in the terminal. merged into main

  You need to add matplotlib as a conda dependency. This is what is making the Ci fail. Here, matplotlib is installed alongside HTM as a pip package. This conflicts with dolfinx which is installed with Conda.

(hello @shimwell)

Originally posted by @RemDelaporteMathurin in #12 (comment)

@RemDelaporteMathurin
Copy link
Collaborator

RemDelaporteMathurin commented Oct 17, 2024

I've produced a MWE for this bug.

import festim as F

my_model = F.HydrogenTransportProblem()

my_model.mesh = F.Mesh1D([0, 0.1, 0.2, 0.3, 0.5, 1])

tungsten = F.Material(D_0=1, E_D=0)

w_subdomain = F.VolumeSubdomain1D(id=1, borders=[0, 1], material=tungsten)

my_model.subdomains = [w_subdomain]

my_model.species = [F.Species("H")]

my_model.temperature = 500

my_model.boundary_conditions = []


my_model.settings = F.Settings(atol=1e-10, rtol=1e-10, final_time=1)

my_model.settings.stepsize = F.Stepsize(initial_value=0.1)

my_model.initialise()
my_model.run()


class RandomClass:
    def __init__(self):
        pass

This produces

Solving HydrogenTransportProblem: 100%|█████████████████████████████████████████████████| 1.00/1.00 [00:00<00:00, 663it/s][0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run 
[0]PETSC ERROR: to get more information on the crash.
[0]PETSC ERROR: Run with -malloc_debug to check if memory corruption is causing the crash.
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
  Proc: [[13633,0],0]
  Errorcode: 59

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------

Environment file:

name: hisp-env
channels:
  - conda-forge
  - defaults
dependencies:
  - fenics-dolfinx=0.8.0
  - matplotlib
  - scipy
  - pip
  - tqdm
  - pip:
      - git+https://github.com/remdelaportemathurin/FESTIM@ad3b10b1a0c736ea3cd1e77835ef70de82208a10
    # - h_transport_materials~=0.16

(both with dolfinx 0.8 and 0.9)

  1. Not defining RandomClass at the end fixes the issue. 😕
  2. adding my_model.show_progress_bar = False fixes the issue
    This removes the tqdm progress bar

@RemDelaporteMathurin
Copy link
Collaborator

Note: the bug also occurs with festim@fenicsx

@RemDelaporteMathurin
Copy link
Collaborator

If we don't define the RandomClass in the same file but import it from another file, the error doesn't occur:

import festim as F

my_model = F.HydrogenTransportProblem()

my_model.mesh = F.Mesh1D([0, 0.1, 0.2, 0.3, 0.5, 1])

tungsten = F.Material(D_0=1, E_D=0)

w_subdomain = F.VolumeSubdomain1D(id=1, borders=[0, 1], material=tungsten)

my_model.subdomains = [w_subdomain]

my_model.species = [F.Species("H")]

my_model.temperature = 500

my_model.boundary_conditions = []


my_model.settings = F.Settings(atol=1e-10, rtol=1e-10, final_time=1)

my_model.settings.stepsize = F.Stepsize(initial_value=0.1)

my_model.initialise()
my_model.run()

from random_class import RandomClass

@RemDelaporteMathurin
Copy link
Collaborator

@kaelyndunnell adding

my_model.progress_bar.close()

After my_model.run() fixes the issue.

I'll open an issue on the FESTIM repo and push a fix to do this inside my_model.run

@RemDelaporteMathurin
Copy link
Collaborator

This PR should fix it after it's merged festim-dev/FESTIM#894

@kaelyndunnell kaelyndunnell linked a pull request Oct 30, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants