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

Wrap the ax-title ConstitutiveMaterial.plot() #743

Merged
merged 4 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ jobs:
pip install tox
tox -- --cov felupe --cov-report xml --cov-report term
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
if: ${{ matrix.python-version == '3.12' }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format

### Added
- Add `math.solve_2d(A, b, solver=np.linalg.solve, **kwargs)` to be used in `newtonrhapson(solve=solve_2d, ...)` for two-dimensional unknowns. This is useful for local Newton-iterations related to viscoelastic evolution equations inside constitutive material formulations.
- Add x- and y-offsets in `Job.plot(xoffset=0.0, yoffset=0.0)`.

### Changed
- Wrap the ax-title with the parameters of the material model in `ConstitutiveMaterial.plot()`.

### Fixed
- Sort array of principal values in descending order before plotting in `Scene.plot("Principal Values of ...")`. This ensures that the labels are matching user-defined arrays of principal values.
Expand Down
9 changes: 4 additions & 5 deletions src/felupe/constitution/_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,11 @@ def plot(self, ax=None, show_title=True, show_kwargs=True, **kwargs):

if show_kwargs:
if hasattr(self.umat, "kwargs"):
ax.set_title(
", ".join(
[f"{key}={value}" for key, value in self.umat.kwargs.items()]
),
fontdict=dict(fontsize="small"),
parameters = ", ".join(
[f"{key}={value}" for key, value in self.umat.kwargs.items()]
)
ax.set_title(parameters, fontdict=dict(fontsize="small"), wrap=True)

return ax


Expand Down
10 changes: 9 additions & 1 deletion src/felupe/mechanics/_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def plot(
ylabel=None,
xscale=1.0,
yscale=1.0,
xoffset=0.0,
yoffset=0.0,
gradient=False,
swapaxes=False,
ax=None,
Expand Down Expand Up @@ -154,6 +156,10 @@ def plot(
A scaling factor for the displacement data (default is 1.0).
yscale : float, optional
A scaling factor the reaction force data (default is 1.0).
xoffset : float, optional
An offset for the displacement data (default is 0.0).
yoffset : float, optional
An offset for the reaction force data (default is 0.0).
gradient : bool, optional
A flag to plot the gradient of the y-data. Uses
``numpy.gradient(edge_order=2)``. The gradient data is set to ``np.nan`` for
Expand Down Expand Up @@ -213,7 +219,9 @@ def plot(
xaxis, yaxis = yaxis, xaxis
xscale, yscale = yscale, xscale

ax.plot(x[:, xaxis] * xscale, y[:, yaxis] * yscale, **kwargs)
ax.plot(
xoffset + x[:, xaxis] * xscale, yoffset + y[:, yaxis] * yscale, **kwargs
)

if xlabel is not None:
ax.set_xlabel(xlabel)
Expand Down
Loading