From f30d8e66b205e6cbc196f90f6cc2a688d1de55e1 Mon Sep 17 00:00:00 2001 From: dcluo Date: Thu, 16 Nov 2023 11:47:48 -0600 Subject: [PATCH 1/3] removed try catch from solver --- .../hyperelasticityControlPDE.py | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/examples/hyperelasticity/hyperelasticityControlPDE.py b/examples/hyperelasticity/hyperelasticityControlPDE.py index a709026..e0f4fb1 100644 --- a/examples/hyperelasticity/hyperelasticityControlPDE.py +++ b/examples/hyperelasticity/hyperelasticityControlPDE.py @@ -126,7 +126,7 @@ def __init__(self, Vh, varf_handler, bc, bc0, load_steps=[1.0], max_newton_iter= self.max_newton_iter_increment = max_newton_iter_increment self.backtrack = backtrack - default_solver_parameters = {'newton_solver': {'linear_solver' : 'lu', 'maximum_iterations': self.max_newton_iter}} + default_solver_parameters = {'newton_solver': {'linear_solver' : 'lu', 'maximum_iterations': self.max_newton_iter, 'error_on_nonconvergence' : False}} self.default_newton_solver = soupy.NonlinearVariationalSolver(default_solver_parameters) self.backtrack_newton_solver = soupy.NewtonBacktrackSolver() @@ -141,25 +141,24 @@ def solveFwd(self, state, x): Do load increments using backtracking newton if full solve fails """ self.n_calls["forward"] += 1 - try: - print("Process %d: Try immediate solve" %(MPI.COMM_WORLD.Get_rank())) - # Make functions - u = hp.vector2Function(x[soupy.STATE], self.Vh[soupy.STATE]) - m = hp.vector2Function(x[soupy.PARAMETER], self.Vh[soupy.PARAMETER]) - p = dl.TestFunction(self.Vh[soupy.ADJOINT]) - z = hp.vector2Function(x[soupy.CONTROL], self.Vh[soupy.CONTROL]) + print("Process %d: Try immediate solve" %(MPI.COMM_WORLD.Get_rank())) + # Make functions + u = hp.vector2Function(x[soupy.STATE], self.Vh[soupy.STATE]) + m = hp.vector2Function(x[soupy.PARAMETER], self.Vh[soupy.PARAMETER]) + p = dl.TestFunction(self.Vh[soupy.ADJOINT]) + z = hp.vector2Function(x[soupy.CONTROL], self.Vh[soupy.CONTROL]) - # Define full nonlinear problem - res_form = self.varf_handler(u, m, p, z) - jacobian_form = dl.derivative(res_form, u) + # Define full nonlinear problem + res_form = self.varf_handler(u, m, p, z) + jacobian_form = dl.derivative(res_form, u) - num_iters, converged = self.default_newton_solver.solve(res_form, u, self.bc, jacobian_form) - self.n_linear_solves += num_iters + num_iters, converged = self.default_newton_solver.solve(res_form, u, self.bc, jacobian_form) + self.n_linear_solves += num_iters - if converged: - print("Process %d: Immediate solve succeeded" %(MPI.COMM_WORLD.Get_rank())) + if converged: + print("Process %d: Immediate solve succeeded" %(MPI.COMM_WORLD.Get_rank())) - except: + else: print("Process %d: Increment load instead starting form zero with backtracking" %(MPI.COMM_WORLD.Get_rank())) # Start with zero initial guess From cfe87992ded9a7c22a558509514314ea3b0ad3e9 Mon Sep 17 00:00:00 2001 From: dcluo Date: Thu, 16 Nov 2023 11:49:20 -0600 Subject: [PATCH 2/3] updated installation instructions and paper fix --- INSTALL.md | 5 ++--- paper/paper.md | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index ede72c3..ba6fcaf 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -11,12 +11,11 @@ - PETSc dependencies: `parmetis`, `scotch`, `suitesparse`, `superlu_dist`, `ml`, `hypre` - (optional): `gmsh`, `mshr`, `jupyter` - ## Recommended installation using Anaconda ### Installation with pip 1. Create an environment with `FEniCS` and appropriate dependencies and activate environment ``` -conda create -n soupy -c conda-forge fenics==2019.1.0 matplotlib scipy jupyter +conda create -n soupy -c conda-forge python=3.11 fenics==2019.1.0 petsc4py==3.19 matplotlib scipy jupyter conda activate soupy ``` @@ -40,7 +39,7 @@ Examples in the `applications` directory can now be run. We refer to the full `F ### Installation for developers 1. Create an environment with `FEniCS` with appropriate dependencies ``` -conda create -n soupy -c conda-forge fenics==2019.1.0 matplotlib scipy jupyter +conda create -n soupy -c conda-forge python=3.11 fenics==2019.1.0 petsc4py==3.19 matplotlib scipy jupyter ``` 2. Clone the `hIPPYlib` [repository](https://github.com/hippylib/hippylib). diff --git a/paper/paper.md b/paper/paper.md index 0510b42..a89012a 100644 --- a/paper/paper.md +++ b/paper/paper.md @@ -16,7 +16,7 @@ authors: - name: Umberto Villa affiliation: 1 - name: Omar Ghattas - affiliation: "1 3" + affiliation: "1, 3" affiliations: - name: Oden Institute for Computational Engineering and Sciences, The University of Texas at Austin, USA index: 1 From cf314d4406932056f579b0be3133003fc0ba4528 Mon Sep 17 00:00:00 2001 From: dcluo Date: Thu, 16 Nov 2023 12:04:38 -0600 Subject: [PATCH 3/3] updated plotting of design --- examples/hyperelasticity/driver_hyperelasticity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/hyperelasticity/driver_hyperelasticity.py b/examples/hyperelasticity/driver_hyperelasticity.py index e2192a7..de3c896 100644 --- a/examples/hyperelasticity/driver_hyperelasticity.py +++ b/examples/hyperelasticity/driver_hyperelasticity.py @@ -154,7 +154,7 @@ plt.savefig("%s/u_soft.png" %(save_dir)) plt.figure() - ax = dl.plot(hp.vector2Function(x[soupy.CONTROL], Vh[soupy.CONTROL])) + ax = dl.plot(hp.vector2Function(x[soupy.CONTROL], Vh[soupy.CONTROL]), vmin=0.0, vmax=1.0, extend='max') plt.colorbar(ax) plt.title("Optimal design") plt.savefig("%s/z_opt.png" %(save_dir))