×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Learning Programming for Structural Engineering
10

Learning Programming for Structural Engineering

Learning Programming for Structural Engineering

(OP)
I have recently become very interested in matrix structural analysis and finite element analysis and I have been creating my own "program" using excel. Of course I have quickly noticed that the basic operations available within excel without using VBA is somewhat limited and I cannot make the quality of the program I want. So naturally I have began learning VBA and in my journey around the internet learning VBA I have seen other recommendations for more powerful languages such as Python, Matlab, Fortran etc..

During this whole process I have been thinking a lot about the usefulness of coding in structural engineering and thought that it might be a fun conversation to have to see what other structural engineers have taught themselves to code, how useful they have found it, and what language might be the most helpful. So I would love to hear others opinions on the topic of coding for a structural engineer!

“Any idiot can build a bridge that stands, but it takes an engineer to build a bridge that barely stands.”

RE: Learning Programming for Structural Engineering

Hi Megastructures

I love programming, I started at a young age and was initially enrolled to study computer science with computational and applied mathematics, I eventually ended up doing Civil engineering.

I think it is a valuable skill that many engineers neglect and don't bother with, as you can develop some amazing solutions through programing.

For my work and personal FEA programming purposes I use Octave which is basically the same as Matlab just a freeware version, the syntax and file formats are exactly the same which makes it easy for trouble shooting as the Matlab help forums are amazing. I also have a freeware copy of Mathematic which runs from a Raspberry Pi which I normally use to test preliminary mathematical ideas which are mathematically intense, just to check the feasibility or troubleshoot before I take the concept to Octave to develop a full on program. I am currently writing a paper about a methodology I developed using a very unconventional method to assess the stability of barges, I implemented the methodology on Octave.

For my personal coding, making small games or messing around with AI, I normally use Python. The only reason I don't use Python in my professional life due to the lack of stability when it comes to updates. A colleague developed a monstrous piece of code for remotely assessing the life span on mechanical equipment and when he did an update of python and/or it's modules, all his code stopped working. After a huge amount of time debugging he couldn't get it to work and just reverted back to the older versions. You wouldn't have these type issues on stuff like Matlab and Octave.

RE: Learning Programming for Structural Engineering

I think coding is an excellent skill to have as a structural engineer. I personally enjoy working with C# and javascript, which are two main languages I used for building Tribby3d.

Coding is such a good tool for calcs, structural design and geometry. Aside from text based coding, I would also recommend checking out visual programming such as Grasshopper3d. It's great for generative design and parametric modelling.

Best of luck!

RE: Learning Programming for Structural Engineering

(OP)
I saw your program tribby3d and I was immediately impressed with the graphical interface. I don't work with concrete often, but I do plan on trying the program. Funny you mention Grasshopper3d as another item I've been learning is Dynamo for Revit, which is another visual programming language and seems to make the process so easy it is hard to call it coding :).

It seems like VBA would be the most practical language to learn based on how often Microsoft and Auto-desk programs are used in engineering offices, but VBA doesn't seem to be a very "respected" coding language and it would be a bummer to take the time to learn a language that isn't as helpful as some others. The main reason I started trying to learn VBA for my own program is to try to learn how to make a graphical interface that shows element deflections like shown here. https://www.youtube.com/watch?v=KdwMysKqcFk

I've also just always been extremely impressed by the functions that some companies have been able to automate with the help of a good programmer.

“Any idiot can build a bridge that stands, but it takes an engineer to build a bridge that barely stands.”

RE: Learning Programming for Structural Engineering

no issue learning VBA, in my experience most of the differences across programming languages are syntax related a logic statement is still a logic statement and a loop s still a loop. Check out IDS's site for some of the things you can do with VBA, https://newtonexcelbach.com/

I'd say since you've already started VBA keep with it and see where it leads, Excel is ubiquitous in our industry so makes deployment of your sheet/program almost trivial vs making a web or GUI based program in another language.


My Personal Open Source Structural Applications:
https://github.com/buddyd16/Structural-Engineering

Open Source Structural GitHub Group:
https://github.com/open-struct-engineer

RE: Learning Programming for Structural Engineering

2
Years ago, I took a Visual Basic course as part of my continuing education. One lesson learned from that, is that if you don't regularly use the material, you tend to forget it before long, too. A lesson learned from Excel work primarily is that there is a substantial investment in time to confirm that the software is doing what you think it is.

RE: Learning Programming for Structural Engineering

It's been a few years since I last programmed, but used to program in half a dozen different languages... My language of preference was Embarcadero... this is the re-name of Borland's Delphi... extremely powerful with an incredibly easy user interface... The graphical interface and putting together a program is so fast and easy. It can be used for anything that C++ can do and a lot easier. The Pascal type language is strongly typed. Try it, you'll like it... it's incredibly easy to use. It has a built-in matrix operation 'toolkit'.

Rather than think climate change and the corona virus as science, think of it as the wrath of God. Feel any better?
-Dik

RE: Learning Programming for Structural Engineering

If you're not invested or interested in writing your own standalone programs, it may also be of interest to work with the APIs of existing programs to automate the more mind-numbing (and thus mistake-prone) tasks or checks. We've been using the little downtime we have now while things are a little slower to play around with creating tools for Revit and ETABS, for instance. I know RAM SS has an API as well, though we haven't touched that one yet since we don't use that program as much. Would love an API for RAM Concept, but don't think that exists yet. We're using Python for our tools, though C# is a pretty common language for APIs as well. Then Revit uses Dynamo as well, as you noted.

RE: Learning Programming for Structural Engineering

I'll suggest that what Mohanlal said is true. Using Matlab makes things a good bit easier on you. I don't personally use it. But, a number of "part time" programmers in graduate school swore by it.

RE: Learning Programming for Structural Engineering

When I first learned to program structural analysis, I took a huge mental leap in terms of problem solving ability and the process of distilling complex problems into logical steps. I owe my college professor (shout out to Dr. Bill Davids) a debt of gratitude for that, as that skill has probably had the most beneficial and significant impact on my career as an engineer.

RE: Learning Programming for Structural Engineering

Don't be ashamed of Excel and VBA but don't expect too much out of them either. I have created some VBA programs for helping me solve retaining wall designs or creating an interaction diagram for a reinforced concrete column design but its abilities for solving complex mathematical operations is limited. I typically write specialty programs nowadays to solve very specific mind numbing math operations that are pretty standardized but that end up saving me lots of time in the end. A thorough program that solves repetitive wood beam design, FRP strengthening, or a PT tendon profile layout can be really helpful. You can either create it just in the spreadsheet or utilize VBA to make the interface have a more professional feel.

Matlab and Fortran were great for me while in school when setting up stiffness matrices and finding forces in truss members but haven't used it since I've been practicing engineering. If you are going to undertake this in a very serious way then I am sure you will have some use for these languages but as a working professional, I know that it's hard to find free time to do this type of stuff if it's not making you money... As for FEA, we're talking a steep learning curve! My FEA professor in grad school created a program with some help from some of his RA's and I looked into it once and was astonished at the limited abilities of it compared to some of the commercially available programs. It makes you realize just how much effort and mindpower go into some of these programs.

RE: Learning Programming for Structural Engineering

(OP)
Wow, I really didn't expect so many responses. It seems that maybe programming isn't as rare among the structural engineering ranks as I might have thought. I appreciate everyone's responses.

Celt83 that was my idea, that once I learned one language I had a better shot at being able to learn others down the road if the need arose.

MrHershey Becoming good at modifying existing commercial programs with API's seems like possibly the most beneficial thing to do with the lowest "cost of entry" in time spent learning. I definitely want to start writing some API's where I can.

Bones206 That is exactly my hope!

STrctPono I'm only making this program to learn. I have spent years kind've sort've knowing what my FEA solver was doing for me on a basic level, but I don't have a full grasp on mesh convergence etc. and I figured what better way to learn the program than build one myself! I am experienced in ANSYS, FEMAP, and SOLIDWORKS so I have no real need to create my own program, but it's sort of fun and teaching me quite a bit.

“Any idiot can build a bridge that stands, but it takes an engineer to build a bridge that barely stands.”

RE: Learning Programming for Structural Engineering

3
Thanks for the mention Celt83.

On the question of whether it is worth using VBA:

It is true that VBA is not well respected amongst full-time programmers, but as far as I have seen the people who make bad comments about it don't know what they are talking about. Not only do they not use the program regularly, they don't even know what the actual features are, or what its real strong points and weaknesses are. Their opinion seems to be based on inexpert users making programming mistakes, which of course there are plenty of examples of, since it remains by far the most widely used programming language for inexpert users.

It simply isn't true that VBA is a less powerful programming language than those used by full-time developers; you can do any computation in VBA that you can do in any other language, including linking to compiled routines if you need to speed up maths intensive operations. The only disadvantages I see with VBA are:

1) You are tied to the Office interface (which means Excel, as far as I'm concerned). This is also an advantage (see below), but it does make it difficult doing anything to work on-line, or do anything for pads or phones (although I don't see why anyone would choose to use a pad or a phone for general engineering work).

2) Passwords are easily cracked, so if code security is an important issue, VBA is not the program to use.

3) Microsoft are basically doing nothing with it these days, so the coding interface is looking pretty old fashioned. I don't find that a problem myself, in fact I still find it far easier and faster to code and debug in VBA than in alternatives, but people starting out may prefer a more modern interface.


Now the advantages:

1) The interface with Excel makes it (as far as I have seen) the easiest and most efficient way to set up programs using numerical calculations, and to display results efficiently. I simply don't agree that using Excel for complex calculations is particularly error prone. Of course it is easy to make mistakes, but it is at least equally easy in any other programming language. In my experience, checking for and fixing errors is much easier using Excel+VBA than it is in any other programming language/ graphical interface, including Python, which I have used quite extensively in recent years.

2) The ability to record and then edit a VBA macro makes the use of complex object models far easier.

3) There are numerous resources on-line available to help non-expert programmers.

For more discussion of what VBA is good for, including links to a number of engineering examples see:

https://newtonexcelbach.com/2013/03/06/what-micros...

Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/

RE: Learning Programming for Structural Engineering

(OP)
IDS, awesome! You have inspired me to keep going with VBA. I opened up your "Frame4 file" and your plot of the frame deflections is exactly what I'm trying to learn right now! I will study your code and see if I can replicate it. I love the website!

“Any idiot can build a bridge that stands, but it takes an engineer to build a bridge that barely stands.”

RE: Learning Programming for Structural Engineering

@OP,

If you are a non-programmer and would like to learn programming AND you do not have any particular application/project in mind I would 100% recommend starting with Python. Python is a minimalistic language and so it is possibly the easiest environment to learn basic principles of programming without getting too bogged down in language-specific syntax and other funny bits that you get with some of the other languages. On top of this Python is a general purpose language that can perform on state-of-the-art level if used well and there will be very few instances where you cannot use it to meet your objectives.

Having said that if you work in a traditional style of structural consultancy and would like to learn programming with work-related applications in mind then your best bet is probably VBA. VBA is ugly, it is clunky, and it can be limiting...but it is very good at using Office applications programmatically and thus it is a clear winner. If you are fluent in Python people will find it cool but likely nothing will come of it, however if you are fluent in VBA your employer will potentially (big emphasis on this word) love it and you stand a good chance of firing it up for work every so often. I would say that great majority of work-related tasks can be performed with VBA and it's only with really complex math that you may have to venture out into Python/Java/C++/whatever to fill in the blanks.

There are many good things about MATLAB and in many ways it is similar to Python in the way that it has minimalistic syntax. MATLAB's big downside is that you have to pay a fair amount of money to use it as it comes inside of a proprietary application. MATLAB is also not a general purpose programming language and so it has its limitations - it's like JavaScript but for scientists and engineers.

Accessing application API's is a very useful feature that I think is going to become commonplace in the next 10 years or so. Being able to programmatically access something completely changes the way you look at it - the easiest analogy is to think of how your use of Excel is affected by becoming fluent in VBA. I personally don't even use convoluted nested Excel functions anymore because sometimes it is just way easier to write a custom function to do the job. Application API's change the situation in a similar manner, you can write your own tools to fill in the functionality blanks that are inevitably let over by the application designers.

RE: Learning Programming for Structural Engineering

(OP)
IDS - Did you use the conjugate beam method found on your blog post here to model the appropriate deflected shape for your beam program, or is there a simpler/more effective technique you recommend?

That will be my only questions as I don't expect free help!

“Any idiot can build a bridge that stands, but it takes an engineer to build a bridge that barely stands.”

RE: Learning Programming for Structural Engineering

Conjugate beam is one method. I found once I had the end moments from either moment distribution or stiffness matrix solutions it was simpler to use the deflection formulas from direct integration for each load type directly and combine the results using super position. Assuming you've already got the formulas worked out for each loading type and a beam with constant cross section.

My Personal Open Source Structural Applications:
https://github.com/buddyd16/Structural-Engineering

Open Source Structural GitHub Group:
https://github.com/open-struct-engineer

RE: Learning Programming for Structural Engineering

Quote (MegaStructures)

IDS - Did you use the conjugate beam method found on your blog post here to model the appropriate deflected shape for your beam program, or is there a simpler/more effective technique you recommend?

No, the procedure used in the ConBeam spreadsheet is:

1. Find the deflections and actions in the beam with all internal supports and end moment restraints removed, i.e. as a simply supported beam with only the end supports.

2. Find the deflections at each support due to unit loads at each support position (one loadcase for each support freedom).

3. Set up and solve the simultaneous equations to find the reaction forces required to reduce the combined deflection to zero at every support location.

4. Find the deflections and actions along the beam due to the combined reaction forces, and add to the results from 1.


Quote:

That will be my only questions as I don't expect free help!

I like to get questions on anything posted in the blog and you are free to use the code from any of the download files. Feel free to ask as many questions as you like, and if it is too detailed or time consuming for me to answer (or if I'm just busy with other things) I'll let you know.

Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/

RE: Learning Programming for Structural Engineering

captain-slow - I'm tempted to leap to the defence of VBA, but since I doubt we'd agree on that, I'll just comment on why I am using Python (with Excel) these days.

Python has several features that I dislike, and lacks some VBA features that I find very useful, but what it does have that VBA lacks is easy access to a vast range of free libraries (such as Numpy and Scipy) that provide efficient compiled code for linear algebra, statistics, curve fitting, solver routines, and many others. These combined with Excel interface programs such as pyxll or xlwings allow maths intensive applications to be run efficiently from Excel with less hassle than preparing and accessing compiled code through VBA.

Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/

RE: Learning Programming for Structural Engineering

(OP)
My apologies IDS, I asked about the method used to find deflection on your beam program, but I meant to ask about the Frame4 file, since I’m building a general frame program now. For now I have been trying to use the double integration method by creating sample points at every 0.25” of beam length and obtaining values for shear and then calculating the approximate area under the curve with the trapezoid rule to find moments, slopes, and deflections, I figure I can always tighten up the distances and make the result more accurate, since I can’t think of a way to get an exact equation to integrate. (So this is the simple beam portion of your example above)

The last thing I am still trying to figure out is how to deal with end conditions on my deflection values, which I think you gave me the answer to above, but I just haven’t quite grasped the concept. I of course already have nodal deflections calculated for purposes of finding element forces, but I have to figure out how to make the intermediate deflection results and nodal deflection results “agree”. I’m just not quite grasping the idea of making a system of equations, because I’m not working it through equations, but a set of approximated points. Of course equations would be better if I could figure out how to create them :)

“Any idiot can build a bridge that stands, but it takes an engineer to build a bridge that barely stands.”

RE: Learning Programming for Structural Engineering

Sample points at 0.25" or less would be for extremely short spans, I presume.

BA

RE: Learning Programming for Structural Engineering

Mega:

You can create the Shear, Moment, slope/rotation, and Deflection equations for each load type using direct integration, doing it this way you can greatly reduce the number of stations to just what you need for a smooth plot and avoid the compounding error of approximate integration routines (I found this to be about 20 to 25 stations along the span).

Once you have these, or you can take them from my github here: Link, then at each station you can calculate the desired result per load type and add them together, superposition, to form the total response.

To account for end deflections you can again use superposition and either do linear interpolation between the two nodal deflections or form the line equation and get a direct result.

For getting exact results see this thread where I struggled/overcomplicated the process: https://www.eng-tips.com/viewthread.cfm?qid=447991

My Personal Open Source Structural Applications:
https://github.com/buddyd16/Structural-Engineering

Open Source Structural GitHub Group:
https://github.com/open-struct-engineer

RE: Learning Programming for Structural Engineering

VBA version of the beam formulas I posted here, 01 - Beam_User_Functions file and the three .bas files: https://github.com/open-struct-engineer/Excel/tree...
the .bas files are exports of the VBA while the excel file has them loaded in as User Defined Functions (UDFs)

Quick note when I derived these formulas it was before I started getting into stiffness methods so the sign convention doesn't follow what you'll see in textbooks for that method.

My Personal Open Source Structural Applications:
https://github.com/buddyd16/Structural-Engineering

Open Source Structural GitHub Group:
https://github.com/open-struct-engineer

RE: Learning Programming for Structural Engineering

(OP)
Ah I think I get it! There are intermediate deflections caused mainly by the internal moments along the beam span, which can be found by integrating the moment (I chose the trapezoid rule to do this previously) and there are nodal deflections found from the stiffness matrix solution. A unique beam deflection can be found by each case at discrete stations and then combined to form a final deflected shape. The only thing I haven’t taken into account with this explanation (I think) is the effect of moment constraints, which will hold slope=0 at the boundary and should be reflected in the deflected shape. My first thought to show this is by putting an if statement in the first 2 stations of the Intermediate deflected shape that basically says if the node is fixed against rotation the first two stations deflection should be 0 (maybe I would have to adjust how many stations to add this condition to based on how it made the plot look)

“Any idiot can build a bridge that stands, but it takes an engineer to build a bridge that barely stands.”

RE: Learning Programming for Structural Engineering

(OP)

“Any idiot can build a bridge that stands, but it takes an engineer to build a bridge that barely stands.”

RE: Learning Programming for Structural Engineering

Have a look here.

RE: Learning Programming for Structural Engineering

Superposition of the individual results of the direct functions for V,M and D for a point load, trapezoidal load, left end moment, and right end moment. (moments used here correspond to the fixed end moment so the start and end slope of the deflection curve is 0)


(link to larger image: here)
https://en.wikipedia.org/wiki/Superposition_princi...

My Personal Open Source Structural Applications:
https://github.com/buddyd16/Structural-Engineering

Open Source Structural GitHub Group:
https://github.com/open-struct-engineer

RE: Learning Programming for Structural Engineering

(OP)
Celt83 I was hoping I got back to the post before anyone else did. I was doing something else and it popped into my head how silly I was with my struggles on how to include the deflection from a fixed end. Of course the reaction moments at fixed end will result in another shear-moment diagram that can be integrated to find the deflection and then superimposed. Your picture makes it even clearer and I can’t wait to add intermediate deflections to my program.

Thanks to all!

“Any idiot can build a bridge that stands, but it takes an engineer to build a bridge that barely stands.”

RE: Learning Programming for Structural Engineering

Quote (MegaStructures)

shear-moment diagram that can be integrated
I still recommend not doing numerical integration via trapezoidal or Simpson rule and instead come up with the actual slope and deflection formulas for end moments or more generally for a moment applied at any point on the beam.

Formulation of those slope and deflection formulas are actually the foundation for the stiffness matrix that your using so would be a good exercise anyway. The bending stiffness entries in the matrix come from solving the simultaneous equations for introducing unit slopes and deflections to either end of the beam.

My Personal Open Source Structural Applications:
https://github.com/buddyd16/Structural-Engineering

Open Source Structural GitHub Group:
https://github.com/open-struct-engineer

RE: Learning Programming for Structural Engineering

not sure if your working off of any textbooks for reference but here are a couple good ones:

Matrix Analysis of Framed Structures, Gere : https://www.amazon.com/Matrix-Analysis-of-Framed-S...
Moment Distribution, Gere: https://www.amazon.com/Distribution-University-Eng...
(This one is a great pre-cursor to matrix analysis to build up a foundation on member end flexibility/stiffness)

Mastan2: http://www.mastan2.com/textbook.html
(this one is free and so is the associated program, goes into advanced analysis for second order effects and buckling)

My Personal Open Source Structural Applications:
https://github.com/buddyd16/Structural-Engineering

Open Source Structural GitHub Group:
https://github.com/open-struct-engineer

RE: Learning Programming for Structural Engineering

@OP

In my opinion, programming is great skill to pick up as a structural engineer. The best thing about learning programming is that it will teach you more about structural engineering. When you write a program to solve a structural analysis problem, you aren't solving a single geometry which is typical for project work but a field of problems.

That process will force you to learn the edge cases in structural analysis which most engineers don't get to see in the same way. It gives you this holistic view, where you'll be able to see issues other engineers who have always approached the problem with a "just get it to work" mentality don't.

For my two cents, I agree with @captain_slow. I really like python. Easy to learn but extremely powerful if you choose to go further with it. Numpy and scipy are great for optimisation, but then can also learn FEM APIs. It's also worth noting that python is the language of choice for machine learning / AI which, full disclosure I think is a a long way off from having an impact in structural engineering, but that only means you could be the engineer to create that impact.

Hope that helps.

Complete Columns
https://www.completecolumns.com/

RE: Learning Programming for Structural Engineering

@IDS,

I am the first person to admit that choice of programming language depends on the type of problem at hand. VBA has its ups and downs with the ups being Excel integration and how commonplace it is (certainly more commonplace in structural consulting than any other language) and the downs being cryptic syntax and lack of in-built array functionality. I personally die a little inside every time I have to juggle/loop/sort arrays in VBA.

I think that the following is a good example of how choice of language depends on task at hand.

My workplace uses RAM Structural System as our main FEA package. RAM SS has a decent enough FEA engine and an outdated user interface that lacks a whole heap of modelling features. In short, if I have to model a large structure in RAM I am not happy with life until modelling is done and I get onto post-processing of analysis. However RAM SS also has an application API - this serves as a back-end way for me to talk to the application programmatically and enables me to program a few features that I lack. I have a choice of C# or VBA to access the API from which I choose VBA because I am functional at it. This also has an added benefit of my code being maintainable when I move onto a different workplace as my office has two other guys that know VBA and nobody that is familiar with C#.

On the other hand when I come home I want to run some statistical analysis based on scraped web data (non-engineering related side hobbies) I use Python. Python enables me to do pretty much anything and everything - I can scrape data from the web, I can juggle enormous arrays of information, and I can perform fancy analysis using dodgy (and non-dodgy too) pseudo-AI libraries that I download from GitHub. Trying to do all of this stuff with VBA would be like sawing timber with a kitchen knife, theoretically possible but why would you do it if there are better tools available.

This is not criticism of VBA as a language at at all - I think that it does its job very well. It's just a fundamentally different beast to Python and so there is little use in comparing the two. Hence my advise to new programmers is typically to learn Python if they want to learn programming and to learn VBA if they want to boost their employment value.

And I also always say to not ever expect anything employment wise from being able to code. We are structural engineers and so we are typically hired for the task - employers seldom set out to find a structural engineer that can code, they are typically more interested in your ability to structurally engineer.

RE: Learning Programming for Structural Engineering

@Complete_columns,

Mostly agree with everything you say - especially the "edge cases". Engineers have a weakness for falling into "just get it to work on paper" type of situations, which is a complex professional issue deserving its own thread.

I just want to say that I really like your website - had a glance at it a few days ago and it looks very good. Certainly very impressive visually. Having said that I am yet to dig properly into it and look at content as time is always short...

Having had a brief read through some of the information I notice that you have some sizing optimisation features - I may or may not contact you for a chat about that if you don't mind as this question of efficiently grouping structural elements has been dwelling on my mind lately. But that is once I look properly through your website lest I say something silly.

RE: Learning Programming for Structural Engineering

@OP,

For a beam element FEA solver you have to work with generic formulas for beam deflections under generic loads. This is a complex topic, however I reckon I can give you the generic stiffness matrix:



Generally speaking you have to do the following:

1. Discretise your load.
2. Discretise your beam.
3. Generate a load vector and assemble a corresponding corresponding stiffness matrix.
4. Solve the resulting matrix equation for the displacement vector.
5. Post-process and derive moment/shear/displacement diagrams.

You certainly need to discretise a bit further than 4 sub-elements to get accurate solutions - ideally you make number of sub-elements an input into your function and then you can vary that number to see how number of sub-elements affects accuracy of your solution.

RE: Learning Programming for Structural Engineering

@captain_slow

Thanks very much. It's a work in progress but that's exactly what I was going for. Column design grouping optimisation through visualisation rather than a black box algorithm. Also a pretty picture to impress clients.

Please do follow up if want to chat. I'm at nick@completecolums.com.

And I may have to start that thread about where engineers sit on the "just get it to work" versus "read everything about the problem" scale.

Complete Columns
https://www.completecolumns.com/

RE: Learning Programming for Structural Engineering

Quote (captain_slow)

You certainly need to discretise a bit further than 4 sub-elements to get accurate solutions - ideally you make number of sub-elements an input into your function and then you can vary that number to see how number of sub-elements affects accuracy of your solution.

You really don't need to sub divide the bar elements. If you have the general formulas worked out all you need is the end moments and you can then construct the full piecewise formulas for shear, moment, slope, and deflection and solve for the roots to find locations of absolute maxima and minima. With the piecwise formulas worked out you can then just take a sampling of stations along the bar so when you plot the diagrams they look nice enough, you can speed up the backend a bit by doing the station values on demand when showing the plots vs preprocessing them and having them stored in memory. When you plot inject additional plot points just before and after load points this gets the discontinuity in the shear/moment diagram shown with a nearly vertical line vs diagonal line with uniform spacing of your reporting points, also inject the root points.

My Personal Open Source Structural Applications:
https://github.com/buddyd16/Structural-Engineering

Open Source Structural GitHub Group:
https://github.com/open-struct-engineer

RE: Learning Programming for Structural Engineering

Sub division would be import if you are planning on performing a natural frequency, transient and non-linear analysis. Even if you are applying loading based on piece-wise functions, you can attain a solution using Laplace transforms coupled coupled with a coarse stiffness matrix...


@Captian_slow, I completely agree with you... Everything has it's place for a particular task. I've actually seen some engineers spending an entire day doing FFT on excel, when you could do something like that in a few lines of code of the right language.

It is good practice to research the tools available before just jumping in and developing something.

RE: Learning Programming for Structural Engineering

Curious - When using Octave are you creating programs with their owner GUI and report. Or do you use it more like MathCAD where you are more or less printing the code?
Thanks.

EIT
www.HowToEngineer.com

RE: Learning Programming for Structural Engineering

@RFreund

I have not used MathCad, however it seems to be a completely different animal to Octave.

I have not really bothered with GUI's when developing programs. By reports I assume that you mean an actual written aspect showing equations, results and discussion which is the output? If so, I don't, it seems that MathCad has a nice interface for that and the newer version of Matlab have incorporated that aspect.

I generally have graphs which are developed which I then paste into my design reports, as the reports will cover information from a number of places.

In cases where my code is used by a few people in the office, I generally have a manual for it's operation as it may be a bit confusing entering information within the code itself. It's a poor way to do things though, I wish I had the time for GUI's.

RE: Learning Programming for Structural Engineering

@Mohanlal - Got it thanks.

Yes MathCAD / SMath are more WYSIWYG math programs. Although I see it being somewhat similar to Matlab. Basically the format is:
Enter input values
Do some work (some of which is shown some can be hidden)
Output results - includes graphs, checks, etc.

I believe I have seen python use in this sense to a degree and maybe Octave could be similar. I've always wanted to invest more time into more a more 'robust' programming language with the ultimate goal of making solid GUI's for the different programs, but as you've said, time...

EIT
www.HowToEngineer.com

RE: Learning Programming for Structural Engineering

@RFreund

You may be able to achieve what you are looking for on Mathematica, with greater ease compared to other languages.

I only use it in my initial stages of development to check the solutions for complex equations and the feasibility of a proposed concept that I am developing.

You can basically create a CDF file, which is essentially a PDF with the mathematical knowledge of what you have coded, it will allow you to change values using slide bars and recalculate solutions. I think it would also change graphs and so forth in real time.

What is nice is that you can have a layout with full text and images like a word document and the code is locked so no one can tamper with it...

RE: Learning Programming for Structural Engineering

@Celt83,

Finite element modelling is not the same as coming up with a closed-form piece-wise solution, there are too many moving pieces to just say it's the same thing.

Small number of nodes introduces error through inadequate discretisation of uniform loads, not through "lower accuracy" of resolving the elements themselves. The elements are always accurately resolved because their stiffness matrices are based on closed-form solutions. It's the loads that end up being wrong.



RE: Learning Programming for Structural Engineering

Captain_slow,

You don't need to discretize a uniform load nor a beam element though all you need are the fixed end reactions.

The closed for solution is of a specific bar/beam element not the structure as a whole. The stiffness method specifically solves for the joint actions under the equilibrium and compatibility constraints imposed by the supports and members. Once you have the joint actions you can directly solve for the forces at the joints. With the joint forces using superposition you can then look at each element individually as a single span beam with applied end forces and displacements and using the closed form solutions for the beam elements determine the max and min internal actions without needing to subdivide the element. There are cases where subdivision is more efficient/required as Mohanlal0488 pointed out.

My Personal Open Source Structural Applications:
https://github.com/buddyd16/Structural-Engineering

Open Source Structural GitHub Group:
https://github.com/open-struct-engineer

RE: Learning Programming for Structural Engineering

@ Celt83,

Let's double down and make sure we are not talking about different things.

Say you have a UDL load on a beam. How would you say the process of resolving it using FEA goes?

What I am saying is that step 1 is to discretise the UDL load into a series of point loads applied at beam nodes. Are you saying that there is no need to discretise the UDL load and that it can be just directly applied to the beam element?

RE: Learning Programming for Structural Engineering

Quote (captain_slow)


Say you have a UDL load on a beam. How would you say the process of resolving it using FEA goes?

For a single span beam I wouldn't use FEA, if your talking a continuous beam first find the fixed end reactions and combine them at the joints then the general formula becomes {F}-{F,fixed}=[K]{D}

Quote (captain_slow)

Are you saying that there is no need to discretise the UDL load and that it can be just directly applied to the beam element?

Yes, for beam elements there are closed form solutions for the internal actions.

My Personal Open Source Structural Applications:
https://github.com/buddyd16/Structural-Engineering

Open Source Structural GitHub Group:
https://github.com/open-struct-engineer

RE: Learning Programming for Structural Engineering

For the FEM toolbox I developed, the UDL is taken as is, and the end conditions between nodes are calculated as if the element is fixed. The end conditions are then used to develop the lead vector. Obviously this formulation requires some changes when allowing releases at beam ends.



RE: Learning Programming for Structural Engineering

@Celt83,

OK I think I know what we are talking here then.

Yes I agree that there is a heap of closed-form solutions out there that can be used to solve a lot of this stuff. I am sure we all have our spreadsheets with several implementations of these things.

I am talking more from the angle of building a general-purpose FEA program - the program first determines where the hard nodes are, then it discretises the continuum (whether it be a beam, plate, or a brick elements), then it discretises any continuous conditions (such as loads, restraints, etc), and then it goes about assembling/solving/post-processing.

RE: Learning Programming for Structural Engineering

I have done some quite simple (but useful) spreadsheets which I occasionally use in design, but I have never attempted anything involving a stiffness matrix analysis, although I have always wondered how matrix analysis can be handled in a spreadsheet. How does one go about doing a full stiffness analysis of any structure in a spreadsheet?
I hope I am not going off in a tangent, but would anyone like to comment on this.

RE: Learning Programming for Structural Engineering

@civeng80

You could do it on excel with some help of vba, there are some built in matrix manipulation tools also. But it goes back to the earlier comments, why would you want to do it on excel? It's a crappy tool for the task. I would use excel just as an interface to develop text files for connectivity and element data that can be printed to a txt file and read by a superior language.

My approach using excel would be to have a worksheet that allows one to enter node coordinates and elements which can be read by various vba routines that do the complexities involved.

RE: Learning Programming for Structural Engineering

Personally I think one of the best ever was MS Visual Basic 6, from which sprang VBA. And VB6 does not not have to sit inside an Excel can and it is relatively easy to interface the two if required. MS mutated it into into VB.Net and deprecated it so MS could enslave us with 99% unwanted web apps baggage. But MS knows that plain old VB6 is still a great general purpose language, because even after having been deprecated to near non-existence, they still refuse to release the source code. They can't take the risk of it being updated by others and kicking them in the "ask". Even after all that and and being nearly 30 yrs old, VB6 is still is the 20th most popular programing language in the coding world. MS, release the source code! Use it, or set it free!

Reality used to affect the way we thought. Now we somehow believe that what we think affects reality.

RE: Learning Programming for Structural Engineering

"For my work and personal FEA programming purposes I use Octave which is basically the same as Matlab just a freeware version"

I use Octave also. Matlab is too expensive unless one really needs it. Octave is very similar for most tasks.

The downside to Octave is that it is different enough from Matlab that Matlab examples are often not helpful, and the number of Octave examples is very limited. For example, formatting figures is completely different and there's little help online. You just have to play with it -- sometimes for a long time -- to figure out how to do something simple.

RE: Learning Programming for Structural Engineering

Spreadsheet has a function for solving the determinant of a matrix. Have used it before to solve simple problems.

RE: Learning Programming for Structural Engineering

civeng80, r13, Mohanlal0488 and rest of all you structural-Excel guys. This is where you need to look. Did you not see it above?
https://newtonexcelbach.com/2016/12/09/3d-frames-a...

Reality used to affect the way we thought. Now we somehow believe that what we think affects reality.

RE: Learning Programming for Structural Engineering

@-Fourteen

Thanks, but I am not an excel guy. I use Octave...

RE: Learning Programming for Structural Engineering

Sorry. I see that now.

Reality used to affect the way we thought. Now we somehow believe that what we think affects reality.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

White Paper - Reshoring Prototyping and Production
In this whitepaper, we'll provide insight into why and when it makes sense for U.S. manufacturers to reshore prototyping and production, and how companies can leverage the benefits of working with local design, prototype, and manufacturing partners during the pandemic and beyond. Download Now
Engineering Report - Top 10 Defect Types in Production
This 22-page report from Instrumental identifies the most common production defect types discovered in 2020, showcases trends from 2019 to 2020, and provides insights on how to prevent potential downtime in 2021. Unlike other methods, Instrumental drives correlations between a variety of data sources to help engineers find and fix root causes. Download Now
White Paper - Addressing Tooling and Casting Requirements at the Design Stage
Several of the tooling and casting requirements of a part can be addressed at the design stage. If these requirements are not addressed at the design stage, lot of time is spent in design iteration when the design reaches the die caster. These design issues lead to increase in time and cost of production leading to delay in time to market and reduced profits for the organization. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close