```python
from sympy.physics.units import *
from sympy import *

EA, l, F = var("EA, l, F")

# def k(phi):
#     """ computes element stiffness matrix """
#     # phi is angle between:
#     # 1. vector along global x axis
#     # 2. vector along 1-2-axis of truss
#     # phi is counted positively about z.
#     (c, s) = ( cos(phi), sin(phi) )
#     (cc, ss, sc) = ( c*c, s*s, s*c)
#     return Matrix(
#         [
#         [ cc,  sc, -cc, -sc],
#         [ sc,  ss, -sc, -ss],
#         [-cc, -sc,  cc,  sc],
#         [-sc, -ss,  sc,  ss],
#         ])
#
# (l1, l2, l3) = (l, l*sqrt(2), l)
# (p1, p2, p3) = (0 *pi/180, 135 *pi/180, 90 *pi/180)
# (k1, k2, k3) = (EA/l1*k(p1), EA/l2*k(p2), EA/l3*k(p3))
#
p = sqrt(2)/S(4)

K = EA/l*Matrix(
[
[1,0,-1,0 ,0,0],
[0,1,0,0 ,0,-1],
[-1,0,p+1,-p,-p,p],
[0,0,-p,p,p,-p],
[0,0,-p,p,p,-p],
[0,-1,p,-p,-p,p+1]
]
)

pprint("\nK / (EA/l):")
pprint(K/ (EA/l))
u1x,u1y,u2x,u2y,u3x,u3y = var("u1x,u1y,u2x,u2y,u3x,u3y")
F1x,F1y,F2x,F2y,F3x,F3y = var("F1x,F1y,F2x,F2y,F3x,F3y")
u = Matrix([u1x,u1y,u2x,u2y,u3x,u3y])
f = Matrix([F1x,F1y,F2x,F2y,F3x,F3y])

unknowns = [u1x,u1y,u2x,u2y,u3x,u3y, F1x,F1y,F2x,F2y,F3x,F3y]

# boundary conditions:
# --- a ---
sub_list_u_a=[
(u1x, 0),
(u1y, 0),
(u3x, 0),
]
sub_list_f_a=[
(F2x, 0),
(F2y, -F),
(F3y, 0),
]

# --- b ---
sub_list_u_b=[
(u1x, 0),
(u3x, 0),
(u3y, 0),
]
sub_list_f_b = sub_list_f_a


pprint("\na:")
ua = u.subs(sub_list_u_a)
fa = f.subs(sub_list_f_a)
eq = Eq(K*ua , fa)
sol = solve(eq, unknowns)
for s in sol:
    pprint("\n")
    pprint(s)
    pprint(sol[s])

pprint("\nb:")
ub = u.subs(sub_list_u_b)
fb = f.subs(sub_list_f_b)
eq = Eq(K*ub , fb)
sol = solve(eq, unknowns)
for s in sol:
    pprint("\n")
    pprint(s)
    pprint(sol[s])

# K / (EA/l):
# ⎡1   0     -1     0     0      0   ⎤
# ⎢                                  ⎥
# ⎢0   1     0      0     0      -1  ⎥
# ⎢                                  ⎥
# ⎢        √2      -√2   -√2     √2  ⎥
# ⎢-1  0   ── + 1  ────  ────    ──  ⎥
# ⎢        4        4     4      4   ⎥
# ⎢                                  ⎥
# ⎢         -√2     √2    √2    -√2  ⎥
# ⎢0   0    ────    ──    ──    ──── ⎥
# ⎢          4      4     4      4   ⎥
# ⎢                                  ⎥
# ⎢         -√2     √2    √2    -√2  ⎥
# ⎢0   0    ────    ──    ──    ──── ⎥
# ⎢          4      4     4      4   ⎥
# ⎢                                  ⎥
# ⎢          √2    -√2   -√2   √2    ⎥
# ⎢0   -1    ──    ────  ────  ── + 1⎥
# ⎣          4      4     4    4     ⎦
#
# a:
#
# F1y
# F
#
# F3x
# -F
#
# F1x
# F
#
# u2y
# -2⋅F⋅l⋅(1 + √2)
# ────────────────
#        EA
#
# u3y
# -F⋅l
# ─────
#   EA
#
# u2x
# -F⋅l
# ─────
#   EA
#
# b:
#
# F1y
# F
#
# F3x
# -F
#
# F1x
# F
#
# u2y
# -F⋅l⋅(1 + 2⋅√2)
# ────────────────
#        EA
#
# u1y
# F⋅l
# ───
#  EA
#
# u2x
# -F⋅l
# ─────
#   EA

```

abc6f379e814f5ba6d67997480951b046d1b999a
ipynb
Jupyter Notebook
ipynb/EMS_02A/Selbst/5.1.ipynb
kassbohm/wb-snippets
f1ac5194e9f60a9260d096ba5ed1ce40b844a3fe
MIT
ipynb/EMS_02A/Selbst/5.1.ipynb
kassbohm/wb-snippets
f1ac5194e9f60a9260d096ba5ed1ce40b844a3fe
MIT
ipynb/EMS_02A/Selbst/5.1.ipynb
kassbohm/wb-snippets
f1ac5194e9f60a9260d096ba5ed1ce40b844a3fe
MIT
Qwen/Qwen-72B
1. YES
2. YES