{
  "schemaVersion": 1,
  "slug": "3d-printing-cost-calculator",
  "category": "diy-craft",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "d48e2b6d9df6edf94eb4021be816c0185316cc714266ac056959e91ab1bfcdb9",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/3d-printing-cost-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "C = material + electricity + (material + electricity) × f ÷ 100 + labor",
    "vars": [
      [
        "C",
        "total cost"
      ],
      [
        "material",
        "material cost = model weight × spool price ÷ spool weight"
      ],
      [
        "electricity",
        "electricity cost = print hours × watts ÷ 1000 × rate"
      ],
      [
        "f",
        "Extra allowance on material and electricity (%)"
      ],
      [
        "labor",
        "labor cost = minutes ÷ 60 × hourly rate"
      ]
    ]
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const perGram = spoolWeight > 0 ? spoolPrice/spoolWeight : 0; const material = modelWeight*perGram; const power = printHours*printerWatts/1000*electricityRate; const waste = (material + power)*failureRate/100; const labour = labourMinutes/60*labourRate; return { costPerGram: perGram, materialCost: material, electricityCost: power, failureCost: waste, labourCost: labour, totalCost: material + power + waste + labour, equivalentSpools: spoolWeight > 0 ? modelWeight/spoolWeight*100 : 0 };",
    "inputs": [
      {
        "name": "modelWeight",
        "type": "number",
        "default": 120,
        "min": 0.1,
        "max": 20000,
        "step": 0.1
      },
      {
        "name": "spoolPrice",
        "type": "number",
        "default": 22,
        "min": 0,
        "max": 1000,
        "step": 0.01
      },
      {
        "name": "spoolWeight",
        "type": "number",
        "default": 1000,
        "min": 10,
        "max": 10000,
        "step": 10,
        "slider": true,
        "advanced": true
      },
      {
        "name": "printHours",
        "type": "number",
        "default": 6,
        "min": 0,
        "max": 500,
        "step": 0.1,
        "slider": true
      },
      {
        "name": "printerWatts",
        "type": "number",
        "default": 120,
        "min": 0,
        "max": 3000,
        "step": 5,
        "slider": true,
        "advanced": true
      },
      {
        "name": "electricityRate",
        "type": "number",
        "default": 0.17,
        "min": 0,
        "max": 10,
        "step": 0.01,
        "slider": true,
        "advanced": true
      },
      {
        "name": "failureRate",
        "type": "number",
        "default": 10,
        "min": 0,
        "max": 100,
        "step": 1,
        "slider": true,
        "advanced": true
      },
      {
        "name": "labourMinutes",
        "type": "number",
        "default": 0,
        "min": 0,
        "max": 1000,
        "step": 5,
        "slider": true,
        "advanced": true
      },
      {
        "name": "labourRate",
        "type": "number",
        "default": 0,
        "min": 0,
        "max": 500,
        "step": 0.5,
        "slider": true,
        "advanced": true
      }
    ],
    "outputs": [
      {
        "name": "totalCost",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "costPerGram",
        "precision": 4,
        "unit": "$/g"
      },
      {
        "name": "materialCost",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "electricityCost",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "failureCost",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "labourCost",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "equivalentSpools",
        "precision": 1,
        "unit": "%"
      }
    ],
    "interpret": null
  }
}
