Skip to content

Commit addb01c

Browse files
Merge pull request #145 from KratosMultiphysics/add-dem-examples
[DEM] Added a DEM example
2 parents 138988c + cedbca1 commit addb01c

File tree

5 files changed

+327
-0
lines changed

5 files changed

+327
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import time
2+
import sys
3+
4+
import KratosMultiphysics
5+
from KratosMultiphysics.DEMApplication.DEM_analysis_stage import DEMAnalysisStage
6+
from KratosMultiphysics import *
7+
from KratosMultiphysics.DEMApplication import *
8+
from KratosMultiphysics import Logger
9+
10+
class DEMAnalysisStageWithFlush(DEMAnalysisStage):
11+
12+
def __init__(self, model, project_parameters, flush_frequency=10.0):
13+
super().__init__(model, project_parameters)
14+
self.flush_frequency = flush_frequency
15+
self.last_flush = time.time()
16+
17+
def FinalizeSolutionStep(self):
18+
super().FinalizeSolutionStep()
19+
20+
if self.parallel_type == "OpenMP":
21+
now = time.time()
22+
if now - self.last_flush > self.flush_frequency:
23+
sys.stdout.flush()
24+
self.last_flush = now
25+
26+
if __name__ == "__main__":
27+
Logger.GetDefaultOutput().SetSeverity(Logger.Severity.INFO)
28+
with open("ProjectParametersDEM.json", 'r') as parameter_file:
29+
parameters = KratosMultiphysics.Parameters(parameter_file.read())
30+
31+
global_model = KratosMultiphysics.Model()
32+
DEMAnalysisStageWithFlush(global_model, parameters).Run()
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"materials" : [{
3+
"material_name" : "DEM-P",
4+
"material_id" : 1,
5+
"Variables" : {
6+
"PARTICLE_DENSITY" : 2200,
7+
"YOUNG_MODULUS" : 9.0e9,
8+
"POISSON_RATIO" : 0.25,
9+
"PARTICLE_SPHERICITY" : 1.0
10+
}
11+
},{
12+
"material_name" : "DEM-S",
13+
"material_id" : 2,
14+
"Variables" : {
15+
"YOUNG_MODULUS" : 202e9,
16+
"POISSON_RATIO" : 0.25,
17+
"PARTICLE_SPHERICITY" : 1.0,
18+
"COMPUTE_WEAR" : false
19+
}
20+
}],
21+
"material_relations" : [{
22+
"material_names_list" : ["DEM-P","DEM-P"],
23+
"material_ids_list" : [1,1],
24+
"Variables" : {
25+
"PARTICLE_MATERIAL": 1,
26+
"DEM_DISCONTINUUM_CONSTITUTIVE_LAW_NAME" : "DEM_D_Linear_viscous_Coulomb",
27+
"STATIC_FRICTION" : 0.25,
28+
"DYNAMIC_FRICTION" : 0.24,
29+
"FRICTION_DECAY" : 500,
30+
"COEFFICIENT_OF_RESTITUTION" : 0.189,
31+
"K_ALPHA" : 45.0,
32+
"DEM_ROLLING_FRICTION_MODEL_NAME" : "DEMRollingFrictionModelConstantTorque",
33+
"ROLLING_FRICTION" : 0.01,
34+
"ROLLING_FRICTION_WITH_WALLS" : 0.01
35+
36+
}
37+
},{
38+
"material_names_list" : ["DEM-P","DEM-S"],
39+
"material_ids_list" : [1,2],
40+
"Variables" : {
41+
"PARTICLE_MATERIAL": 1,
42+
"DEM_DISCONTINUUM_CONSTITUTIVE_LAW_NAME": "DEM_D_Linear_viscous_Coulomb",
43+
"STATIC_FRICTION": 0.5,
44+
"DYNAMIC_FRICTION": 0.49,
45+
"FRICTION_DECAY": 500,
46+
"WALL_COHESION": 0.0,
47+
"SEVERITY_OF_WEAR": 0.001,
48+
"IMPACT_WEAR_SEVERITY": 0.001,
49+
"BRINELL_HARDNESS": 200.0,
50+
"COEFFICIENT_OF_RESTITUTION": 0.189,
51+
"K_ALPHA": 45.0,
52+
"DEM_ROLLING_FRICTION_MODEL_NAME" : "DEMRollingFrictionModelConstantTorque",
53+
"ROLLING_FRICTION": 0.01,
54+
"ROLLING_FRICTION_WITH_WALLS": 0.0
55+
}
56+
}],
57+
"material_assignation_table" : [["SpheresPart.DEMParts_Body","DEM-P"],
58+
["RigidFacePart.DEM-FEM-Wall_TOP","DEM-S"],
59+
["RigidFacePart.DEM-FEM-Wall_BOTTOM","DEM-S"]]
60+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"Dimension" : 3,
3+
"PeriodicDomainOption" : false,
4+
"BoundingBoxOption" : false,
5+
"AutomaticBoundingBoxOption" : false,
6+
"BoundingBoxEnlargementFactor" : 1.1,
7+
"BoundingBoxStartTime" : 0.0,
8+
"BoundingBoxStopTime" : 1000.0,
9+
"BoundingBoxMaxX" : 10,
10+
"BoundingBoxMaxY" : 10,
11+
"BoundingBoxMaxZ" : 10,
12+
"BoundingBoxMinX" : -10,
13+
"BoundingBoxMinY" : -10,
14+
"BoundingBoxMinZ" : -10,
15+
"dem_inlet_option" : false,
16+
"GravityX" : 0.0,
17+
"GravityY" : 0.0,
18+
"GravityZ" : 0.0,
19+
"RotationOption" : true,
20+
"CleanIndentationsOption" : false,
21+
"VirtualMassCoefficient" : 1.0,
22+
"RollingFrictionOption" : false,
23+
"GlobalDamping" : 0.0,
24+
"ContactMeshOption" : true,
25+
"OutputFileType" : "Binary",
26+
"Multifile" : "multiple_files",
27+
"ElementType" : "SphericContPartDEMElement3D",
28+
"TranslationalIntegrationScheme" : "Symplectic_Euler",
29+
"RotationalIntegrationScheme" : "Direct_Integration",
30+
"MaxTimeStep" : 1e-5,
31+
"FinalTime" : 0.1,
32+
"NeighbourSearchFrequency" : 1,
33+
"SearchTolerance" : 0.02,
34+
"GraphExportFreq" : 1e-2,
35+
"VelTrapGraphExportFreq" : 1e-2,
36+
"OutputTimeStep" : 1e-2,
37+
"PostBoundingBox" : true,
38+
"PostLocalContactForce" : true,
39+
"PostDisplacement" : true,
40+
"PostRadius" : true,
41+
"PostVelocity" : true,
42+
"PostAngularVelocity" : true,
43+
"PostElasticForces" : true,
44+
"PostContactForces" : true,
45+
"PostRigidElementForces" : false,
46+
"PostStressStrainOption" : true,
47+
"PostTangentialElasticForces" : false,
48+
"PostTotalForces" : true,
49+
"PostPressure" : false,
50+
"PostShearStress" : false,
51+
"PostSkinSphere" : true,
52+
"PostNonDimensionalVolumeWear" : false,
53+
"PostParticleMoment" : true,
54+
"PostEulerAngles" : false,
55+
"PostRollingResistanceMoment" : false,
56+
"problem_name" : "test_PBM",
57+
"DeltaOption" : "Absolute",
58+
"CoordinationNumber" : 10,
59+
"AmplifiedSearchRadiusExtension" : 1.1,
60+
"PoissonEffectOption" : false,
61+
"ShearStrainParallelToBondOption" : false,
62+
"ComputeStressTensorOption" : false,
63+
"MaxAmplificationRatioOfSearchRadius" : 1000,
64+
"PostContactFailureId" : true,
65+
66+
"EnergyCalculationOption" : false,
67+
"VelocityTrapOption" : false,
68+
"solver_settings" : {
69+
"RemoveBallsInitiallyTouchingWalls" : false,
70+
"strategy" : "sphere_strategy"
71+
},
72+
"ModelDataInfo" : false,
73+
"DontSearchUntilFailure" : false,
74+
"MaxNumberOfIntactBondsToConsiderASphereBroken" : 0,
75+
"AutomaticTimestep" : false,
76+
"DeltaTimeSafetyFactor" : 1.0,
77+
"ControlTime" : 4.0,
78+
"PostPoissonRatio" : false,
79+
"PostCharacteristicLength" : false,
80+
"PostNodalArea" : false,
81+
"PostContactSigma" : true,
82+
"PostContactTau" : true,
83+
"PostFailureCriterionState" : true,
84+
"PostMeanContactArea" : false,
85+
"PostRHS" : false,
86+
"PostDampForces" : false,
87+
"PostAppliedForces" : true,
88+
"PostGroupId" : false,
89+
"PostExportId" : false,
90+
"post_vtk_option" : false
91+
}
92+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Begin ModelPartData
2+
// VARIABLE_NAME value
3+
End ModelPartData
4+
5+
Begin Properties 0
6+
End Properties
7+
8+
Begin Nodes
9+
1 -0.1 0.0 0.1
10+
2 0.1 0.0 0.1
11+
3 -0.1 0.0 -0.1
12+
4 0.1 0.0 -0.1
13+
5 0.0 0.141421356237 0.0
14+
6 0.0 -0.141421356237 0.0
15+
End Nodes
16+
17+
18+
Begin Elements SphericParticle3D// GUI group identifier: Body
19+
1 0 1
20+
2 0 2
21+
3 0 3
22+
4 0 4
23+
5 0 5
24+
6 0 6
25+
End Elements
26+
27+
Begin NodalData RADIUS // GUI group identifier: Body
28+
1 0 0.1
29+
2 0 0.1
30+
3 0 0.1
31+
4 0 0.1
32+
5 0 0.1
33+
6 0 0.1
34+
End NodalData
35+
36+
Begin SubModelPart DEMParts_Body // Group Body // Subtree DEMParts
37+
Begin SubModelPartNodes
38+
1
39+
2
40+
3
41+
4
42+
5
43+
6
44+
End SubModelPartNodes
45+
Begin SubModelPartElements
46+
1
47+
2
48+
3
49+
4
50+
5
51+
6
52+
End SubModelPartElements
53+
Begin SubModelPartConditions
54+
End SubModelPartConditions
55+
End SubModelPart
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
Begin ModelPartData
2+
// VARIABLE_NAME value
3+
End ModelPartData
4+
5+
Begin Properties 0
6+
End Properties
7+
8+
Begin Nodes
9+
1 -0.2 0.241421356237 0.2
10+
2 -0.2 0.241421356237 -0.2
11+
3 0.2 0.241421356237 -0.2
12+
4 0.2 0.241421356237 0.2
13+
5 -0.2 -0.241421356237 0.2
14+
6 -0.2 -0.241421356237 -0.2
15+
7 0.2 -0.241421356237 -0.2
16+
8 0.2 -0.241421356237 0.2
17+
End Nodes
18+
19+
20+
Begin Conditions RigidFace3D4N// GUI group identifier: TOP
21+
1001 0 1 2 3 4
22+
End Conditions
23+
24+
Begin Conditions RigidFace3D4N// GUI group identifier: BOTTOM
25+
2001 0 5 6 7 8
26+
End Conditions
27+
28+
Begin SubModelPart DEM-FEM-Wall_TOP // DEM-FEM-Wall - group identifier: TOP
29+
Begin SubModelPartData // DEM-FEM-Wall. Group name: TOP
30+
LINEAR_VELOCITY [3] (-0.0, -0.05, -0.0)
31+
VELOCITY_PERIOD 0.0
32+
ANGULAR_VELOCITY [3] (0.0,0.0,0.0)
33+
ROTATION_CENTER [3] (0.0,0.0,0.0)
34+
ANGULAR_VELOCITY_PERIOD 0.0
35+
VELOCITY_START_TIME 0.0
36+
VELOCITY_STOP_TIME 100.0
37+
ANGULAR_VELOCITY_START_TIME 0.0
38+
ANGULAR_VELOCITY_STOP_TIME 100.0
39+
FIXED_MESH_OPTION 0
40+
RIGID_BODY_MOTION 1
41+
FREE_BODY_MOTION 0
42+
IS_GHOST 0
43+
IDENTIFIER TOP
44+
FORCE_INTEGRATION_GROUP 0
45+
End SubModelPartData
46+
Begin SubModelPartNodes
47+
1
48+
2
49+
3
50+
4
51+
End SubModelPartNodes
52+
53+
Begin SubModelPartConditions
54+
1001
55+
End SubModelPartConditions
56+
57+
End SubModelPart
58+
59+
Begin SubModelPart DEM-FEM-Wall_BOTTOM // DEM-FEM-Wall - group identifier: BOTTOM
60+
Begin SubModelPartData // DEM-FEM-Wall. Group name: BOTTOM
61+
LINEAR_VELOCITY [3] (0.0, 0.05, 0.0)
62+
VELOCITY_PERIOD 0.0
63+
ANGULAR_VELOCITY [3] (0.0,0.0,0.0)
64+
ROTATION_CENTER [3] (0.0,0.0,0.0)
65+
ANGULAR_VELOCITY_PERIOD 0.0
66+
VELOCITY_START_TIME 0.0
67+
VELOCITY_STOP_TIME 100.0
68+
ANGULAR_VELOCITY_START_TIME 0.0
69+
ANGULAR_VELOCITY_STOP_TIME 100.0
70+
FIXED_MESH_OPTION 0
71+
RIGID_BODY_MOTION 1
72+
FREE_BODY_MOTION 0
73+
IS_GHOST 0
74+
IDENTIFIER BOTTOM
75+
FORCE_INTEGRATION_GROUP 0
76+
End SubModelPartData
77+
Begin SubModelPartNodes
78+
5
79+
6
80+
7
81+
8
82+
End SubModelPartNodes
83+
Begin SubModelPartConditions
84+
2001
85+
End SubModelPartConditions
86+
87+
End SubModelPart
88+

0 commit comments

Comments
 (0)