0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

(断面二次モーメント大小比較)「一級建築士【構造力学】断面二次モーメント・断面係数」様を参考に、sympyでやってみたい。

Last updated at Posted at 2025-01-25

・途中です。
パイソニスタの方へ
・私は、tupleの掛け算がわかっていません。アドバイスをいただけると幸いです。
・以下は、sympyのsecond_moment_of_area(point=None) です。

オリジナル

Youtube でめまる構造 様  
フル 一級建築士【構造力学】断面二次モーメント・断面係数(0:00〜15:05)
https://youtu.be/47HHxwGCi_A?t=322

sympyのweb上での実行方法

SymPy Live Shellで。
FreeCADのマクロは、以下で実行できません。本ページで使っていません。
https://qiita.com/mrrclb48z/items/00dd08b0317069be9342#web%E4%B8%8A%E3%81%AE%E5%AE%9F%E8%A1%8C%E6%96%B9%E6%B3%95sympy-live-shell%E3%81%A7

sympyで(オリジナル 様の方法を参考に)

勉強中
・未 ver 0.1 細かく分割。???素因数分解
・未 ver 0.2 細かく分割。

sympyで(いつもの方法で)

・ver 0.3 sympyの一筆書き ??? 私は、tupleの掛け算がわかっていません。
・second_moment_of_area(point=None)
https://docs.sympy.org/latest/modules/geometry/polygons.html#sympy.geometry.polygon.Polygon.second_moment_of_area
・変数aを使っていません。

# ver 0.3 sympyの一筆書き ??? 私は、tupleの掛け算がわかっていません。
from sympy import *
var('a',nonnegative=True)
def compare_variables(**kwargs):
    # 変数名と値をペアにしてリスト化
    variables = list(kwargs.items())

    # 値を基準に降順でソート (同じ値でも順番を保つ)
    sorted_vars = sorted(variables, key=lambda x: x[1], reverse=True)

    # 結果を組み立て (等しい値は "=" で表現)
    result = []
    values = []
    for i in range(len(sorted_vars)):
        if i > 0 and sorted_vars[i][1] == sorted_vars[i-1][1]:
            result[-1] += f" = {sorted_vars[i][0]}"
            values[-1] += f" = {sorted_vars[i][1]}"
        else:
            result.append(sorted_vars[i][0])
            values.append(f"{sorted_vars[i][1]}")
    return " > ".join(result)," > ".join(values)
A_a=Polygon(( 0,-4),                                           # 1+(4+1)+1+(4+1)=12点
            ( 3,-4),( 3, 4),(-3, 4),(-3,-4),(0,-4), 
            ( 0,-2),
            (-2,-2),(-2, 2),( 2, 2),( 2,-2),(0,-2))
B_a=Polygon(( 0,-4),
            ( 3,-4),( 3,-2),( 1,-2),( 1, 2),( 3, 2),( 3, 4),   # 1+6+6*13点
            (-3, 4),(-3, 2),(-1, 2),(-1,-2),(-3,-2),(-3,-4))
C_a=Polygon(( 0,-4),                                           # 1+4=5点
            ( 2,-4),( 2, 4),(-2, 4),(-2,-4))             
print("#",A_a.area,B_a.area,C_a.area)
ansStr,ansValue=compare_variables(A=A_a.second_moment_of_area()[0],
                                  B=B_a.second_moment_of_area()[0], 
                                  C=C_a.second_moment_of_area()[0])
print("#",ansStr)                                  
print("#",ansValue)                                  
print()
ansStr,ansValue=compare_variables(A=A_a.second_moment_of_area()[1],
                                  B=B_a.second_moment_of_area()[1], 
                                  C=C_a.second_moment_of_area()[1])
print("#",ansStr)                                  
print("#",ansValue)                                  
# 32 32 32
# A = B > C
# 704/3 = 704/3 > 512/3

# A > B > C
# 368/3 > 224/3 > 128/3

・ver 0.4 sympyの第Ⅳ象限だけ の一筆書きで十分のような気がしました。
勉強中

いつもの? sympyの実行環境と 参考のおすすめです。

(テンプレート)  開発環境

いつもと違うおすすめです。

Qiita内で

・以下、AI先生に教えてもらいました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?