zhuminjie / OpenSeesPy

OpenSeesPy versions, doc, and pip
Other
157 stars 66 forks source link

Need an explanation about plotting -> I must not use Matplotlib #134

Closed petrasvestartas closed 1 month ago

petrasvestartas commented 1 month ago

I am running a simple cantilever example. OpenSeesPy use Matplotlib for visualization, opsvis. Which I cannot use.

Can you provide an explanation how to output raw geometry (e.g. xyz coordinates) and values for visualization?

This is my working sample which I am trying to transfer to CAD program:

Screenshot 2024-05-08 121041

#! python 3
# r: openseespy

import openseespy.opensees as ops

#########################################################################
# Definition Units
#########################################################################

# Basic Units
m = 1.0
N = 1.0
sec = 1.0

# Length
mm = m / 1000.0
cm = m / 100.0
inch = 25.4 * mm
ft = 12 * inch

# Forcec
kN = 1000 * N
kips = kN * 4.448221615
lb = kips / 1.0e3

# Stress ( kN/m2 or kPa )
Pa = N / ( m ** 2 )
kPa = Pa * 1.0e3
MPa = Pa * 1.0e6
GPa = Pa * 1.0e9
ksi = 6.8947573 * MPa
psi = 1e-3 * ksi

# Mass - Weight
tonne = kN * sec ** 2 / m
kg = N * sec ** 2 / m
lb = psi*inch**2

# Gravitational acceleration
g = 9.81 * m/sec**2

# Time
min = 60 * sec
hr = 60 * min

#########################################################################
# Definition Parameters
#########################################################################

L = 3 * m
E = 200 * GPa
A = 23.32 * cm ** 2
I = 4250 * cm ** 4
P = 200 * kN

#########################################################################
# Problem Definition
#########################################################################

ops.wipe()
ops.model('basic', '-ndm', 2, '-ndf', 3)

ops.node(1, 0, 0)
ops.node(2, L, 0)

transfType = 'Linear'
transfTag = 1
ops.geomTransf(transfType, transfTag)

ele_Tag = 1
ops.element('elasticBeamColumn', ele_Tag, *(1, 2), A, E, I, transfTag) 
ops.fix(1, 1, 1, 1)

#########################################################################
# Vizualization of Model
#########################################################################

# not translatable because of matplotlib dependency

#########################################################################
# Analysis
#########################################################################

# Gravity pattern and Analysis
# Create a Plain load pattern with a Linear TimeSeries
ops.timeSeries('Linear', 1)
ops.pattern('Plain', 1, 1)

# Create nodal laods at nodes
ops.load(2, 0, -1*P, 0)
nSteps = 100
Oflag = 0

# Wipe any previous analysis object
ops.wipeAnalysis()

# Set analysis parameters
# Convergence Test -- determines when convergence has been achieved.
tol = 1.0e-6 # Tolerance
iterMax = 50 # Max number of iterations
pFlag = 0 # Optional print flag (default is 0), Valid options: 0-2
nType = 2 # Optional type of norm (default is 2). Valid options: 0-2
ops.test('NormDispIncr', tol, iterMax, pFlag, nType)

# SolutionAlgorithm - determines the sequence of steps taken to solve the non-linear equation at the current time step
ops.algorithm('KrylovNewton')

# DOF_Numberer - determines the mapping between equation members and deegrees of freedom
ops.numberer('RCM')

# SystemofEqn/Solve - within the solution algorithm, it specifies how to store and solve the system of equations in the analysis
ops.system('BandGeneral')

# Constrains handler: determines how the constraint equations are enforced in the analysis - how it handles the boundary conditions / imposed displacments
ops.constraints('Transformation')

# Intergrator - determines the predictive step for time t+dt
dLambda = 1/nSteps # the load factor increment
ops.integrator('LoadControl', dLambda)

# AnalysisType - defines what type of analysis is to be performed ('Static, 'Tansient', etc.)
ops.analysis('Static')

# Perform analysis
ops.analyze(int(nSteps))

# Maintain constant gravity loads and reset time to zero
ops.loadConst('-time', 0.0)
mhscott commented 1 month ago

You can use commands like ops.getNodeTags() and ops.nodeCoord() to dump model data:

https://portwooddigital.com/2022/09/25/opensees-to-json/

petrasvestartas commented 1 month ago

@mhscott and how do you achieve deformation since these are node coordinates only?

This is the case for 3 nodes:

image

mhscott commented 1 month ago

Use the commands listed here: https://openseespydoc.readthedocs.io/en/latest/src/outputcmds.html

petrasvestartas commented 1 month ago

Thank you for the reference.

Could you please provide an example that outputs coordinates for such deformed shapes? It is my first day using OpenSees...

mhscott commented 1 month ago

No, sorry, I don't have such an example.