Skip to content

Commit aa0ad5a

Browse files
add test case for servo control
1 parent 6050a6f commit aa0ad5a

7 files changed

Lines changed: 233 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"materials" : [{
3+
"material_name" : "DEM-DefaultMaterial",
4+
"material_id" : 1,
5+
"Variables" : {
6+
"PARTICLE_DENSITY" : 2650.0,
7+
"YOUNG_MODULUS" : 3.5e7,
8+
"POISSON_RATIO" : 0.2,
9+
"PARTICLE_SPHERICITY" : 1.0
10+
}
11+
}],
12+
"material_relations" : [{
13+
"material_names_list" : ["DEM-DefaultMaterial","DEM-DefaultMaterial"],
14+
"material_ids_list" : [1,1],
15+
"Variables" : {
16+
"DEM_DISCONTINUUM_CONSTITUTIVE_LAW_NAME" : "DEM_D_Hertz_viscous_Coulomb",
17+
"PARTICLE_COHESION" : 0.0,
18+
"STATIC_FRICTION" : 0.6,
19+
"DYNAMIC_FRICTION" : 0.6,
20+
"FRICTION_DECAY" : 500,
21+
"COEFFICIENT_OF_RESTITUTION" : 0.01,
22+
"ROLLING_FRICTION" : 0.01,
23+
"ROLLING_FRICTION_WITH_WALLS" : 0.01,
24+
"DEM_ROLLING_FRICTION_MODEL_NAME" : "DEMRollingFrictionModelConstantTorque"
25+
}
26+
}],
27+
"material_assignation_table" : [["SpheresPart.DEMParts_Body","DEM-DefaultMaterial"]]
28+
}
29+
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"Dimension" : 3,
3+
"PeriodicDomainOption" : true,
4+
"BoundingBoxOption" : true,
5+
"AutomaticBoundingBoxOption" : false,
6+
"BoundingBoxEnlargementFactor" : 1.0,
7+
"BoundingBoxStartTime" : 0.0,
8+
"BoundingBoxStopTime" : 1000.0,
9+
"BoundingBoxMaxX" : 0.2,
10+
"BoundingBoxMaxY" : 0.241421356237,
11+
"BoundingBoxMaxZ" : 0.2,
12+
"BoundingBoxMinX" : -0.2,
13+
"BoundingBoxMinY" : -0.241421356237,
14+
"BoundingBoxMinZ" : -0.2,
15+
"BoundingBoxMoveOption" : true,
16+
"BoundingBoxMoveVelocity" : [1.0, 1.0, 1.0],
17+
"BoundingBoxMoveOptionDetail" : [1, 1, 1, 1, 1, 1],
18+
"BoundingBoxServoLoadingOption" : true,
19+
"BoundingBoxServoLoadingSettings":{
20+
"BoundingBoxServoLoadingType" : "isotropic",
21+
"BoundingBoxServoLoadingStress" : [5e3, 5e3, 5e3],
22+
"BoundingBoxServoLoadingFactor" : 5,
23+
"BoundingBoxServoLoadingFrequency" : 10,
24+
"BoundingBoxServoLoadingVelocityMax": 1.0,
25+
"MeanParticleDiameterD50" : 2.1e-4,
26+
"ParticleYoungsModulus" : 3.5e10
27+
},
28+
"dem_inlet_option" : false,
29+
"dem_inlets_settings" : {},
30+
"GravityX" : 0.0,
31+
"GravityY" : 0.0,
32+
"GravityZ" : 0.0,
33+
"RotationOption" : true,
34+
"CleanIndentationsOption" : false,
35+
"RadiusExpansionOption" : false,
36+
"RadiusExpansionRate" : 1000.0,
37+
"RadiusMultiplierMax" : 2.0,
38+
"RadiusExpansionRateChangeOption": false,
39+
"RadiusExpansionAcceleration" : -4e5,
40+
"RadiusExpansionRateMin" : 100.0,
41+
"EnergyCalculationOption" : true,
42+
"ComputeStressTensorOption" : true,
43+
"solver_settings" : {
44+
"RemoveBallsInitiallyTouchingWalls" : false,
45+
"strategy" : "sphere_strategy",
46+
"material_import_settings" : {
47+
"materials_filename" : "MaterialsDEM.json"
48+
}
49+
},
50+
"VirtualMassCoefficient" : 1.0,
51+
"RollingFrictionOption" : true,
52+
"GlobalDamping" : 0.0,
53+
"GlobalViscousDamping" : 0.0,
54+
"ContactMeshOption" : true,
55+
"OutputFileType" : "Ascii",
56+
"Multifile" : "multiple_files",
57+
"ElementType" : "SphericPartDEMElement3D",
58+
"TranslationalIntegrationScheme" : "Symplectic_Euler",
59+
"RotationalIntegrationScheme" : "Direct_Integration",
60+
"MaxTimeStep" : 2e-8,
61+
"FinalTime" : 0.00006,
62+
"NeighbourSearchFrequency" : 50,
63+
"SearchTolerance" : 0.0000002,
64+
"GraphExportFreq" : 0.00004,
65+
"VelTrapGraphExportFreq" : 0.00004,
66+
"OutputTimeStep" : 0.00004,
67+
"PostBoundingBox" : true,
68+
"PostLocalContactForce" : false,
69+
"PostDisplacement" : true,
70+
"PostRadius" : true,
71+
"PostVelocity" : true,
72+
"PostAngularVelocity" : false,
73+
"PostElasticForces" : false,
74+
"PostContactForces" : false,
75+
"PostRigidElementForces" : false,
76+
"PostStressStrainOption" : true,
77+
"PostTangentialElasticForces" : false,
78+
"PostTotalForces" : false,
79+
"PostPressure" : false,
80+
"PostShearStress" : false,
81+
"PostSkinSphere" : false,
82+
"PostNonDimensionalVolumeWear" : false,
83+
"PostParticleMoment" : false,
84+
"PostEulerAngles" : false,
85+
"PostRollingResistanceMoment" : false,
86+
"problem_name" : "testSC"
87+
}
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Begin ModelPartData
2+
// VARIABLE_NAME value
3+
End ModelPartData
4+
5+
Begin Properties 0
6+
End Properties
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Time Trans kinematic energy Rot kinematic energy Kinematic energy Gravitational energy Elastic energy Frictional energy Viscodamping energy Rolling resistance energy Total energy
2+
4.002e-05 6.17221e-19 1.64829e-28 6.17221e-19 0 9.58515e-12 0 1.26916e-21 2.09691e-25 9.58515e-12

applications/DEMApplication/tests/test_DEMApplication.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import test_dem_3d_parallel_bond_model
3636
import test_dem_3d_smooth_joint_model
3737
import test_moving_periodic_boundary
38+
import test_servo_control
3839
import sys
3940
sys.path.append('DEM3D_chung_ooi_tests/test1_data')
4041
sys.path.append('DEM3D_chung_ooi_tests/test2_data')
@@ -107,6 +108,7 @@ def AssembleTestSuites():
107108
smallSuite.addTest(test_dem_3d_parallel_bond_model.TestParallelBondModel("test_ParallelBondModel_1"))
108109
smallSuite.addTest(test_dem_3d_smooth_joint_model.TestSmoothJointModel("test_SmoothJointModel_1"))
109110
smallSuite.addTest(test_moving_periodic_boundary.TestMovingPeriodicBoundary("test_MovingPeriodicBoundary"))
111+
smallSuite.addTest(test_servo_control.TestServoControl("test_ServoControl"))
110112

111113
# Create a test suit with the selected tests plus all small tests
112114
nightSuite = suites['nightly']
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import os
2+
import KratosMultiphysics as Kratos
3+
from KratosMultiphysics import Logger
4+
Logger.GetDefaultOutput().SetSeverity(Logger.Severity.WARNING)
5+
import KratosMultiphysics.KratosUnittest as KratosUnittest
6+
import KratosMultiphysics.DEMApplication.DEM_analysis_stage
7+
8+
import auxiliary_functions_for_tests
9+
10+
this_working_dir_backup = os.getcwd()
11+
12+
def GetFilePath(fileName):
13+
return os.path.join(os.path.dirname(os.path.realpath(__file__)), fileName)
14+
15+
class ServoConrolTestSolution(KratosMultiphysics.DEMApplication.DEM_analysis_stage.DEMAnalysisStage, KratosUnittest.TestCase):
16+
17+
@classmethod
18+
def GetMainPath(self):
19+
return os.path.join(os.path.dirname(os.path.realpath(__file__)), "servo_control_tests_files")
20+
21+
def GetProblemNameWithPath(self):
22+
return os.path.join(self.main_path, self.DEM_parameters["problem_name"].GetString())
23+
24+
def FinalizeSolutionStep(self):
25+
super().FinalizeSolutionStep()
26+
tolerance = 1e-8
27+
stress_tensor = self.MeasureSphereForGettingGlobalStressTensor()
28+
mean_stress = (stress_tensor[0][0]+stress_tensor[1][1]+stress_tensor[2][2])/3
29+
30+
if self.time >= 0.000048 and self.time < 0.000049:
31+
expected_value = 5.007421025614752e-08
32+
self.assertAlmostEqual(mean_stress, expected_value, delta=tolerance)
33+
34+
def Finalize(self):
35+
self.procedures.RemoveFoldersWithResults(str(self.main_path), str(self.problem_name), '')
36+
super().Finalize()
37+
38+
class TestServoControl(KratosUnittest.TestCase):
39+
40+
def setUp(self):
41+
pass
42+
43+
@classmethod
44+
def test_ServoControl(self):
45+
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "servo_control_tests_files")
46+
parameters_file_name = os.path.join(path, "ProjectParametersDEM.json")
47+
model = Kratos.Model()
48+
auxiliary_functions_for_tests.CreateAndRunStageInSelectedNumberOfOpenMPThreads(ServoConrolTestSolution, model, parameters_file_name, 1)
49+
50+
if __name__ == "__main__":
51+
Kratos.Logger.GetDefaultOutput().SetSeverity(Logger.Severity.WARNING)
52+
KratosUnittest.main()

0 commit comments

Comments
 (0)