anaStruct icon indicating copy to clipboard operation
anaStruct copied to clipboard

Load cases not working

Open Wolinski opened this issue 2 years ago • 3 comments

Hi, I installed anaStruct from github and example on load cases and combinations from docs [(https://anastruct.readthedocs.io/en/latest/loadcases.html#load-cases )] doesn't work anymore, it returns:

File "C:\Python38\lib\site-packages\anastruct\fem\system.py", line 1592, in apply_load_case
    exec("self.{}({})".format(method, kwargs))
  File "<string>", line 1, in <module>
  File "C:\Python38\lib\site-packages\anastruct\fem\system.py", line 932, in q_load
    (q[i][0] ** 2 + q_perp[i][0] ** 2) ** 0.5,  # type: ignore
TypeError: unsupported operand type(s) for ** or pow(): 'list' and 'int'

I see also that print(lc_wind) returns more outputs:

{'q_load-1': {'direction': 'element',
              'element_id': [10, 11, 12, 13, 5],
              'q': [[(-1, -1)]],
              'q_perp': [[([0, 0], [0, 0])]],
              'rotation': None}}

Is there a chance to get update of docs and examples?

Wolinski avatar Nov 07 '21 13:11 Wolinski

same issue here...

running the exact same https://anastruct.readthedocs.io/en/latest/loadcases.html#load-cases-and-load-combinations example, we get the following error:

Loadcase wind:
{'q_load-1': {'direction': 'element',
              'element_id': [10, 11, 12, 13, 5],
              'q': [[(-1, -1)]]}}
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
C:\Users\\AppData\Local\Temp/ipykernel_73584/1884868986.py in <module>
     25 
     26 # add the load case to the SystemElements object
---> 27 ss.apply_load_case(lc_wind)
     28 ss.show_structure()

C:\ProgramData\Anaconda3\lib\site-packages\anastruct\fem\system.py in apply_load_case(self, loadcase)
   1536             kwargs = re.sub(r".??(\w+).?:", r"\1=", kwargs)
   1537 
-> 1538             exec("self.{}({})".format(method, kwargs))
   1539 
   1540     def __deepcopy__(self, memo):

C:\ProgramData\Anaconda3\lib\site-packages\anastruct\fem\system.py in <module>

C:\ProgramData\Anaconda3\lib\site-packages\anastruct\fem\system.py in q_load(self, q, element_id, direction)
    922             id_ = _negative_index_to_id(element_id[i], self.element_map.keys())
    923             self.plotter.max_q = max(
--> 924                 self.plotter.max_q, max(abs(q[i][0]), abs(q[i][1]))
    925             )
    926             self.loads_q[id_] = [

TypeError: bad operand type for abs(): 'list'
```

scote89 avatar May 06 '22 13:05 scote89

Also have the same issue. Looking into this a bit further it seems to be that Load Cases do not work with q_loads.

For v1.3 there is a line in System.py (line 912) which talks about duck typing hell in the method which seems to be the issue (so it's semi known). I'll have a look to see if there is an easy solution but I'm really not a Python programmer so don't hold your breath.

RichardWhitfield avatar Jul 12 '22 04:07 RichardWhitfield

Ok I believe I have solved this one. I have refactored the code in load.py so that the creation of q_load matches the format of q_load in system.py.

This passes all existing tests and I have added an additional test for this error which also passes. I can either post the code here or if someone would like to grant me permissions to push then I'm happy to submit a pull request or alternatively I'm also happy just to upload the changed file here. Let me know.

RichardWhitfield avatar Jul 12 '22 05:07 RichardWhitfield

Hi @RichardWhitfield sorry for late reply. Can you please submit pull request?

ghost avatar Nov 06 '22 09:11 ghost

Hi @wolinski, no worries I still have the code locally! I need permission to push my branch first and then I can create a pull request.

RichardWhitfield avatar Nov 06 '22 20:11 RichardWhitfield

@RichardWhitfield Can you upload your change here? Thank you.

warem-stu avatar Nov 27 '22 22:11 warem-stu

load.zip

See attached zip file with load.py.

RichardWhitfield avatar Nov 28 '22 21:11 RichardWhitfield

@RichardWhitfield Thanks for the file. I got the error followed. Can you help to have a look? Thank you.

Traceback (most recent call last): File "C:\Roy\tools\msys64\home\roy.wu\bin\python3\anaStruct\LC.py", line 23, in <module> ss.apply_load_case(lc_wind) # this does NOT work File "C:/Roy/tools/msys64/mingw32/lib/python3.10/site-packages/anastruct/fem/system.py", line 1543, in apply_load_case exec("self.{}({})".format(method, kwargs)) File "<string>", line 1, in <module> TypeError: SystemElements.q_load() got an unexpected keyword argument 'rotation'

warem-stu avatar Nov 29 '22 19:11 warem-stu