-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Model.py
89 lines (75 loc) · 2.51 KB
/
Model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from IdState import IdState
from Calculation import Calculation
from BeamElement import BeamElement
from Point import Point
from MatrixUtil import *
from TestFrame import *
class Model:
def __init__(self):
self.elementList = []
self.idState = IdState()
self.setPointState = False
self.responseText = "Welcome to BMUS. Press 'p' to enter set point mode, 'f' to enter set force mode and 'b' to set boundrys."
def setPoint(self, x, y):
self.responseText = "Mode: set new start point"
pointB = Point(x, y, self.idState.getPointId())
if self.setPointState and (0 != len(self.elementList)):
self.responseText = "Mode: set continuation point"
pointA = self.elementList.pop()
beamElement = BeamElement(pointA, pointB, self.idState.getBeamId())
self.elementList.append(beamElement)
self.elementList.append(pointA)
self.elementList.append(pointB)
self.setPointState = True
def endPoint(self):
self.setPointState = False
def setForce(self):
self.responseText = "Mode: set force"
def setFixture(self):
self.responseText = "Mode: set boundry"
def drawElementList(self, canv):
for element in self.elementList:
element.draw(canv)
return canv
def newCalculation(self):
newCalculation = Calculation(self.calculateIEG(), self.getBeamList(), self.calculateNumVert())
#TODO: Get force vector from user adn number of iterations from user..
newCalculation.setForceVector(self.getForceVector())
newCalculation.calculateDisplacementVector(200)
print "Stivhetsmatrise:"
printC(newCalculation.K)
print "Forskyvningsvektor:"
print newCalculation.displacementVector
print "Belastningsvektor:"
print newCalculation.forceVector
def calculateIEG(self):
IEG = []
for element in self.elementList:
if element.Type == 'b':
IEG.append([element.start.ID, element.end.ID])
return IEG
def calculateNumVert(self):
numVert = 0
for element in self.elementList:
if element.Type == 'p':
numVert += 1
return numVert
def getBeamList(self):
beamList = []
for element in self.elementList:
if element.Type == 'b':
#TODO: User set properties.
element.setPhysicalProperties(1, 1, 1)
beamList.append(element)
return beamList
def getForceVector(self):
localForceVectors = []
for element in self.elementList:
if element.Type == 'p':
localForceVectors.append(element.forceVector)
return appendLists(localForceVectors)
def printElementListId(self):
liste = []
for element in self.elementList:
liste.append(element.getIdType())
print liste