-
Notifications
You must be signed in to change notification settings - Fork 9
Changes on the linear-elasticity problem simulation using PSYDAC. #21
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes and finalizes the linear elasticity simulation workflow by correcting the original notebook’s markup and adding two new notebooks—one for the pure displacement formulation and one for a mixed displacement–pressure formulation—along with updating the table of contents.
- Refactored chapter2/linear-elasticity.ipynb for clearer PDE statement and heading.
- Introduced chapter2/linear-elasticity-v1.ipynb (pure displacement formulation).
- Introduced chapter2/linear-elasticity-v2.ipynb (mixed displacement–pressure formulation).
- Updated
_toc.yml
to include the new notebooks underlinear-elasticity
.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
chapter2/linear-elasticity.ipynb | Cleaned up markdown, corrected header and PDE description |
chapter2/linear-elasticity-v1.ipynb | Added notebook implementing compressible pure displacement method |
chapter2/linear-elasticity-v2.ipynb | Added notebook implementing mixed displacement–pressure method |
_toc.yml | Added sections entries for the new v1 and v2 notebooks under chapter2/linear-elasticity |
Comments suppressed due to low confidence (3)
chapter2/linear-elasticity.ipynb:20
- [nitpick] This single sentence is very long and embeds multiple definitions. Consider breaking it into two or more sentences or using bullet points so each variable and definition is clearly separated for readability.
"where $ \\sigma $ is the stress tensor, $ f $ represents the body force per unit volume, $ \\kappa $ and $ \\mu $ are Lamé's elasticity parameters for the material, $ I $ denotes the identity tensor, $ \\epsilon $ is the symmetric strain tensor and the displacement vector field is denoted by $ u $. $ \\epsilon := \\frac{1}{2}(\\nabla u + (\\nabla u)^T) $\n"
chapter2/linear-elasticity-v2.ipynb:383
- [nitpick] The variable
h
is reused here for grid resolution but was earlier used for discretization cell count (h = 8
). Consider using distinct names (e.g.,grid_res
) to avoid shadowing and improve readability.
"h = 100\n",
chapter2/linear-elasticity-v2.ipynb:272
- The
assemble
call for the pressure L2 norm only needs thep
field; thekappa
andmu
parameters are not used by this norm. Remove them to avoid confusion.
"l2_error_p = l2norm_ph.assemble(p=ph,kappa=kappa_val, mu=mu_val)\n",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a problem in both notebooks. After this cell
equation_h.set_solver('gmres', info=False, tol=1e-8)
uh = equation_h.solve(mu=mu_val, kappa=kappa_val)
we get
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
Cell In[4], line 2
1 equation_h.set_solver('gmres', info=False, tol=1e-8)
----> 2 uh = equation_h.solve(mu=mu_val, kappa=kappa_val)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/psydac/api/equation.py:198, in DiscreteEquation.solve(self, **kwargs)
196 def solve(self, **kwargs):
--> 198 self.assemble(**kwargs)
200 # Free arguments of current equation
201 free_args = set(self.lhs.free_args + self.rhs.free_args)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/psydac/api/equation.py:178, in DiscreteEquation.assemble(self, **kwargs)
176 # Matrix (left-hand side)
177 if assemble_lhs:
--> 178 A = self.lhs.assemble(reset=True, **kwargs)
179 if self.bc:
180 apply_essential_bc(A, *self.bc)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/psydac/api/fem.py:533, in DiscreteBilinearForm.assemble(self, reset, **kwargs)
530 if reset:
531 reset_arrays(*self.global_matrices)
--> 533 self._func(*args, *self._threads_args)
534 if self._matrix and self._update_ghost_regions:
535 self._matrix.exchange_assembly_data()
File ~/work/IGA-Python/IGA-Python/chapter2/__psydac__/dependencies_n2tehl4j.py:123, in assemble_matrix_n2tehl4j(global_test_basis_v_1, global_test_basis_v_2, global_test_basis_v_3, global_trial_basis_u_1, global_trial_basis_u_2, global_trial_basis_u_3, global_span_v_1, global_span_v_2, global_span_v_3, global_x1, global_x2, global_x3, test_v_p1, test_v_p2, test_v_p3, trial_u_p1, trial_u_p2, trial_u_p3, n_element_1, n_element_2, n_element_3, k1, k2, k3, pad1, pad2, pad3, g_mat_u_0_v_0_n2tehl4j, g_mat_u_1_v_0_n2tehl4j, g_mat_u_2_v_0_n2tehl4j, g_mat_u_0_v_1_n2tehl4j, g_mat_u_1_v_1_n2tehl4j, g_mat_u_2_v_1_n2tehl4j, g_mat_u_0_v_2_n2tehl4j, g_mat_u_1_v_2_n2tehl4j, g_mat_u_2_v_2_n2tehl4j, mu, kappa)
121 contribution_v_2_u_0_n2tehl4j += temp_v_0_u_0_2*u_0_x3*v_2_x1 + temp_v_0_u_0_6*u_0_x1
122 contribution_v_2_u_1_n2tehl4j += temp_v_0_u_0_2*u_1_x3*v_2_x2 + temp_v_0_u_0_6*u_1_x2
--> 123 contribution_v_2_u_2_n2tehl4j += temp_v_0_u_0_1*temp_v_0_u_0_7 + temp_v_0_u_0_2*temp_v_0_u_0_7 + temp_v_0_u_0_2*(temp_v_0_u_0_7 + u_2_x1*v_2_x1 + u_2_x2*v_2_x2)
127 l_mat_u_0_v_0_n2tehl4j[i_basis_1,i_basis_2,i_basis_3,2 - i_basis_1 + j_basis_1,2 - i_basis_2 + j_basis_2,2 - i_basis_3 + j_basis_3] = contribution_v_0_u_0_n2tehl4j
128 l_mat_u_1_v_0_n2tehl4j[i_basis_1,i_basis_2,i_basis_3,2 - i_basis_1 + j_basis_1,2 - i_basis_2 + j_basis_2,2 - i_basis_3 + j_basis_3] = contribution_v_0_u_1_n2tehl4j
KeyboardInterrupt:
chapter2/linear-elasticity.ipynb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that a markdown file could be used here, instead of an IPython Notebook with a single markdown cell. The file would be called linear-elasticity-intro.md
. See intro.md
for an example. Please let me know if that works.
Further, your section "The PDE problem" is currently repeated in both the v1 and v2 notebooks. I like that section, but I think that it should not be repeated. Instead I suggest to move it to this markdown file, and remove it from the two notebooks. You can use a link to refer to this section from the notebooks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue occuring after the cell
equation_h.set_solver('gmres', info=False, tol=1e-8)
uh = equation_h.solve(mu=mu_val, kappa=kappa_val)
was due to an excessively long runtime. This has been resolved by reducing the number of cells from 8 to 6.
Additionally, the section "The PDE problem" has been moved to a Markdown file and removed from both notebooks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right. Just a comment about how PR reviewing works...
It is good practice to let the person who started a conversation mark it as "resolved", especially if this person is reviewing the PR. It also helps if you tell the reviewer which commit has addressed their comment.
…own file and remove them from notebooks
…near-elasticity-fixes
Make sure that all inline math can be displayed correctly in the GitHub preview for markdown files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your math equations do not get formatted on the GitHub website. This makes it very hard for me to review the PR. I suggested some changes on the intro file which hopefully fix the problem.
Let the equations be formatted on GitHub...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still some formatting problems...
Fix some more formatting issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ArasuCandassamy Good job with this PR!
I have just made some changes to the intro markdown file in order to be able to properly visualize the inline math and the equations on GitHub (when I click on "view file"). Could you please make similar changes to the other two markdown files?
This pull request addresses the linear elasticity problem and its simulation using Psydac. The initial Jupyter notebook was not functional. This PR introduces two new notebooks, each implementing a different formulation.
The first notebook employs the pure displacement formulation to solve the PDE with one vector field (the displacement) as the unknown. This approach is similar to the previous notebook but has been corrected to ensure the Python script works properly.
The second notebook utilizes a mixed formulation known as the displacement-pressure formulation. This method involves one vector field (the displacement) and one scalar field (the pressure) as unknowns.