-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 Merge pull request #332 from bldrkamal/add-stiffness-matrix-feature
Add stiffness matrix feature to SystemElements class
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import unittest | ||
|
||
from anastruct.fem import system as se | ||
|
||
|
||
class TestSystemElements(unittest.TestCase): | ||
def test_get_stiffness_matrix(self): | ||
# Create a system | ||
system = se.SystemElements() | ||
|
||
# Add a simple beam element (make sure it has a stiffness matrix) | ||
system.add_element( | ||
location=[[0, 0], [5, 0]] | ||
) # Adjust as necessary based on your implementation | ||
|
||
# Here, we assume that the added element has a stiffness matrix defined | ||
# Check if stiffness matrix is correctly returned for element 1 | ||
stiffness_matrix = system.get_stiffness_matrix(1) | ||
|
||
# Assert that a stiffness matrix was returned | ||
self.assertIsNotNone(stiffness_matrix) | ||
print("Stiffness matrix returned successfully.") | ||
|
||
def test_invalid_element(self): | ||
# Create a system without adding any elements | ||
system = se.SystemElements() | ||
|
||
# Try to get the stiffness matrix of an element that doesn't exist | ||
stiffness_matrix = system.get_stiffness_matrix(999) # Nonexistent ID | ||
self.assertIsNone(stiffness_matrix) | ||
print("Handled invalid element ID correctly.") | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |