Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Python Solve Functions - Help For A Noobie 2

Status
Not open for further replies.

sticksandtriangles

Structural
Apr 7, 2015
468
US
sparked by the python coding discussion by Celt83, I am diving in and trying to solve instantaneous center of rotation problems with python.

The example problem I am trying to solve is outlined here:

The way I see this problem, there are (3) unknowns:
[ol 1]
[li]X location of the instantaneous center of rotation, [/li]
[/ol]
[ol 2]
[li]Y location of the instantaneous [/li]
[/ol]
[ol 3]
[li]and the Applied Loading that needs to be maxed out.[/li]
[/ol]

(sorry don't know how to fix the numbering above, fiddled for too damn long)

I also have (3) equations that need to equal 0
[ul]
[li]Sum of Forces in the X = 0[/li]
[/ul]
[ul]
[li] Sum of Forces in the Y = 0[/li]
[/ul]
[ul]
[li]Sum of Moments = 0 [/li]
[/ul]



Even in my "native coding language" matlab, this would be somewhat challenging to code, so I am sure it will be fun using this as a learning experience in python.

Anyways, python experts, do you have any suggestions on how to solve this? Should I explore symbolic notation within in python? Should I use a solve block that iterates through the (3) unknowns?

Any help or suggestions/starting points would be appreciated.

My base code that does the guess and check version of this is shown below:
image_one_cr58iv.png

The final print shows the comparison of applied loading verse resist force.
image_2_fuboii.png







S&T
 
Replies continue below

Recommended for you

Celt83 - I'm getting good convergence with your example, using eccentricity = 5 and Theta = 75. In my code Theta is the angle to the vertical, but it works with Theta = 15 as well. I can set the tolerance down to 1E-13, and it still converges in 1.5 milliseconds. My results (with Theta = 75) are:
ICx = -0.662, ICy = -3.0299, Pu = 95.2908 (see screen-shot below).

One possible reason for the difference in results is that my code takes the eccentricity as being the perpendicular distance from the centroid of the bolt group to the line of action of the applied force, as shown in the diagrams in the first link posted by sticksandtriangles. You seem to be using an XY coordinate for the point of application, with Y = 0, and that would give a different eccentricity for any non-vertical load.

Scipy-solve2_ijs47r.png





Doug Jenkins
Interactive Design Services
 
@IDS: think you may be right on the eccentricity side I'm trying to align with AISC table 7-8 which puts the load at an ex eccentricity with the load y coordinate aligned with the bolt group centroid.

Edit:think the equivalent e on your end would be 1.2941

I added a convergence graph to my gui here is what happens to my version of the Brandt algorithm if I keep the precision too tight, 0.000001:
Capture_vaxb0h.png


vs a tol=0.001:
Capture2_tpuuhi.png


Open Source Structural Applications:
 
So I had this working and now my python program is getting a little finicky.

Now when I run the program i get an error that states "import scipy.optimize as sci" no module named optimize.

Any thoughts on what happened (it was working before)? I do not even know where to check to see where this going wrong. It looks like my console is no longer the same, so I might have moved directories or something?

S&T
 
Seems you got it sorted was going to suggest re-installing.

I've added another chart showing the stability of the C factor across the calculation iterations. This can aid in making an educated decision on whether the smaller tolerances needed sometimes result in a C that is relatively stable or not

Screenshot_from_2018-12-07_21-56-01_pdmkux.png


Open Source Structural Applications:
 
Yakpol has a good spreadsheet for this calculation, with detailed output and also a theory page:

It uses the Excel Solver, but works pretty fast. It is set up with exactly same example as we are working on, except the factored bolt shear strength (Phi.Rn) is set to 27.06 kip.

To check against my code I set Ru to 27.06/0.75, and I corrected deltamax to 0.34 in (I had entered it as 0.43 in in the examples posted previously). With Y set to zero in the Yakpol spreadsheet the eccentricity for my code = X*cos(theta), where theta is the angle to the vertical. With those changes my results agree exactly with Yakpol's spreadsheet.

Celt83 - I tried your code, and using your ic_brandt function with final Icx and Icy values I get exact agreement with the first 4 results in the table output, but all force and moment results are lower by the Ru factor. I don't understand why you are treating Ru as a variable.

Compared with your brandt function, my results are completely different. Have you made significant changes to the posted code?

Finally a warning - first hit on my searches was a site called engineersviewpoint.blogspot. This seems to have been hijacked. I clicked on a link to an updated version of a post supposedly on Brandt's Method with VBA and immediately got pop-up messages that my hard drive was about to be erased.

Doug Jenkins
Interactive Design Services
 
IDS:

Edit: oh all the fxi and fyi's will be off by Ru I did that multiplication at the end so not in the table values.I ment to get that corrected so it shows in the per bolt force table.

Edit2: this may be relevent
Screenshot_from_2018-12-08_23-41-54_a7gerb.png


with the approach of Pult=1, then Rult = -Mp/sumMi, so my Mi table won't match yours but I've fixed the Fxi and Fyi table values to include Rult now.


Open Source Structural Applications:
 
IDS:

I misread your post, Rult is a variable as it is based on the bolt diameter and material. My current functions calculate everything relative to the ratio of the bolt forces to the ultimate force. Doing it this way you get the C multiplier for that bolt arrangement and can then back into a bolt size/material.

Open Source Structural Applications:
 
I solved my issue, with very small eccentricities the ax, ay step size proposed by Brandt ends up being too large and you get to an equilibrium of over/under shooting the actual IC. Using the same equations for ax, and ay but dividing them in half or by 10 takes more iterations to find the IC but lowers the risk of overshoot.

Open Source Structural Applications:
 
so, ive done a complete removal of python xy on my work computer and reinstall and I still get an error:

Python:
import scipy.optimize as sci
yields:
Python:
ImportError: No module named optimize

Not sure what the hang up is. I have this working on my home computer and I just installed python xy there and it works like a charm. Any help would be appreciated.

Thanks,
S&T


S&T
 
you could try opening a command prompt ( windows key --> type cmd.exe --> hit enter) then type pip install scipy.

pip is a package manager used with python and should have been installed if you did a default install of python xy.

Open Source Structural Applications:
 
S&T - You might like to look at installing Anaconda Python, which installs SciPy and Numpy by default, as well as other science and maths related packages. It also includes xlwings, which allows you to call Python functions from Excel, or vice versa.

Doug Jenkins
Interactive Design Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top