Euler-Bernoulli Beam Element - Coding in Python

Поделиться
HTML-код
  • Опубликовано: 26 авг 2024

Комментарии • 49

  • @user-fq2nd8nw6f
    @user-fq2nd8nw6f 4 года назад +3

    thank you freeball. your work is very clearly explained. I'm coding something similar and this has been great help pointing me in the right direction

  • @alexander.ramos.94
    @alexander.ramos.94 6 лет назад +1

    So useful, im working in my thesis degree about aeroelasticity, and with this explanation of the structural model will help me a lot, im trying to go further more and implement deflections of the cross section with shape and expansion functions in the formulation of FEM, it will be interesting if you know about interpolation of meshes which don't coincide the location of each node of each meshes, keep doing this kind of work. Best regards

  • @longcheng8573
    @longcheng8573 7 лет назад

    This type of video for finite element analysis is very useful, thank you very much

  • @Gandalfablon
    @Gandalfablon 7 лет назад

    Thanks for the video!
    I'm trying to solve a problem of heat exchanger. Mechanical engineering.

  • @jpa_fasty3997
    @jpa_fasty3997 5 месяцев назад

    Great video but what did that keyboard ever do to you?

    • @Freeball99
      @Freeball99  4 месяца назад

      Keyboard is fine, but the kids are a problem! No, not really...sensitive mic which was sitting on my desk in combination with a tactile keyboard. I now have a shock mount for the mic which keep it happier-sounding.

  • @sebastianmanco5072
    @sebastianmanco5072 6 лет назад +4

    Hello, can you help me as I can find deflections with this method by programming it directly from python

    • @Freeball99
      @Freeball99  6 лет назад +3

      To find deflections, you are just solving the static problem {F} = [K]{x} for {x}. So, you find the deflection, {x} = inverse([K]).{F}
      So, all you need to do is: 1) Find the [K] matrix as in the video. 2) Find the inverse of [K]. and 3) Multiply this by the force vector, {F}.
      In order for find the inverse of a matrix, first include the following at the top of the code: from scipy.linalg import inv then you can use: inv(K)

    • @zschramm
      @zschramm 4 года назад

      @@Freeball99 Do you have any suggestions for help on assembling the force vector. I have watched a bunch of different videos and done some reading, but am still not clear.
      I am using this element force vector to apply self weight:
      q = -rho * A * g # distributed force (self weight)
      f_dist = np.array([-q*l/2, -q*l*l/12, -q*l/2, q*l*l/12])
      Then similar to your other global matrix generations I use:
      F_temp = np.zeros(2*num_elems+2)
      F_temp[2*i:2*i+4] = f_dist
      F += F_temp
      And then removing fixed DOF
      F = np.delete(F, dof, axis=0)
      Solving for displacements
      U = np.matmul(inv(K),F)
      I think my issue is in the removal of the DOF perhaps, but I am maybe shaky on concepts is perhaps the issue ;)

    • @zschramm
      @zschramm 4 года назад +1

      Figured out my stupid mistake. Had a (-) in the q and in the element force, matches standard FEA code now. Thanks.

  • @alexanderpal6425
    @alexanderpal6425 7 лет назад

    Perfect content, exactly what I was searching for.
    Hope you will answer me. What are benefits in learning python for civil engineers, in your opinion? Is it a plus for an employer, or maybe it will simplify civil engineer's work?

    • @Freeball99
      @Freeball99  7 лет назад +3

      Python should be considered to be a tool for the engineer. I don't think it is necessarily a plus for an employer because, as a civil engineer, you will likely use commercial software packages when analyzing problems, but it is certainly useful for preliminary analysis on many problems - including homework problems for engineering students. You should think of it perhaps as a very advanced scientific calculator.
      One of the knocks on Python is that it runs relatively slowly when compared with other (especially compiled) languages. However, its true speed is in the short time it typically takes to deploy (write & debug) a piece of code to solve a problem which adds to one's understanding of the problem being tackled - and for many things it is more than fast enough (as demonstrated in the video). I have some colleagues that have written fairly sizable finite element codes using Python and it has performed pretty well in terms of its speed. Add to that the fact that some of the more computationally expensive routines can be coded in C++ or FORTRAN which results in a huge performance boost.
      So while, as a civil engineer, knowledge of Python may not look like a particularly big plus to an employer on your resume, it will certainly impress an employer when you are able to produce preliminary results in a very short time. This, in the long run, allows you to work more effectively and efficiently on a given problem because it gives you insights to benchmark your results against.

    • @alexanderpal6425
      @alexanderpal6425 7 лет назад +1

      Freeball Thank you for your answer. I will take into account it and study python.
      It's strange that you don't have a lot of subscribers)

    • @Freeball99
      @Freeball99  7 лет назад +2

      If you are planning on learning Python, the following might be useful/interesting for you to know:
      1. Python was invented by Guido van Rossum, who for many years, and until recently, worked at Google. Consequently, it is used extensively in many applications at Google and, as such, Google has put out a lot lot of training videos (on RUclips). These are a good place to start. Google has, more recently, invented the language Go (often called 'Golang') which is a much faster, compiled language.
      2. In addition to the Google training videos, there are several other RUclips videos which give anything for a general overview of coding in Python to the solving of more specific problems - though, from my perspective, a noticeable lack of videos demonstrating finite element modeling which yours truly has attempted to begin remediating.
      3. Python was used to build the original Google search engine stack though this has since been replaced by compiled code. The RUclips front-end was also coded using Python.
      4. Other well-known web sites built using Python include: Reddit, Dropbox, Pinterest, Instagram, Bitbucket, Yahoo Maps, Spotify, Quora. Most of these use a Python framework called Django which makes it a breeze to built web applications.
      5. Python has a HUGE support community behind it. Almost everything you'll want to do with it has either been demonstrated or has a library built for it. It's rare that you will have to build something completely from scratch...and if you do, there are plenty of forums where you can seek help.
      6. Python seems to be gathering a life of its own amongst the artificial intelligence community (including machine learning, robotics and the like). Google has recently released a library called TensorFlow which makes this extremely useful and computationally efficient.
      7. Some additional Python libraries that you might want to explore as an engineer include Numpy and SciPy for all numerical processing (basically a substitute for MATLAB and the language R), Pandas (which is like Excel on steroids and can be used to import and handle spreadsheets), Matplotlib (a graphing/charting library).

  • @rohit-hu1qk
    @rohit-hu1qk 2 года назад

    sir,
    why the restrained dof is not arranged as serial numbers like 0, 1, 2, 3.
    How this minus sign comes in restrained Dof [0, 1, -2, -1] .
    how would python know that -2 means the restrained dof of a vertical support reaction on the right-hand side?
    thankyou sir.

    • @Freeball99
      @Freeball99  2 года назад +1

      This has to do with the way python indexes lists. A positive number refers to the start of the list (0, 1, 2...) while a negative number refers to the end of the list (-1, -2, ...).
      If you look at how the degrees of freedom are numbered, the last dof is a rotation while the 2nd last is a vertical displacement. Since we want to eliminate the 2nd last dof, I refer to the restrained dof as -2 - ie the second last element..

  • @josemascarenhaslneto7166
    @josemascarenhaslneto7166 Год назад

    Q: can I use this code to determine the others natural frequencies? specially the second one from the cantilever beam. I'm trying to but I get the same results as the first frequency

    • @Freeball99
      @Freeball99  Год назад

      You could use this, but it would be pretty tedious. You'd have to run experiments at different frequencies and monitor the results.
      It would be better to first convert the equations into the frequency domain (I realize I haven't shown this in any videos - probably time to make one on this topic).

  • @astyanaxfromdownunder1225
    @astyanaxfromdownunder1225 4 года назад

    Question: Hello, Your lectures and code are excellent and provide clear explanations of complex phenomena.
    I have a related question about this topic and would be grateful if you can provide an explanation with your usual clarity.
    Specifically I am interested in transverse vibration of bars but find it difficult to understand the physical interpretation of, particularly, rotary inertia (old texts refer to it is rotatory inertia) and shear when bars are not slender or on slender bars for the frequency of the higher overtones. Classic texts provide mathematical corrections for the effects, but don't explain their physical origin. Are you able to assist?

    • @Freeball99
      @Freeball99  4 года назад +1

      You ask a very good question and it's unlikely that I can answer it using this messaging system. It will require a video but I have waited on doing it because it really falls outside the scope of what would be considered "Introductory". You are correct that when considering shearing effects (Timoshenko Beam Theory) the rotatory inertia inertia becomes important. This becomes an issue in stubby beams as you have indicated and also in the analysis of anisotropic materials such as composites. Textbooks can be pricy and often not particularly detailed. Most good PhD dissertations in these areas ought to have a good write-up on the derivations of the equations of motion for these. Might be available online or at a an engineering library, if you're attached to a university.
      You can start by searching "Timoshenko Beam Theory". As an example, here is a Wikipedia article though it's definitely not the best write-up I've seen on the subject: en.wikipedia.org/wiki/Timoshenko_beam_theory

    • @astyanaxfromdownunder1225
      @astyanaxfromdownunder1225 4 года назад

      @@Freeball99 Many thanks for taking the time to reply. Keep up the great work! It would be a great contribution if you were able to make a video at some point as that would be a great contribution, unfortunately the concept is complex but if well understood has potential for application (determination of anisotropy, shear, poisson's-ratio....). My interest is in wood, it is certainly non-homogeneous, but it is good to start with simple assumptions. The Euler-Bernoulli system is not trivial to understand either but it is great (relatively simple). Thank you for the link, and any suggestions you may have for good PhD dissertations. (Incidentally Timoshenko's classic paper and others, on the corrections is totally beyond me).

  • @arsgorrussia477
    @arsgorrussia477 5 лет назад

    Great lesson, but i don't understand one thing. Why don't you include boundary conditions for the shear force and bending moment at the ends of the beam into stiffnes matrix?

    • @Freeball99
      @Freeball99  5 лет назад

      For the purpose of finite element modeling, the GEOMETRIC boundary conditions are applied by eliminating the rows and columns corresponding to those degrees of freedom from the mass and stiffness matrices.
      The boundary conditions that you have described (ie the applied forces and moments) are incorporated into the equations of motion by including them in the forcing function.

  • @rakshitselot4656
    @rakshitselot4656 5 лет назад +1

    thanks for the video sir < ...i just change the degree of freedom locations( in the matrix) i.e the v1,v2,theta1,theta2 instead of v1,theta1,v2,theta2 (like u did ) , but results r not coming..only the first value of frequency is matching ..further it converges to 1...

    • @Freeball99
      @Freeball99  5 лет назад

      Sounds to me like you have the coordinates in different positions, but you are using my same K and M matrices. This will surely give you incorrect results. You will first need to re-arrange my matrices (or re-derive them) to ensure that the correct values in your matrices are multiplying the correct coordinates.
      Doing things your way makes it much more difficult (in my opinion) to assemble your global mass and stiffness matrices. It can be done, but gives much more opportunities for mistakes.
      My advice? DON'T DO IT. Group the coordinates for each node together (i.e. all your node1 coordinates, then all your node2 coordinates, etc.) AND keep these in the same order for each node.

    • @rakshitselot4656
      @rakshitselot4656 5 лет назад

      @@Freeball99 thankyou sir

  • @jasonstark9787
    @jasonstark9787 2 года назад

    Hello sir,
    I have a k matrix of order 6*6(includes axial effects) , and while broadcasting it into K_temp (full of zeroes - 40*40 matrix) , I used "K_temp[3*i : 3*i+6, 3*i : 3*i+6] = k" .
    but it showing [ ValueError: could not broadcast input array from the shape (6,6) into shape (4,4)]

    • @Freeball99
      @Freeball99  2 года назад

      This is hard to tell without more information, but clearly Python still thinks you're dealing with a 4x4 matrix.

  • @ousmanceesay2068
    @ousmanceesay2068 2 года назад

    can I apply this code with Wilson Theta method

    • @Freeball99
      @Freeball99  2 года назад

      No. You might be able to use some of the basic code structure. But the integrator routine would have to be recoded.

  • @palashdas823
    @palashdas823 4 года назад

    sir ,what change to handle non homologous BC.say left side is fixed right is permissible 4 unit deflection

    • @Freeball99
      @Freeball99  4 года назад

      This would be a discontinuous problem. Your right boundary is free until a 4 unit deflection at which point the fixed boundary must be applied. You would have to treat each case separately. On the other hand, you might be able to approximate this boundary condition by using a spring instead. By making the spring stiff enough, you could restrict the deflection to a maximum of 4 units. It,s not exactly the same thing, but it’s continuous, simpler and might give you reasonable results.

  • @chrisheuberger87
    @chrisheuberger87 6 лет назад

    Hello, First of all I want to thank you very much for the movies on FEM, they are really helpful. I have one question. Basically, I want to model the response of a beam in the frequency domain using a transfer function: {x} = [H]{f}, where [H] = [-omega^2 * M + K]. Furthermore, I want to model this with stochastic dynamics instead of deterministic dynamics. So my force input will be a force spectrum {S_FF} and my output a response spectrum {S_xx}. Now my equations become: {S_xx} = [H] {S_FF} [H]^T. However, my problem is that my response spectrum gives me different values when I increase the number of elements and this does not show convergence. Let's say that my force spectrum only contains a moment as input at the rotation DOFs of the supports. Do you know why this could be the case? Because clearly, the eigenfrequencies converge very fast when you increase the number of elements. Kind regards, Chris

    • @Freeball99
      @Freeball99  6 лет назад

      Chris,I have never personally coded an FEM frequency response model though I have read about it plenty so I am hesitant to recommend anything that might send you down a bad path. While I am not familiar with the problem that you are experiencing, I can offer you this, however, just in terms of overall code debugging practices (assuming it is, in fact, something in the code):
      1. Unit testing - As a student, I used to ignore this until I ran into a problem, but the more time I have spent in industry, the more I have begun to appreciate that this is part of the coding process. The idea here is to create a suite/series of simple tests that test various assertions about the routines that you have coded. Make sure that the various routines you have coded are giving you the results that you expect from them. This is especially true for routines that you have downloaded from a library or codebase somewhere. Don't ever assume that some so-called expert's routine is correct - check it!
      2 - Sample Problems - Find a worked problem of the type that you are trying to model. Chances are that a paper or a textbook somewhere has a sample problem of the type you are coding (preferably one that shows step-by-step results).
      Sorry I can't be of more help here.
      Andy

  • @vineeth9295
    @vineeth9295 2 года назад

    Thank you for the explanation. Is it possible to model this behavior in 2D ?

    • @Andy-hy8px
      @Andy-hy8px 2 года назад

      Yes, you certainly can model it in 2D. I have shown it in this video for a truss (ruclips.net/video/WpBj34r4ySE/видео.html). Take a look at the way I treated the stiffness matrix. Note, however, that I did NOT treat the mass matrix correctly. Will have to create a new video for this.

  • @guilhermewagner4579
    @guilhermewagner4579 3 года назад

    im having some syntax errors using pyton 3 from Anaconda,im pretty noob on programing,can you help me?

    • @Freeball99
      @Freeball99  3 года назад

      This code was written in Python2, but I'm pretty sure the only issue will be with the PRINT statements. In each case, you just need to wrap the argument in brackets. So, Print 'Hello' becomes print ('Hello')

  • @iKrakin
    @iKrakin 4 года назад

    Hey freeball , i am working on a cantilever beam and i have finished coding and deflections i am getting are very accurate .so i was hoping can you make a video on how i can use simulation using python to show the deflection just like Ansys does. I hope you understand what i am trying to say.🙏🙏

    • @Freeball99
      @Freeball99  4 года назад

      Do you possibly have a screenshot or an image I can look at?

    • @iKrakin
      @iKrakin 4 года назад

      @@Freeball99 i have code here github.com/gen1ze/finiteelement/blob/master/1d_beam_element_with_only_uniformly_distributed_load(1).py

    • @iKrakin
      @iKrakin 4 года назад

      @@Freeball99 s.amsu.ng/80j0aZFJfniN

    • @Freeball99
      @Freeball99  4 года назад

      @@iKrakin So you're trying to plot it in Matplotlib and it's not working? What is the issue you're having?

    • @iKrakin
      @iKrakin 4 года назад

      @@Freeball99 no thats not the problem.I want to create an animation of beam bending