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

Error in Darcy solver #228

Open
Sruthy-s-24 opened this issue Aug 16, 2024 · 2 comments
Open

Error in Darcy solver #228

Sruthy-s-24 opened this issue Aug 16, 2024 · 2 comments

Comments

@Sruthy-s-24
Copy link

Describe the bug

I discussed this issue with Louis and reporting it as he requested.
While using the Darcy solve if this line: darcy_solver.constitutive_model.Parameters.s = sympy.Matrix([0, 0]).T, is not there, I am getting this error message.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[15], line 1
----> 1 darcy_solver.solve()

File [~/Documents/codes/uw3-local-installation/uw3_folder/src/underworld3/systems/solvers.py:337](http://localhost:8888/lab/tree/~/Documents/codes/uw3-local-installation/uw3_folder/src/underworld3/systems/solvers.py#line=336), in SNES_Darcy.solve(self, zero_init_guess, timestep, verbose, _force_setup)
    324 """
    325 Generates solution to constructed system.
    326 
   (...)
    333     value used to evaluate inertial contribution
    334 """
    336 if (not self.is_setup) or _force_setup:
--> 337     self._setup_pointwise_functions(verbose)
    338     self._setup_discretisation(verbose)
    339     self._setup_solver(verbose)

File src[/underworld3/cython/petsc_generic_snes_solvers.pyx:717](http://localhost:8888/underworld3/cython/petsc_generic_snes_solvers.pyx#line=716), in underworld3.cython.generic_solvers.SNES_Scalar._setup_pointwise_functions()

File [~/Documents/codes/uw3-local-installation/uw3_folder/src/underworld3/systems/solvers.py:277](http://localhost:8888/lab/tree/~/Documents/codes/uw3-local-installation/uw3_folder/src/underworld3/systems/solvers.py#line=276), in SNES_Darcy.darcy_problem_description(self)
    274 self._f0 = self.F0.value
    276 # f1 residual term (integration by parts [/](http://localhost:8888/) gradients)
--> 277 self._f1 = self.F1.value
    279 # Flow calculation
    280 self._v_projector.uw_function = -self.F1.value

File [~/Documents/codes/uw3-local-installation/uw3_folder/src/underworld3/systems/solvers.py:261](http://localhost:8888/lab/tree/~/Documents/codes/uw3-local-installation/uw3_folder/src/underworld3/systems/solvers.py#line=260), in SNES_Darcy.F1(self)
    256 @property
    257 def F1(self):
    259     F1_val = uw.function.expression(
    260         r"\mathbf{F}_1\left( \mathbf{u} \right)",
--> 261         sympy.simplify(self.darcy_flux),
    262         "Darcy pointwise flux term: F_1(u)",
    263     )
    265     # backward compatibility
    266     self._f1 = F1_val.value

File [~/Documents/codes/uw3-local-installation/uw3_folder/src/underworld3/systems/solvers.py:304](http://localhost:8888/lab/tree/~/Documents/codes/uw3-local-installation/uw3_folder/src/underworld3/systems/solvers.py#line=303), in SNES_Darcy.darcy_flux(self)
    302 @property
    303 def darcy_flux(self):
--> 304     flux = self.constitutive_model.flux.T
    305     return flux

File [~/Documents/codes/uw3-local-installation/uw3_folder/src/underworld3/constitutive_models.py:1584](http://localhost:8888/lab/tree/~/Documents/codes/uw3-local-installation/uw3_folder/src/underworld3/constitutive_models.py#line=1583), in DarcyFlowModel.flux(self)
   1577 @property
   1578 def flux(self):
   1579     """Computes the effect of the constitutive tensor on the gradients of the unknowns.
   1580     (always uses the `c` form of the tensor). In general cases, the history of the gradients
   1581     may be required to evaluate the flux.
   1582     """
-> 1584     ddu = self.grad_u - self.Parameters.s
   1586     return self._q(ddu)

File [~/Documents/codes/uw3-local-installation/uw3-env/lib/python3.11/site-packages/sympy-1.12-py3.11.egg/sympy/core/decorators.py:106](http://localhost:8888/lab/tree/~/Documents/codes/uw3-local-installation/uw3-env/lib/python3.11/site-packages/sympy-1.12-py3.11.egg/sympy/core/decorators.py#line=105), in call_highest_priority.<locals>.priority_decorator.<locals>.binary_op_wrapper(self, other)
    104         if f is not None:
    105             return f(self)
--> 106 return func(self, other)

File [~/Documents/codes/uw3-local-installation/uw3-env/lib/python3.11/site-packages/sympy-1.12-py3.11.egg/sympy/matrices/common.py:2937](http://localhost:8888/lab/tree/~/Documents/codes/uw3-local-installation/uw3-env/lib/python3.11/site-packages/sympy-1.12-py3.11.egg/sympy/matrices/common.py#line=2936), in MatrixArithmetic.__sub__(self, a)
   2935 @call_highest_priority('__rsub__')
   2936 def __sub__(self, a):
-> 2937     return self + (-a)

File [~/Documents/codes/uw3-local-installation/uw3-env/lib/python3.11/site-packages/sympy-1.12-py3.11.egg/sympy/core/decorators.py:106](http://localhost:8888/lab/tree/~/Documents/codes/uw3-local-installation/uw3-env/lib/python3.11/site-packages/sympy-1.12-py3.11.egg/sympy/core/decorators.py#line=105), in call_highest_priority.<locals>.priority_decorator.<locals>.binary_op_wrapper(self, other)
    104         if f is not None:
    105             return f(self)
--> 106 return func(self, other)

File [~/Documents/codes/uw3-local-installation/uw3-env/lib/python3.11/site-packages/sympy-1.12-py3.11.egg/sympy/matrices/common.py:2656](http://localhost:8888/lab/tree/~/Documents/codes/uw3-local-installation/uw3-env/lib/python3.11/site-packages/sympy-1.12-py3.11.egg/sympy/matrices/common.py#line=2655), in MatrixArithmetic.__add__(self, other)
   2653 if getattr(other, 'is_MatrixLike', False):
   2654     return MatrixArithmetic._eval_add(self, other)
-> 2656 raise TypeError('cannot add %s and %s' % (type(self), type(other)))

TypeError: cannot add <class 'sympy.matrices.dense.MutableDenseMatrix'> and <class 'sympy.core.mul.Mul'>
@lmoresi
Copy link
Member

lmoresi commented Aug 29, 2024

@julesghub - update on whether this is fixed for @Sruthy-s-24, please ?

@bknight1
Copy link
Member

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

3 participants