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

Add math.solve_2d(A, b) #742

Merged
merged 2 commits into from
Apr 12, 2024
Merged

Add math.solve_2d(A, b) #742

merged 2 commits into from
Apr 12, 2024

Conversation

adtzlr
Copy link
Owner

@adtzlr adtzlr commented Apr 12, 2024

for two-dimensional problems.

See discussion #741.

Example

import numpy as np
import tensortrax as tr
from tensortrax.math import trace
from tensortrax.math.linalg import inv
from tensortrax.math.special import dev, from_triu_1d, triu_1d

import felupe as fem

mesh = fem.Rectangle(n=3)
region = fem.RegionQuad(mesh)
field = fem.FieldContainer([fem.FieldPlaneStrain(region, dim=2)])
boundaries, loadcase = fem.dof.uniaxial(field, clamped=True)

@fem.constitution.isochoric_volumetric_split
def finite_strain_viscoelastic_newton(C, Cin, mu, eta, dtime):
    "Finite Strain Viscoelastic material formulation."

    def evolution(Ci, Cin, C, mu, eta, dtime):
        "Viscoelastic evolution equation."
        return mu / eta * dev(C @ inv(Ci)) @ Ci - (Ci - Cin) / dtime

    # update of state variables by evolution equation
    Cin = from_triu_1d(Cin, like=C)
    Ci = fem.newtonrhapson(
        x0=Cin,
        fun=tr.function(evolution, ntrax=C.ntrax),
        jac=tr.jacobian(evolution, ntrax=C.ntrax),
        solve=fem.math.solve_2d,
        args=(Cin, C.x, mu, eta, dtime),
        verbose=0,
        tol=1e-2,
    ).x

    # first invariant of elastic part of right Cauchy-Green deformation tensor
    I1 = trace(C @ inv(Ci))

    # strain energy function and state variable
    return mu / 2 * (I1 - 3), triu_1d(Ci)

umat = fem.Hyperelastic(
    finite_strain_viscoelastic_newton, mu=1.0, eta=1.0, dtime=0.1, nstatevars=6
)
solid = fem.SolidBodyNearlyIncompressible(umat, field, bulk=5000)
solid.results.statevars[[0, 3, 5]] += 1

move = fem.math.linsteps([0, 0.3], num=3)
step = fem.Step(
    items=[solid], ramp={boundaries["move"]: move}, boundaries=boundaries
)
job = fem.CharacteristicCurve(steps=[step], boundary=boundaries["move"]).evaluate()

for two-dimensional problems
@adtzlr adtzlr added the enhancement New feature or request label Apr 12, 2024
@adtzlr adtzlr self-assigned this Apr 12, 2024
Copy link

codecov bot commented Apr 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.48%. Comparing base (c98f213) to head (b4decc8).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #742   +/-   ##
=======================================
  Coverage   97.48%   97.48%           
=======================================
  Files          95       96    +1     
  Lines        5163     5173   +10     
=======================================
+ Hits         5033     5043   +10     
  Misses        130      130           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@adtzlr adtzlr merged commit bd2d6fc into main Apr 12, 2024
9 checks passed
@adtzlr adtzlr deleted the add-math-solve2d branch April 12, 2024 08:03
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 this pull request may close these issues.

1 participant