Build your first material¶
End-to-end walkthrough: scaffold a material bound to an existing material schema, build it, test it, register it. About 15 minutes.
A material is a component whose payload is a set of properties
conforming to a material schema; see
Concepts: materials. This tutorial uses the
public test schema simscale.test:test-fluid-material-schema, which
declares a name, a fluid type, a density and a dynamic viscosity.
Prerequisites¶
- SimKit CLI installed. See installation.
- API key for your SimScale account. Your account needs
MEMBERpermission or higher on the component group you'll register components under (directly or inherited from a parent group), or you must be an admin of your organization. - A working directory. Anywhere on disk.
Conventions¶
Same as the other tutorials: <your-namespace> is a component group
you have MEMBER permission or higher on; all 1.0.0 references are
snapshots
while you iterate.
Step 1 — Configure simkit¶
Step 2 — Scaffold¶
Step 3 — Declare the schema¶
A material has exactly one dependency, its material schema, so naming
the schema with its version in schema(...) declares it; no
dependencies { } block is needed. Replace the scaffolded blocks:
metadata {
reference = "<your-namespace>:water:1.0.0"
name = "Water"
description = "Liquid water at 20 °C and 1 atm."
}
schema("simscale.test:test-fluid-material-schema:1.0.0-SNAPSHOT-latest")
Step 4 — Fill the properties¶
properties { } is applied to the schema's generated data model
builder. Its properties are the schema's fields: mandatory ones must be
set, fields with a schema default may be left out, enums are the
generated enum classes, dimensionals are written with a unit and keep
it, a nested compound is a block named after it and a polymorphic one a
function per variant (equationOfState { incompressible() }).
import com.simscale.workflows.framework.measurementunits.dimensionals.kilogram_per_cubic_meter
import com.simscale.workflows.framework.measurementunits.dimensionals.pascal_second
properties {
name = "Water"
fluidType = FluidType.LIQUID
density = 997.33.kilogram_per_cubic_meter
dynamicViscosity = 0.000931297.pascal_second
}
The imports go to the top of the file. A misspelled property is a compile error at the build; a mandatory property left unset fails the build with the property's name.
Why a data model and not a value model? A material is data: constants, complete, frozen when built. Value models are how rules and configuration mappings read data, including a slot's effective material; they have no place in a material file.
For generated or migrated materials, propertiesJson(""" { … } """)
takes the properties document as JSON instead; it is validated
structurally at registration rather than at build time.
Step 5 — Build¶
The build resolves the schema, generates its data model, compiles your
properties { } against it and writes
<your-namespace>:water:1.0.0.material.json — the registration
envelope, whose package.properties is the serialized document:
{
"name": "Water",
"fluidType": "LIQUID",
"density": { "value": 997.33, "unit": "kg/m³" },
"dynamicViscosity": { "value": 0.000931297, "unit": "Pa⋅s" }
}
Step 6 — Test¶
Create water.material.test.kts next to the material:
materialTest {
test("the properties document carries the authored properties in the authored units") {
property("/density/value").asDouble() shouldBe 997.33
property("/density/unit").asString() shouldBe "kg/m³"
property("/fluidType").asString() shouldBe "LIQUID"
}
test("the material is bound to the fluid schema") {
schemaDataTypeReference shouldBe "simscale.test:test-fluid-material-schema"
}
}
property("/json/pointer") reads the serialized document; see the
component tests reference.
Step 7 — Register¶
The registry validates the document against the schema — structure, defaults, the schema's rule set — and rejects a material that violates it (a negative density here). Look the material up in the SimKit Web UI, or ask which slots accept it:
Where to go next¶
- Add a material slot — consume it in a workflow type.
- Author a material schema — when no existing schema fits.
- Release a component — snapshots become immutable versions; the schema goes first.