Feap installation with visual studio

If you ever require a FEM system for quick fem for educational or research purpose. Feap is one of the easiest to get started with.

Here’s a rundown with screenshots on how to build it with visual studio with Intel Fortran.

Hope this helps.

Step 0:

Download from:

http://projects.ce.berkeley.edu/feap/feappv/feappv41.zip

Project Page:

http://projects.ce.berkeley.edu/feap/feappv/

Two steps

  1. Build a library
  2. Build the program
  1. Select New Project

  1. Select New Project
    1. Select Library: Select Static Library
    2. Name library e.g. lib22

  1. Under the Projects tab select Add Existing Item
    1. Add all subroutines in directories: Elements, Plot, Program, User, and Windows (do not include Unix, Include, or Main).

Under the Projects tab select Properties

Select Fortran then General

b.) Set additional include path to point to the feappv include

directory (e.g. c:\users\xxx\feappv\ver22\include) and the appropriate

    directory for 32-bit or 64-bit pointers (e.g.

    c:\users\xxx\feappv\ver22\include\integer4 or

    c:\users\xxx\feappv\ver22\include\integer8)

Build library

Building the Main program

Open Visual Studio or if open new project

a.) Select QuickWin Application, select QuickWin option

(not standard graphics QuickWin)

b.) Name main program e.g. feappv

At top select Release build (as opposed to Debug)

3. Under the Projects tab select Add Existing Item

a.) Set show all files in window and add library (e.g. lib22)

Visual Studio normally places this in

c:\users\xxx\documents\visual studio\projects\lib22\lib22\release

b.) Add feappv.f from the subdirectory Main.

4. Under the Projects tab select Properties

a.) Select Fortran then General

b.) Set additional include path to point to the feappv include

directory (e.g. c:\users\xxx\feappv\ver22\include) and the appropriate

    directory for 32-bit or 64-bit pointers (e.g.

    c:\users\xxx\feappv\ver22\include\integer4 or

    c:\users\xxx\feappv\ver22\include\integer8)

Add the libraries and the library path

Build… If you get error like this, you have not included all forttan file sin the liberay include and come pback..



Advertisements

Updated Binary STL File Reader

bent_plate

A recent comment on the post titled binary stl file reader in numpy prompted me to revisit the code and while I was looking at it , I updated the same for code to view the loaded stl file.

The above picture shows the result.

The code as usual available on github from here

from binarySTLreader import BinarySTL,ShowSTLFile
h,p,n,v1,v2,v3=BinarySTL('bent_plate.stl')
ShowSTLFile(v1,v2,v3)

OD Command in Windows with Python

I have seen OD command for last two years but had never bothered to look it up. It always remained under the surface.

Life went on well without it, until now.

During a recent debugging crisis, had to resort to this command for an efficient way to check binary results. All the while had to go to Linux and copy the files. This is when I knew I have to see what this OD is?

OD is octal dump. Simple functionality, don’t know if there is a windows equivalent. So before searching for a windows equivalent, I knew I can replicate this in python and here’s my first attempt.

Works for me and suits my requirement. Not an entire mimic of actual OD command but if you are looking for long and double precision values, this does the job.

I have kept the command line arguments similar to the actual OD command. Here’s a simple demo.

As always, the code is available from my github repo here. Hope to add more functionality as and when I get more time. Please free to fork and play around.

Special thanks to Andy for introducing the command and helping me make sense of the important arguments.

Quick Gantt Chart with Matplotlib

ProjectPlan_GANTT_CHart_MatplotlibThe problem: You need a quick Gantt chart for a quick proposal report and you dint have any project planner software installed.

Solution:

While there are many different ways, you only have access to python, well Here’s a simple Gantt chart plotter with just matplotlib.

Not for rigorous use but a good substitute to make quick Gantt plot for quick report.

Continue reading

Quick Intro to 2D and 3D Visualization in Python

contour_visualization_with_python
Posted a quick tutorial introducing visualization in python.

This tutorial offers a quick look at some common 2d and 3d Visualization available in python. This tutorial is meant to give anyone a quick start in matplotlib and mayavi.mlab.

The tutorial was written as part of CSRP program of AeSIAA which I am volunteering as a mentor to few aeronautical students.

View the tutorial by clicking this Quick Intro to 2D and 3D Visualization in Python

Analysing Trusses – a python program

truss_in_python

Was digging into my laptop and found this Truss program written in python. Computes, displacement, stresses and reactions.


"""
Created on Thu May 08 07:07:24 2014

@author: Sukhbinder Singh

Truss FEM

"""
from __future__ import division
import numpy as np

modE=30.0e6
Area=2.0


#numElem=3
#numNodes=4

elemNodes=np.array([[0,1],[0,2],[0,3]])
nodeCords=np.array([[0.0,0.0],[0.0,120.0],[120.0,120.0],[120.0,0]])

#'''
elemNodes=np.array([[0,1],[0,2],[1,2],[1,3],
                    [0,3],[2,3],[2,5],[3,4],[3,5],[2,4],[4,5]])

nodeCords=np.array([
[0.0,0.0],[0.0,3000.0],
[3000.0,0.0],[3000.0,3000.0],
[6000.0,0.0],[6000.0,3000.0]
])


modE=70000
Area=300
#'''

numElem=elemNodes.shape[0]
numNodes=nodeCords.shape[0]

xx=nodeCords[:,0]
yy=nodeCords[:,1]

EA=modE*Area
tdof = 2*numNodes #total number of degrees of freedom
disps=np.zeros((tdof,1))
force=np.zeros((tdof,1))
sigma=np.zeros((numElem,1))
stiffness=np.zeros((tdof,tdof))
np.set_printoptions(precision=3)

'''
force[1]=-10000.0
presDof=np.arange(2,9)

'''
force[3]=-50000.0
force[7]=-100000.0
force[11]=-50000.0

presDof=np.array([0,1,9])
#'''

for e in xrange(numElem):
    indice= elemNodes[e,:]
    elemDof=np.array([indice[0]*2, indice[0]*2+1, indice[1]*2, indice[1]*2+1 ])
    xa=xx[indice[1]]-xx[indice[0]]
    ya=yy[indice[1]]-yy[indice[0]]
    len_elem=np.sqrt(xa*xa+ya*ya)
    c=xa/len_elem
    s=ya/len_elem
    k1=(EA/len_elem)* np.array([[c*c,c*s,-c*c, -c*s],
                                [c*s,s*s,-c*s ,-s*s],
                                [-c*c,-c*s,c*c,c*s],
                                [-c*s,-s*s,c*s,s*s]])
    stiffness[np.ix_(elemDof,elemDof)] +=k1


actDof=np.setdiff1d(np.arange(tdof),presDof)

disp1=np.linalg.solve(stiffness[np.ix_(actDof,actDof)],force[np.ix_(actDof)]);
disps[np.ix_(actDof)]=disp1


# stresses at elements

for e in xrange(numElem):
    indice= elemNodes[e,:]
    elemDof=np.array([indice[0]*2, indice[0]*2+1, indice[1]*2, indice[1]*2+1 ])
    xa=xx[indice[1]]-xx[indice[0]]
    ya=yy[indice[1]]-yy[indice[0]]
    len_elem=np.sqrt(xa*xa+ya*ya)
    c=xa/len_elem
    s=ya/len_elem
    sigma[e] = (modE/len_elem) * np.dot(np.array([-c,-s,c,s]),disps[np.ix_(elemDof)])

        
print disps
print sigma

react = np.dot(stiffness,disps)
print react.reshape((numNodes,2))