from KratosMultiphysics import * from KratosMultiphysics.StructuralApplication import * model = Model() model_part = model.CreateModelPart("SolidPart") node1 = model_part.CreateNewNode(1, 0.0, 0.0, 0.0) node2 = model_part.CreateNewNode(2, 1.0, 0.0, 0.0) node3 = model_part.CreateNewNode(3, 0.0, 1.0, 0.0) model_part.CreateNewElement("Element3D3N", 1, [node1.Id, node2.Id, node3.Id], model_part.GetProperties()[0]) model_part.GetProperties()[0].SetValue(YOUNG_MODULUS, 210e6) model_part.GetProperties()[0].SetValue(POISSON_RATIO, 0.3) node1.SetSolutionStepValue(DISPLACEMENT_X, 0.0) node1.SetSolutionStepValue(DISPLACEMENT_Y, 0.0) node1.SetSolutionStepValue(DISPLACEMENT_Z, 0.0) node2.SetSolutionStepValue(DISPLACEMENT_X, 0.0) node2.SetSolutionStepValue(DISPLACEMENT_Y, 0.0) node2.SetSolutionStepValue(DISPLACEMENT_Z, 0.0) node3.SetSolutionStepValue(DISPLACEMENT_X, 0.0) node3.SetSolutionStepValue(DISPLACEMENT_Y, 0.0) node3.SetSolutionStepValue(DISPLACEMENT_Z, 0.0) solver = StaticStructuralSolver(model_part, domain_size=3) solver.Solve()
from KratosMultiphysics import * from KratosMultiphysics.FluidDynamicsApplication import * model = Model() model_part = model.CreateModelPart("FlowPart") model_part.AddNodalSolutionStepVariable(VELOCITY) model_part.AddNodalSolutionStepVariable(PRESSURE) model_part.AddNodalSolutionStepVariable(VISCOSITY) model_part.ProcessInfo.SetValue(DENSITY, 1.0) model_part.ProcessInfo.SetValue(VISCOSITY, 0.001) box_model_part = ModelPart("BoxPart") Create3DBox(box_model_part, 1.0, 1.0, 1.0, 10, 10, 10) model_part.AddModelPart(box_model_part) fluid_solver_settings = Parameters(""" { "solver_type": "navier_stokes_solver_vmsmonolithic", "domain_size": 3, "model_import_settings": { "input_type": "mdpa", "input_filename": "box_part.mdpa" }, "formulation": { "dynamic_tau": 0.0, "dynamic_tau_stabilization": 0.0, "turbulence_model": "none", "pressure_model_part_name": "FluidPart_AuxiliarModelPart", "element_replace_settings": [], "processes_sub_model_part": "" }, "compute_reactions": false, "echo_level": 1 } """) fluid_solver = CreateSolver(model_part, fluid_solver_settings) fluid_solver.Initialize() fluid_solver.Solve()This code creates a 3D box with dimensions of 1.0x1.0x1.0 and applies viscosity and density values to the domain. The Navier-Stokes solver is then used to simulate the fluid flow in the box. Based on these examples, it is clear that KratosMultiphysics belongs to the package libraries for structural and fluid analysis, and it covers comprehensive features for each field.