Example:Example Quad4i 02

From Nemesis
Jump to: navigation, search
# /******************************************************************************
# *   nemesis. an experimental finite element code.                             *
# *   Copyright (C) 2004-2008 F.E.Karaoulanis [http://www.nemesis-project.org]  *
# *                                                                             *
# *   This program is free software; you can redistribute it and/or modify      *
# *   it under the terms of the GNU General Public License version 3, as        *
# *   published by the Free Software Foundation.                                *
# *                                                                             *
# *   This program is distributed in the hope that it will be useful,           *
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of            *
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
# *   GNU General Public License for more details.                              *
# *                                                                             *
# *   You should have received a copy of the GNU General Public License         *
# *   along with this program.  If not, see <http://www.gnu.org/licenses/>.     *
# ******************************************************************************/

# //*****************************************************************************
# // $LastChangedDate$
# // $LastChangedRevision$
# // $LastChangedBy$
# // $HeadURL$
# // Author(s): F.E. Karaoulanis (fkar@nemesis-project.org)
# //*****************************************************************************

# Data
nds={1:[0.0, 0.0],
     2:[9.0, 0.0],
     3:[8.0, 8.0],
     4:[0.0, 6.0],
     5:[2.5, 2.0],
     6:[6.5, 1.5],
     7:[5.5, 5.0],
     8:[2.5, 5.0]}
ax=[ 0.0001, 0.0061, 0.0049]
ay=[-0.0005, 0.0042, 0.0038]

# domain
domain.planeStrain(1.0)

# database
name="vtk"
db.SQLite(name)

# material
material.elastic( 1, 1000., 0.25)

# nodes
for i in nds:
	node.add( i, nds[i][0], nds[i][1])

# elements
element.quad4i( 1, 1, 2, 6, 5, 1)
element.quad4i( 2, 2, 3, 7, 6, 1)
element.quad4i( 3, 8, 7, 3, 4, 1)
element.quad4i( 4, 1, 5, 8, 4, 1)
element.quad4i( 5, 5, 6, 7, 8, 1)

# constraints
for i in [1,2,3,4]:
	x=nds[i][0]
	y=nds[i][1]
	ux=ax[0]+ax[1]*x+ax[2]*y
	uy=ay[0]+ay[1]*x+ay[2]*y
	node.fix(i,1,ux)
	node.fix(i,2,uy)

# loadcase (empty)
lc.define(1)

# analysis
analysis.static()
imposer.lagrange()
analysis.run(1,1)

# results
print '================================================='
print '|   |     Analytical      |     Numerical       |'
print '+---+----------+----------+----------+----------+'
print '|id |ux        |uy        |ux        |uy        |'
print '+---+----------+----------+----------+----------+'
for i in [5,6,7,8]:
	x=nds[i][0]
	y=nds[i][1]
	uxA=ax[0]+ax[1]*x+ax[2]*y
	uyA=ay[0]+ay[1]*x+ay[2]*y
	uxN=node.data(i)['disp'][0]
	uyN=node.data(i)['disp'][1]
	print '| %2i| % 8.6f| % 8.6f| % 8.6f| % 8.6f|'%(i,uxA,uyA,uxN,uyN)
print '================================================='

# store to database
db.store(name)
db.exportToVtk(name)
Personal tools