File: GridConnection_Spring.py

package info (click to toggle)
yade 2025.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,308 kB
  • sloc: cpp: 93,298; python: 50,409; sh: 577; makefile: 162
file content (100 lines) | stat: -rw-r--r-- 2,891 bytes parent folder | download | duplicates (2)
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
90
91
92
93
94
95
96
97
98
99
100
# -*- encoding=utf-8 -*-
#--- bruno.chareyre@grenoble-inp.fr ---

# Experiment beam-like behaviour with chained cylinders + CohFrict connexions

from yade.gridpfacet import *

young = 1.0e10
poisson = 4
density = 2.60e3
frictionAngle = radians(30)
O.materials.append(
        CohFrictMat(
                young=young,
                poisson=poisson,
                density=density,
                frictionAngle=frictionAngle,
                normalCohesion=1e13,
                shearCohesion=1e13,
                momentRotationLaw=True,
                label='mat'
        )
)

O.engines = [
        ForceResetter(),
        InsertionSortCollider([
                Bo1_Sphere_Aabb(),
                Bo1_GridConnection_Aabb(),
        ]),
        InteractionLoop(
                # Geometric interactions
                [
                        Ig2_GridNode_GridNode_GridNodeGeom6D(),
                        Ig2_Sphere_GridConnection_ScGridCoGeom(),  # used for the cohesive sphere-cylinder interaction
                ],
                [
                        # Interaction phusics
                        Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True, setCohesionOnNewContacts=True),
                ],
                # Interaction law
                [
                        Law2_ScGeom6D_CohFrictPhys_CohesionMoment(),
                        Law2_ScGridCoGeom_CohFrictPhys_CundallStrack(),  # used for the cohesive sphere-cylinder interaction
                ]
        ),
        GlobalStiffnessTimeStepper(active=1, timeStepUpdateInterval=100, timestepSafetyCoefficient=0.8, label='ts'),
        NewtonIntegrator(gravity=(0, -9.81, 0), damping=0.15, label='newton'),
        PyRunner(iterPeriod=500, command='history()'),
]

### Generate a spiral

### Create all nodes first
nodesIds = []
rCyl = 0.005
Ne = 200
for i in range(0, Ne + 1):
	omega = 60.0 / float(Ne)
	hy = 0.10
	hz = 0.15
	px = float(i) * (omega / 60.0)
	py = sin(float(i) * omega) * hy
	pz = cos(float(i) * omega) * hz
	nodesIds.append(O.bodies.append(gridNode([px, py, pz], rCyl, wire=False, fixed=False, color=Vector3(0.6, 0.5, 0.5), material='mat')))

### Now create connection between the nodes
for i, j in zip(nodesIds[:-1], nodesIds[1:]):
	O.bodies.append(gridConnection(i, j, rCyl, color=Vector3(0.6, 0.5, 0.5), material='mat'))


def outp(id=1):
	for i in O.interactions:
		if i.id1 == 1:
			print(i.phys.shearForce)
			print(i.phys.normalForce)
			return i


O.bodies[Ne - 1].state.blockedDOFs = 'xyzXYZ'
yade.qt.View()

#plot some results
from yade import plot

plot.plots = {'t': ('pos1', None, 'vel1')}


def history():
	plot.addData(
	        pos1=O.bodies[0].state.pos[1],  # potential elastic energy
	        vel1=O.bodies[0].state.vel[1],
	        t=O.time
	)


#yade.qt.Renderer().bound=True
plot.plot(subPlots=False)
O.saveTmp()
#O.bodies[0].state.angVel=Vector3(0.05,0,0)