Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load cases not working #87

Closed
ghost opened this issue Nov 7, 2021 · 8 comments · Fixed by #107
Closed

Load cases not working #87

ghost opened this issue Nov 7, 2021 · 8 comments · Fixed by #107
Labels

Comments

@ghost
Copy link

ghost commented Nov 7, 2021

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?

@scote89
Copy link

scote89 commented May 6, 2022

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'
```

@RichardWhitfield
Copy link

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
Copy link

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.

@ghost
Copy link
Author

ghost commented Nov 6, 2022

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

@RichardWhitfield
Copy link

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.

@warem-stu
Copy link

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

@RichardWhitfield
Copy link

load.zip

See attached zip file with load.py.

@warem-stu
Copy link

@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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants