zhuminjie / OpenSeesPy

OpenSeesPy versions, doc, and pip
Other
177 stars 66 forks source link

uniaxial Material 'ElasticMultiLinear' ends programm without error on large data #146

Closed LuMaul closed 1 month ago

LuMaul commented 1 month ago

Im trying to set an own moment-rotation behaviour for a rotational spring. Somehow the ElasticMultiLinear Material ends my python programm without any error message. The print statement after the method isn't beeing executed:

import openseespy.opensees as ops
from typing import Literal
import numpy as np

CURVATURES = [
    -0.0086861903667678,
    -0.0066164760332932,
    -0.0055680858007077,
    -0.0047823962295489,
    -0.0042144233275967,
    -0.0037695729788329,
    -0.0033939716532736,
    -0.0031140609974251,
    -0.0028609917569906,
    -0.0026596317574998,
    -0.002480851050643,
    -0.0023289073542425,
    -0.0021964473225195,
    -0.0020788798502651,
    -0.0019764928611026,
    -0.0018836320630965,
    -0.0018112442362192,
    -0.0017472183519109,
    -0.0016867341906177,
    -0.0016395421358893,
    -0.0015925017778709,
    -0.0015486006564154,
    -0.0015123863733991,
    -0.001476250367094,
    -0.0014402883864556,
    -0.0014112691170936,
    -0.001381571934394,
    -0.0013511406909555,
    -0.0013199085144112,
    -0.0012878015360509,
    -0.0012547347024704,
    -0.001220610252394,
    -0.0011853153748628,
    -0.0011487193058709,
    -0.0011106700605921,
    -0.0010709907973985,
    -0.0010294762969844,
    -0.000985889737026,
    -0.0009399674820354,
    -0.0008914248797544,
    -0.0008399817343732,
    -0.0007854433835286,
    -0.000727847337623,
    -0.0006677177604803,
    -0.0006063668520215,
    -0.0005460172989622,
    -0.0004893340233658,
    -0.0004383750599161,
    -0.0003940027891318,
    -0.000355996453291,
    -0.0003235871645922,
    -0.0002958655724821,
    -0.0002720039429849,
    -0.0002513035306925,
    -0.0002332032686888,
    -0.0002172550667265,
    -0.0002031056541901,
    -0.0001904722634612,
    -0.0001791273851354,
    -0.000168885981629,
    -0.0001595968669811,
    -0.0001511367198936,
    -0.0001434014988302,
    -0.0001363051079612,
    -0.0001297736023196,
    -0.0001238443285491,
    -0.0001185015371976,
    -0.0001134593624606,
    -0.0001086624383098,
    -0.0001040694442986,
    -9.964964685706332e-05,
    -9.537938404681388e-05,
    -9.1240109294899e-05,
    -8.72168908355161e-05,
    -8.329747167419883e-05,
    -7.947166695140011e-05,
    -7.573087654609217e-05,
    -7.206778385881633e-05,
    -6.847620443652038e-05,
    -6.495071219312592e-05,
    -6.148647179795574e-05,
    -5.807939053060164e-05,
    -5.47259438096385e-05,
    -5.142280033946788e-05,
    -4.816714974735037e-05,
    -4.495664699536037e-05,
    -4.178890982107781e-05,
    -3.868117881480865e-05,
    -3.556678319814018e-05,
    -3.247357641599978e-05,
    -2.938049048748545e-05,
    -2.6287513889194816e-05,
    -2.3194635101787677e-05,
    -2.0101842609557187e-05,
    -1.700912490000155e-05,
    -1.3916470463396027e-05,
    -1.0823867792365112e-05,
    -7.731305381455237e-06,
    -4.638771726707248e-06,
    -1.5462553252294586e-06,
    1.546255325229418e-06,
    4.638771726707207e-06,
    7.731305381455193e-06,
    1.0823867792365068e-05,
    1.3916470463395951e-05,
    1.7009124900001473e-05,
    2.0101842609557106e-05,
    2.3194635101787586e-05,
    2.628751388919473e-05,
    2.938049048748541e-05,
    3.247357641599975e-05,
    3.556678319814014e-05,
    3.868117881480861e-05,
    4.178890982107777e-05,
    4.495664699536034e-05,
    4.8167149747350304e-05,
    5.142280033946776e-05,
    5.472594380963841e-05,
    5.807939053060155e-05,
    6.148647179795563e-05,
    6.495071219312584e-05,
    6.847620443652028e-05,
    7.206778385881632e-05,
    7.57308765460921e-05,
    7.947166695140004e-05,
    8.32974716741987e-05,
    8.721689083551604e-05,
    9.124010929489888e-05,
    9.537938404681384e-05,
    9.964964685706328e-05,
    0.0001040694442982,
    0.0001086624383098,
    0.0001134593624606,
    0.0001185015371976,
    0.0001238443285491,
    0.0001297736023196,
    0.0001363051079612,
    0.0001434014988302,
    0.0001511367198936,
    0.0001595968669811,
    0.000168885981629,
    0.0001791273851354,
    0.0001904722634612,
    0.0002031056541901,
    0.0002172550667265,
    0.0002332032686888,
    0.0002513035306925,
    0.0002720039429849,
    0.0002958655724821,
    0.0003235871645922,
    0.000355996453291,
    0.0003940027891318,
    0.0004383750599161,
    0.0004893340233658,
    0.0005460172989622,
    0.0006063668520215,
    0.0006677177604803,
    0.000727847337623,
    0.0007854433835286,
    0.0008399817343732,
    0.0008914248797544,
    0.0009399674820354,
    0.000985889737026,
    0.0010294762969844,
    0.0010709907973985,
    0.0011106700605921,
    0.0011487193058709,
    0.0011853153748628,
    0.001220610252394,
    0.0012547347024704,
    0.0012878015360509,
    0.0013199085144112,
    0.0013511406909555,
    0.001381571934394,
    0.0014112691170936,
    0.0014402883864556,
    0.001476250367094,
    0.0015123863733991,
    0.0015486006564154,
    0.0015925017778709,
    0.0016395421358893,
    0.0016867341906177,
    0.0017472183519109,
    0.0018112442362191,
    0.0018836320630965,
    0.0019764928611026,
    0.0020788798502651,
    0.0021964473225195,
    0.0023289073542425,
    0.002480851050643,
    0.0026596317574998,
    0.0028609917569906,
    0.0031140609974251,
    0.0033939716532737,
    0.0037695729788329,
    0.0042144233275966,
    0.0047823962295489,
    0.0055680858007077,
    0.0066164760332932,
    0.0086861903667677
    ]

MOMENTS = [
    -3405.4264161941337,
    -3371.2010250766048,
    -3336.975633959076,
    -3302.750242841547,
    -3268.524851724018,
    -3234.299460606489,
    -3200.07406948896,
    -3165.8486783714307,
    -3131.6232872539017,
    -3097.3978961363728,
    -3063.172505018844,
    -3028.947113901315,
    -2994.721722783786,
    -2960.496331666257,
    -2926.270940548728,
    -2892.045549431199,
    -2857.82015831367,
    -2823.594767196141,
    -2789.369376078612,
    -2755.143984961084,
    -2720.918593843554,
    -2686.693202726025,
    -2652.467811608496,
    -2618.242420490967,
    -2584.017029373438,
    -2549.791638255909,
    -2515.5662471383803,
    -2481.340856020852,
    -2447.1154649033224,
    -2412.890073785793,
    -2378.6646826682645,
    -2344.439291550735,
    -2310.2139004332066,
    -2275.988509315677,
    -2241.7631181981487,
    -2207.53772708062,
    -2173.3123359630904,
    -2139.086944845561,
    -2104.8615537280325,
    -2070.636162610504,
    -2036.4107714929744,
    -2002.1853803754457,
    -1967.9599892579165,
    -1933.734598140388,
    -1899.5092070228584,
    -1865.2838159053297,
    -1831.0584247878007,
    -1796.8330336702718,
    -1762.6076425527426,
    -1728.3822514352137,
    -1694.1568603176847,
    -1659.9314692001558,
    -1625.7060780826268,
    -1591.480686965098,
    -1557.255295847569,
    -1523.0299047300398,
    -1488.8045136125108,
    -1454.579122494982,
    -1420.353731377453,
    -1386.128340259924,
    -1351.9029491423948,
    -1317.677558024866,
    -1283.452166907337,
    -1249.226775789808,
    -1215.001384672279,
    -1180.77599355475,
    -1146.5506024372212,
    -1112.3252113196922,
    -1078.0998202021633,
    -1043.8744290846344,
    -1009.6490379671054,
    -975.423646849576,
    -941.1982557320472,
    -906.972864614518,
    -872.7474734969892,
    -838.5220823794602,
    -804.2966912619313,
    -770.0713001444024,
    -735.8459090268734,
    -701.6205179093445,
    -667.3951267918155,
    -633.1697356742866,
    -598.9443445567576,
    -564.7189534392287,
    -530.4935623216993,
    -496.2681712041704,
    -462.0427800866414,
    -427.81738896911247,
    -393.5919978515835,
    -359.3666067340546,
    -325.14121561652564,
    -290.9158244989967,
    -256.69043338146776,
    -222.4650422639388,
    -188.23965114640987,
    -154.01426002888093,
    -119.78886891135151,
    -85.56347779382259,
    -51.33808667629364,
    -17.1126955587647,
    17.112695558764244,
    51.33808667629319,
    85.56347779382213,
    119.78886891135107,
    154.01426002888002,
    188.23965114640896,
    222.4650422639379,
    256.69043338146685,
    290.9158244989958,
    325.1412156165252,
    359.36660673405413,
    393.5919978515831,
    427.817388969112,
    462.04278008664096,
    496.2681712041699,
    530.4935623216988,
    564.7189534392278,
    598.9443445567567,
    633.1697356742857,
    667.3951267918146,
    701.620517909344,
    735.8459090268725,
    770.0713001444019,
    804.2966912619304,
    838.5220823794598,
    872.7474734969883,
    906.9728646145176,
    941.1982557320462,
    975.4236468495756,
    1009.649037967105,
    1043.8744290846334,
    1078.0998202021628,
    1112.325211319691,
    1146.5506024372207,
    1180.7759935547492,
    1215.0013846722786,
    1249.226775789807,
    1283.4521669073365,
    1317.677558024865,
    1351.9029491423944,
    1386.1283402599229,
    1420.3537313774525,
    1454.5791224949817,
    1488.8045136125102,
    1523.0299047300396,
    1557.255295847568,
    1591.4806869650974,
    1625.706078082626,
    1659.931469200155,
    1694.1568603176838,
    1728.3822514352132,
    1762.6076425527417,
    1796.833033670271,
    1831.0584247878,
    1865.283815905329,
    1899.5092070228584,
    1933.7345981403869,
    1967.9599892579165,
    2002.1853803754448,
    2036.4107714929744,
    2070.6361626105027,
    2104.861553728032,
    2139.0869448455605,
    2173.31233596309,
    2207.5377270806184,
    2241.763118198148,
    2275.9885093156763,
    2310.2139004332057,
    2344.439291550735,
    2378.664682668264,
    2412.890073785793,
    2447.115464903321,
    2481.340856020851,
    2515.56624713838,
    2549.7916382559088,
    2584.0170293734373,
    2618.2424204909667,
    2652.467811608495,
    2686.6932027260245,
    2720.918593843553,
    2755.1439849610824,
    2789.369376078612,
    2823.5947671961403,
    2857.8201583136697,
    2892.045549431198,
    2926.270940548728,
    2960.496331666256,
    2994.721722783785,
    3028.947113901314,
    3063.172505018844,
    3097.397896136372,
    3131.6232872539013,
    3165.8486783714307,
    3200.074069488959,
    3234.2994606064885,
    3268.524851724017,
    3302.7502428415464,
    3336.975633959075,
    3371.2010250766043,
    3405.4264161941333
    ]

def build_ops_model() -> None:
    ops.wipe()
    ops.model('basic', '-ndm', 2, '-ndf', 3)

def node(nodeTag:int, x:float, y:float) -> None:
    ops.node(nodeTag, *[x, y])

def fix(
        nodeTag:int,
        x:Literal['free', 'fixed']='fixed',
        y:Literal['free', 'fixed']='fixed',
        zz:Literal['free', 'fixed']='fixed'
        ) -> None:

    OPS_MAPPER = {
        'free':0,
        'fixed':1
        }

    ops.fix(
        nodeTag,
        OPS_MAPPER[x],
        OPS_MAPPER[y],
        OPS_MAPPER[zz]
        )

def rotational_spring(
        eleTag:int,
        sta_nodeTag:int,
        end_nodeTag:int,
        moments:list[float],
        curvatures:list[float]
        ) -> None:

    if not len(curvatures) == len(moments):
        raise Exception("rotation list must have same length as moments")

    ROT_MAT_TAG = 0
    ops.uniaxialMaterial(
        'ElasticMultiLinear',
        ROT_MAT_TAG,
        0.0,
        '-strain',
        *curvatures,
        '-stress',
        *moments
    )

    # code gets stuck in 'ElasticMultiLinear'
    print('ElasticMultilinear Material took info')

    ALL_DIRS_MAT_TAG = 1
    E = 10e10
    ops.uniaxialMaterial(
        'Elastic',
        ALL_DIRS_MAT_TAG,
        E,
    )

    ops.element(
        'zeroLength',
        eleTag,
        sta_nodeTag,
        end_nodeTag,
        '-mat',
        ALL_DIRS_MAT_TAG,
        ALL_DIRS_MAT_TAG,
        ROT_MAT_TAG,
        '-dir',
        1, 2, 6
        )

def elasticBeam(
        eleTag:int,
        srt_nodeTag:int,
        end_nodeTag:int,
        Area:float=1.0,
        E:float=10e10,
        Iz:float=10e10
        ) -> None:
    nodes = [srt_nodeTag, end_nodeTag]
    stiffs = [Area, E, Iz]
    TRANSF_TAG = 1
    ops.geomTransf('Linear', TRANSF_TAG)
    ops.element('elasticBeamColumn', eleTag, *nodes, *stiffs, TRANSF_TAG)

def TimeSeries(tsTag:int) -> None:
    ops.timeSeries('Constant', tsTag)

def Pattern(patTag:int, tsTag:int) -> None:
    ops.pattern("Plain", patTag, tsTag)

def PointForce(AtnodeTag:int, x:float, y:float, zz:float) -> None:
    ops.load(AtnodeTag, x, y, zz)

def solveSystem() -> None:
    ops.constraints('Plain')
    ops.numberer('RCM')
    ops.system('BandGen')
    ops.test('NormDispIncr', 1.0e-8, 6)
    ops.algorithm('Newton')
    ops.integrator('LoadControl', 0.1)
    ops.analysis('Static')

    ok = ops.analyze(1)

    if ok == 0:
        print("Analysis completed successfully")
    else:
        print("Analysis failed")

def main():
    build_ops_model()

    node(nodeTag=1, x=0, y=0)
    node(nodeTag=2, x=0, y=0)
    node(nodeTag=3, x=0, y=5)

    fix(nodeTag=1, x='fixed', y='fixed', zz='fixed')

    rotational_spring(
        eleTag=0,
        sta_nodeTag=1,
        end_nodeTag=2,
        moments=MOMENTS,
        curvatures=CURVATURES
        )

    elasticBeam(eleTag=1, srt_nodeTag=2, end_nodeTag=3, E=32_000, Iz=10)

    TS_TAG = 0
    TimeSeries(TS_TAG)
    Pattern(patTag=0, tsTag=TS_TAG)
    PointForce(AtnodeTag=3, x=500, y=0, zz=0)

    solveSystem()

    print(ops.nodeDisp(3))

if __name__ == '__main__':
    main()
zhuminjie commented 1 month ago

This is due to too many stress and strain points. Currently only 64 is allowed. Will fix in the next release.

LuMaul commented 1 month ago

Thank you very much for your prompt response! Is there an easier way (or workaround) to define my own moment-rotation behavior for a zeroLength element?

mhscott commented 1 month ago

Use 64 points or less!