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

Linear solver for c = theta * S #570

Closed
RemDelaporteMathurin opened this issue Aug 24, 2023 · 1 comment · Fixed by #579
Closed

Linear solver for c = theta * S #570

RemDelaporteMathurin opened this issue Aug 24, 2023 · 1 comment · Fixed by #579
Labels
enhancement New feature or request
Milestone

Comments

@RemDelaporteMathurin
Copy link
Collaborator

https://github.com/RemDelaporteMathurin/FESTIM/blob/5e710594217d05156e9fd947897b86eb0f9d0b76/festim/concentration/theta.py#L84-L101

The problem here should be a LinearProblem instead of nonlinear.

The following changes should be done

    def post_processing_solution_to_concentration(self):
        """Converts the post_processing_solution from theta to mobile
        concentration.
        c = theta * S.
        The attribute post_processing_solution is fenics.Product (if self.S is
        festim.ArheniusCoeff)
        """
        problem = f.LinearVariationalProblem(f.lhs(self.form_post_processing), f.rhs(self.form_post_processing), self.post_processing_solution, [])
        solver = f.LinearVariationalSolver(problem)
        solver.solve()

    def create_form_post_processing(self, V, materials, dx):
        F = 0
        v = f.TestFunction(V)
        self.post_processing_solution = f.TrialFunction(V)
        F += -self.post_processing_solution * v * dx
        for mat in materials.materials:
            if mat.solubility_law == "sievert":
                F += self.solution * self.S * v * dx(mat.id)
            elif mat.solubility_law == "henry":
                F += self.solution**2 * self.S * v * dx(mat.id)
        self.form_post_processing = F
        self.post_processing_solution = f.Function(V)
@RemDelaporteMathurin RemDelaporteMathurin added the enhancement New feature or request label Aug 24, 2023
@RemDelaporteMathurin
Copy link
Collaborator Author

This is needed as sometimes the nonlinear solver for theta doesn't converge...

@RemDelaporteMathurin RemDelaporteMathurin added this to the v1.0 milestone Sep 5, 2023
@RemDelaporteMathurin RemDelaporteMathurin linked a pull request Oct 4, 2023 that will close this issue
10 tasks
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 a pull request may close this issue.

1 participant