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

Versions bump #127

Merged
merged 32 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2340ede
Dynamic membrane example
piotrbartman Apr 12, 2024
3cf739a
!Dynamic membrane with dumped contact
piotrbartman Apr 15, 2024
1e0c29f
rename
piotrbartman Apr 15, 2024
7bbc3ae
!BOSK example 2
piotrbartman Apr 20, 2024
8a87ea0
BOSK: working
piotrbartman Apr 17, 2024
c04a44b
BOSK: working schur
piotrbartman Jun 19, 2024
8b53177
BOSK: add products
piotrbartman Jun 24, 2024
a34a92a
!BOSK: parameters
piotrbartman Jun 25, 2024
6b8fafc
!BOSK: postprocessing
piotrbartman Jul 13, 2024
1da43ca
enable continuing of previous simulation
piotrbartman Jul 16, 2024
0ec16f4
better test converge
piotrbartman Jul 16, 2024
8ceae3e
refactor contact laws
piotrbartman Jul 17, 2024
5fa366c
fix static 3d and add test
piotrbartman Jul 19, 2024
99da0dd
contact laws refactor
piotrbartman Jul 19, 2024
109791f
problem solver refactor
piotrbartman Jul 22, 2024
d0aa166
cleanup
piotrbartman Jul 22, 2024
14b24e1
update BOST to publish prepared version
piotrbartman Jul 23, 2024
21fd5f4
cleanup^
piotrbartman Jul 23, 2024
d9c00b9
use archive version of meshzoo
piotrbartman Jul 23, 2024
ff5b485
drop python 3.8 support
piotrbartman Jul 23, 2024
6ba2bf3
macos workaround
piotrbartman Jul 23, 2024
a4b10e4
macos workaround
piotrbartman Jul 23, 2024
711965f
macos workaround
piotrbartman Jul 23, 2024
19a58a2
alder version of meshzoo
piotrbartman Jul 25, 2024
a203082
black
piotrbartman Jul 25, 2024
c676e39
fix old meshzoo
piotrbartman Jul 25, 2024
b814c72
cleanup BOSK
piotrbartman Jul 25, 2024
a29adde
black
piotrbartman Jul 25, 2024
0e4dc19
fix hanging ci
piotrbartman Jul 25, 2024
352f7e4
bump versions of deps
piotrbartman Jul 25, 2024
ad77a2f
keep olders scipy
piotrbartman Jul 25, 2024
403c664
keep older networkx
piotrbartman Jul 25, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/conmech_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
run_tests:
strategy:
matrix:
platform: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
platform: [ ubuntu-latest, macos-13, windows-latest ]
python-version: [ "3.9", "3.10", "3.11"]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
Expand Down
18 changes: 18 additions & 0 deletions conmech/dynamics/contact/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# CONMECH @ Jagiellonian University in Kraków
#
# Copyright (C) 2024 Piotr Bartman-Szwarc <piotr.bartman@uj.edu.pl>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
46 changes: 46 additions & 0 deletions conmech/dynamics/contact/constant_constact_law.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# CONMECH @ Jagiellonian University in Kraków
#
# Copyright (C) 2024 Piotr Bartman-Szwarc <piotr.bartman@uj.edu.pl>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
from typing import Type

from conmech.dynamics.contact.contact_law import (
ContactLaw,
DirectContactLaw,
PotentialOfContactLaw,
)


def make_const_contact_law(resistance: float) -> Type[ContactLaw]:
class PSlopeContactLaw(DirectContactLaw, PotentialOfContactLaw):
@staticmethod
def potential_normal_direction(
var_nu: float, static_displacement_nu: float, dt: float
) -> float:
if var_nu <= 0:
return 0 * static_displacement_nu
return (resistance * var_nu) * static_displacement_nu

@staticmethod
def subderivative_normal_direction(
var_nu: float, static_displacement_nu: float, dt: float
) -> float:
if var_nu <= 0:
return 0
return resistance

return PSlopeContactLaw
126 changes: 126 additions & 0 deletions conmech/dynamics/contact/contact_law.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# CONMECH @ Jagiellonian University in Kraków
#
# Copyright (C) 2024 Piotr Bartman-Szwarc <piotr.bartman@uj.edu.pl>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
from abc import ABC, abstractmethod


class ContactLaw:
# pylint: disable=unused-argument)
"""
"Abstract" class for all contact conditions.
"""

@staticmethod
def normal_bound(var_nu: float, static_displacement_nu: float, dt: float) -> float:
"""
:param var_nu: variable normal vector length
:param static_displacement_nu: normal vector length of displacement from
the previous step. For time independent problems this likely be 0.
:param dt: time step
:returns foundation response
"""
return 1.0

@staticmethod
def tangential_bound(var_nu: float, static_displacement_nu: float, dt: float) -> float:
"""
Friction bound

:param var_nu: variable normal vector length
:param static_displacement_nu: normal vector length of displacement from
the previous step. For time independent problems this likely be 0.
:param dt: time step
:returns foundation response
"""
return 1.0


class DirectContactLaw(ContactLaw, ABC):
# pylint: disable=unused-argument)
"""
Abstract class for contact conditions given in a direct form.
Since usually contact law is a multifunction it can be treated as
a subderivative of *some* function - potential. Hence, from point of view
of conmech package we call subderivative form.
"""

@staticmethod
@abstractmethod
def subderivative_normal_direction(
var_nu: float, static_displacement_nu: float, dt: float
) -> float:
"""
:param var_nu: variable normal vector length
:param static_displacement_nu: normal vector length of displacement from
the previous step. For time independent problems this likely be 0.
:param dt: time step
:returns foundation response
"""
raise NotImplementedError()

@staticmethod
def subderivative_tangential_direction(
var_tau: float, static_displacement_tau: float, dt: float
) -> float:
"""
:param var_tau: variable normal vector length
:param static_displacement_tau: normal vector length of displacement from
the previous step. For time independent problems this likely be 0.
:param dt: time step
:returns potential of foundation friction response
"""
return 0.0


class PotentialOfContactLaw(ContactLaw, ABC):
# pylint: disable=unused-argument)
"""
Abstract class for contact conditions given in a potential form.
Since usually contact law is a multifunction it can be treated as
a subderivative of *some* function - potential. To solve contact problem
numerically with optimization approach we need only the potential of
contact condition. Hence, from point of view of conmech package,
we call potential form.
"""

@staticmethod
@abstractmethod
def potential_normal_direction(
var_nu: float, static_displacement_nu: float, dt: float
) -> float:
"""
:param var_nu: variable normal vector length
:param static_displacement_nu: normal vector length of displacement from
the previous step. For time independent problems this likely be 0.
:param dt: time step
:returns potential of foundation response
"""
raise NotImplementedError()

@staticmethod
def potential_tangential_direction(
var_tau: float, static_displacement_tau: float, dt: float
) -> float:
"""
:param var_tau: variable normal vector length
:param static_displacement_tau: normal vector length of displacement from
the previous step. For time independent problems this likely be 0.
:param dt: time step
:returns potential of foundation friction response
"""
return 0
55 changes: 55 additions & 0 deletions conmech/dynamics/contact/damped_normal_compliance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# CONMECH @ Jagiellonian University in Kraków
#
# Copyright (C) 2024 Piotr Bartman-Szwarc <piotr.bartman@uj.edu.pl>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
from conmech.dynamics.contact.contact_law import PotentialOfContactLaw
from conmech.dynamics.contact.interior_contact_law import InteriorContactLaw


def make_damped_norm_compl(obstacle_level: float, kappa: float, beta: float, interior=False):
superclass = InteriorContactLaw if interior else PotentialOfContactLaw

class DampedNormalCompliance(superclass):
@property
def kappa(self):
return kappa

@property
def beta(self):
return beta

@property
def obstacle_level(self):
return obstacle_level

@staticmethod
def normal_bound(var_nu: float, static_displacement_nu: float, dt: float) -> float:
"""
Since multiply by var_nu
"""
return 0.5 * var_nu

@staticmethod
def potential_normal_direction(
var_nu: float, static_displacement_nu: float, dt: float
) -> float:
displacement = static_displacement_nu + var_nu * dt
if displacement < obstacle_level:
return 0
return kappa * (displacement - obstacle_level) + beta * var_nu

return DampedNormalCompliance
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CONMECH @ Jagiellonian University in Kraków
#
# Copyright (C) 2023 Piotr Bartman <piotr.bartman@uj.edu.pl>
# Copyright (C) 2024 Piotr Bartman-Szwarc <piotr.bartman@uj.edu.pl>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -16,16 +16,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
import numpy as np
from conmech.dynamics.contact.contact_law import PotentialOfContactLaw


def interpolate_nodes(scaled_nodes, corner_vectors):
input_dim = scaled_nodes.shape[-1]
output_dim = corner_vectors.shape[-1]
values = np.zeros((scaled_nodes.shape[0], output_dim))
for i in range(input_dim):
coordinate_i = scaled_nodes[..., [i]]
values += (
coordinate_i * corner_vectors[i] + (1 - coordinate_i) * corner_vectors[i + input_dim]
) / input_dim
return values
class InteriorContactLaw(PotentialOfContactLaw):
pass
32 changes: 32 additions & 0 deletions conmech/dynamics/contact/relu_slope_contact_law.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Example contact law
"""

from typing import Type

from conmech.dynamics.contact.contact_law import (
ContactLaw,
DirectContactLaw,
PotentialOfContactLaw,
)


def make_slope_contact_law(slope: float) -> Type[ContactLaw]:
class ReLuContactLaw(DirectContactLaw, PotentialOfContactLaw):
@staticmethod
def potential_normal_direction(
var_nu: float, static_displacement_nu: float, dt: float
) -> float:
if var_nu <= 0:
return 0.0
return 0.5 * slope * var_nu**2

@staticmethod
def subderivative_normal_direction(
var_nu: float, static_displacement_nu: float, dt: float
) -> float:
if var_nu <= 0:
return 0.0
return slope * var_nu * static_displacement_nu

return ReLuContactLaw
5 changes: 2 additions & 3 deletions conmech/dynamics/dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ def __init__(
self.body.dynamics = self

self.force = BodyForces(body)
self.temperature = BodyForces(
body,
)
self.temperature = BodyForces(body)

self.factory = get_factory(body.mesh.dimension)
self.element_initial_volume: np.ndarray
self.volume_at_nodes: np.ndarray
Expand Down
8 changes: 7 additions & 1 deletion conmech/dynamics/factory/_abstract_dynamics_factory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Tuple
import numpy as np

from conmech.struct.stiffness_matrix import SM1


class AbstractDynamicsFactory:
@property
Expand Down Expand Up @@ -34,5 +36,9 @@ def get_permittivity_tensor(self, W: np.ndarray, coeff: np.ndarray) -> np.ndarra
raise NotImplementedError()

@staticmethod
def calculate_poisson_matrix(W: np.ndarray) -> np.ndarray:
def calculate_poisson_matrix(W: np.ndarray, propagation: float) -> SM1:
return SM1(propagation**2 * np.sum(W.diagonal(), axis=2))

@staticmethod
def calculate_wave_matrix(W: np.ndarray) -> np.ndarray:
return np.sum(W.diagonal(), axis=2)
Loading
Loading