{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/hecate-input-schema/latest.json",
  "title": "Hecate Input Schema",
  "description": "The input schema for Hecate.",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/ShaitanLyss/these/main/hecate/hecate-json-schema.json",
    "sourceSha256": "1c9021d072187e494cf3d301a81cade8846c7337003a4e0a7b3680988fde18ee",
    "fileMatch": [
      "*.hecate.yml",
      "*.hecate.yaml",
      "*.hecate",
      "*.hecate.json"
    ],
    "parsers": [
      "json",
      "yaml"
    ]
  },
  "type": "object",
  "properties": {
    "equations": {
      "$ref": "#/$defs/Map%3Cstring,%20Equation%3E",
      "description": "The available equations.",
      "title": "Equations"
    },
    "functions": {
      "$ref": "#/$defs/Map%3Cstring,%20FunctionDef%3E",
      "description": "The available functions.\nThey can either be simple function expression, or a list of function expression with conditions.",
      "title": "Functions"
    },
    "generation": {
      "$ref": "#/$defs/GenConfig",
      "default": {
        "debug": false,
        "matrix_free": false,
        "mpi": false
      }
    },
    "meshes": {
      "$ref": "#/$defs/Map%3Cstring,%20MeshEnum%3E",
      "description": "The available meshes.",
      "title": "Meshes"
    },
    "parameters": {
      "$ref": "#/$defs/Map%3Cstring,%20QuantityEnum%3E",
      "description": "The available parameters.",
      "title": "Parameters"
    },
    "solve": {
      "$ref": "#/$defs/Solve"
    },
    "unknowns": {
      "$ref": "#/$defs/Map%3Cstring,%20Unknown%3E",
      "description": "The available unknowns.",
      "title": "Unknowns"
    }
  },
  "$defs": {
    "Condition": {
      "anyOf": [
        {
          "$ref": "#/$defs/time"
        },
        {
          "pattern": "^\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*\\s*..\\s*\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*$",
          "type": "string"
        }
      ]
    },
    "Condition2": {
      "anyOf": [
        {
          "$ref": "#/$defs/length"
        },
        {
          "pattern": "^\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*\\s*..\\s*\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*$",
          "type": "string"
        }
      ]
    },
    "ConditionedFunctionExpression": {
      "properties": {
        "expr": {
          "$ref": "#/$defs/FunctionExpression"
        },
        "t": {
          "anyOf": [
            {
              "$ref": "#/$defs/Condition"
            },
            {
              "type": "null"
            }
          ],
          "description": "The time condition for which the function expression is valid.\nIt can be none, a value or a range.",
          "title": "Time Condition"
        },
        "x": {
          "anyOf": [
            {
              "$ref": "#/$defs/Condition2"
            },
            {
              "type": "null"
            }
          ],
          "description": "The x condition for which the function expression is valid.\nIt can be none, a value or a range.",
          "title": "X Condition"
        },
        "y": {
          "anyOf": [
            {
              "$ref": "#/$defs/Condition2"
            },
            {
              "type": "null"
            }
          ],
          "description": "The y condition for which the function expression is valid.\nIt can be none, a value or a range.",
          "title": "Y Condition"
        },
        "z": {
          "anyOf": [
            {
              "$ref": "#/$defs/Condition2"
            },
            {
              "type": "null"
            }
          ],
          "description": "The z condition for which the function expression is valid.\nIt can be none, a value or a range.",
          "title": "Z Condition"
        }
      },
      "required": [
        "expr"
      ],
      "type": "object"
    },
    "CustomQuantity": {
      "description": "This allows defining custom quantities based on\nthe seven base quantities of the international system.",
      "properties": {
        "amount": {
          "default": 0,
          "format": "int",
          "type": "integer"
        },
        "current": {
          "default": 0,
          "format": "int",
          "type": "integer"
        },
        "length": {
          "default": 0,
          "format": "int",
          "type": "integer"
        },
        "luminous_intensity": {
          "default": 0,
          "format": "int",
          "type": "integer"
        },
        "mass": {
          "default": 0,
          "format": "int",
          "type": "integer"
        },
        "temperature": {
          "default": 0,
          "format": "int",
          "type": "integer"
        },
        "time": {
          "default": 0,
          "format": "int",
          "type": "integer"
        },
        "value": {
          "default": 0.0,
          "format": "double",
          "type": "number"
        }
      },
      "title": "CustomQuantity",
      "type": "object"
    },
    "FiniteElement": {
      "description": "The finite element to use for the mesh.",
      "enum": [
        "Q1",
        "Q2",
        "Q3"
      ],
      "title": "Finite Element",
      "type": "string"
    },
    "FunctionDef": {
      "anyOf": [
        {
          "$ref": "#/$defs/FunctionExpression"
        },
        {
          "description": "A function defined as list of function expression with conditions (time range, space range, etc...).\nThe function expressions are checked in order. Therefore, in case of an overlap, the first one will be used.\nIf no function expressions without conditions are specified, a default value of 0 will be assumed.",
          "items": {
            "$ref": "#/$defs/ConditionedFunctionExpression"
          },
          "title": "Conditioned Function",
          "type": "array"
        }
      ],
      "description": "The definition of a function.\nThis can be an expression or a conditioned function.",
      "title": "Function Definition"
    },
    "FunctionExpression": {
      "description": "A function expression.\nAvailable variables are : t, x, y, z.\nMath functions such as cosinus or exponentials are available.\nThey can be called through their cpp names like log for the logarithm.",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        }
      ],
      "title": "Function Expression"
    },
    "GenConfig": {
      "description": "The configuration for the generation of the code.",
      "properties": {
        "debug": {
          "default": false,
          "description": "Whether to generate debug code.",
          "title": "Debug",
          "type": "boolean"
        },
        "matrix_free": {
          "default": false,
          "description": "Whether to generate matrix free code.",
          "title": "Matrix Free",
          "type": "boolean"
        },
        "mpi": {
          "default": false,
          "description": "Whether to generate MPI code.",
          "title": "MPI",
          "type": "boolean"
        }
      },
      "title": "Generation Configuration",
      "type": "object"
    },
    "HyperCubeMesh": {
      "properties": {
        "range": {
          "default": "0 m .. 1 m",
          "pattern": "^\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*\\s*..\\s*\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*$",
          "type": "string"
        },
        "resolution": {
          "$ref": "#/$defs/length",
          "default": "0.03125 m",
          "description": "The size of each cell.",
          "title": "Resolution"
        },
        "show_info": {
          "default": false,
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "Map<string, Equation>": {
      "type": "object",
      "additionalProperties": {
        "pattern": "^[^=]+=[^=]+$",
        "type": "string"
      }
    },
    "Map<string, FunctionDef>": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/FunctionDef"
      }
    },
    "Map<string, MeshEnum>": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/MeshEnum"
      }
    },
    "Map<string, QuantityEnum>": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/QuantityEnum"
      }
    },
    "Map<string, Unknown>": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/Unknown"
      }
    },
    "MeshEnum": {
      "oneOf": [
        {
          "$ref": "#/$defs/HyperCubeMesh",
          "properties": {
            "type": {
              "const": "hyper_cube",
              "type": "string"
            }
          },
          "required": [
            "type"
          ],
          "type": "object"
        }
      ]
    },
    "QuantityEnum": {
      "oneOf": [
        {
          "properties": {
            "type": {
              "const": "speed",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/speed"
            }
          },
          "required": [
            "type",
            "value"
          ],
          "type": "object"
        },
        {
          "properties": {
            "type": {
              "const": "length",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/length"
            }
          },
          "required": [
            "type",
            "value"
          ],
          "type": "object"
        },
        {
          "properties": {
            "type": {
              "const": "area",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/area"
            }
          },
          "required": [
            "type",
            "value"
          ],
          "type": "object"
        },
        {
          "properties": {
            "type": {
              "const": "volume",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/volume"
            }
          },
          "required": [
            "type",
            "value"
          ],
          "type": "object"
        },
        {
          "properties": {
            "type": {
              "const": "mass",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/mass"
            }
          },
          "required": [
            "type",
            "value"
          ],
          "type": "object"
        },
        {
          "properties": {
            "type": {
              "const": "temperature",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/temperature"
            }
          },
          "required": [
            "type",
            "value"
          ],
          "type": "object"
        },
        {
          "properties": {
            "type": {
              "const": "diffusion_coefficient",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/diffusion_coefficient"
            }
          },
          "required": [
            "type",
            "value"
          ],
          "type": "object"
        },
        {
          "properties": {
            "type": {
              "const": "custom",
              "type": "string"
            },
            "value": {
              "$ref": "#/$defs/CustomQuantity"
            }
          },
          "required": [
            "type",
            "value"
          ],
          "type": "object"
        }
      ],
      "title": "Quantity"
    },
    "Solve": {
      "description": "The equation(s) to solve and the mesh to use.",
      "properties": {
        "dimension": {
          "default": 2,
          "description": "The dimension of the problem\nPossible values: 1, 2, 3",
          "format": "uint",
          "minimum": 0,
          "title": "Dimension",
          "type": "integer"
        },
        "element": {
          "$ref": "#/$defs/FiniteElement"
        },
        "equations": {
          "description": "The equation(s) to solve",
          "items": {
            "type": "string"
          },
          "title": "Equations",
          "type": "array"
        },
        "mesh": {
          "description": "The mesh to use",
          "title": "Mesh",
          "type": "string"
        },
        "time": {
          "default": "0 .. 5s",
          "description": "The time range to solve.",
          "pattern": "^\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*\\s*..\\s*\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*$",
          "title": "Time",
          "type": "string"
        },
        "time_step": {
          "$ref": "#/$defs/time",
          "description": "The time step to use.",
          "title": "Time Step"
        }
      },
      "required": [
        "equations",
        "mesh",
        "element",
        "time_step"
      ],
      "title": "Solve",
      "type": "object"
    },
    "Unknown": {
      "description": "Represents an unknown to be solved in the PDE.",
      "properties": {
        "boundary": {
          "$ref": "#/$defs/UnknownProperty",
          "default": 0,
          "description": "The boundary condition of the unknown.",
          "title": "Boundary Condition"
        },
        "derivative": {
          "anyOf": [
            {
              "$ref": "#/$defs/Unknown"
            },
            {
              "type": "null"
            }
          ],
          "description": "The time derivative's conditions of the unknown.\nThe number of derivative specified should match the max time order of the equations - 1.\n(ie. an equation of order 2 in time needs one derivative specified)",
          "title": "Time Derivative Conditions"
        },
        "initial": {
          "$ref": "#/$defs/UnknownProperty",
          "default": 0,
          "description": "The initial value of the unknown.",
          "title": "Initial Condition"
        }
      },
      "title": "Unknown",
      "type": "object"
    },
    "UnknownProperty": {
      "anyOf": [
        {
          "format": "int64",
          "type": "integer"
        },
        {
          "format": "double",
          "type": "number"
        },
        {
          "description": "Function name referencing one of the globally defined functions.",
          "type": "string"
        }
      ]
    },
    "area": {
      "description": "A area.",
      "oneOf": [
        {
          "pattern": "^\\s*(reference|ref)?\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*$",
          "type": "string"
        },
        {
          "type": "number"
        }
      ],
      "title": "Area"
    },
    "diffusion_coefficient": {
      "description": "A diffusion coefficient.",
      "oneOf": [
        {
          "pattern": "^\\s*(reference|ref)?\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*$",
          "type": "string"
        },
        {
          "type": "number"
        }
      ],
      "title": "Diffusion Coefficient"
    },
    "length": {
      "description": "A length.",
      "oneOf": [
        {
          "pattern": "^\\s*(reference|ref)?\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*$",
          "type": "string"
        },
        {
          "type": "number"
        }
      ],
      "title": "Length"
    },
    "mass": {
      "description": "A mass.",
      "oneOf": [
        {
          "pattern": "^\\s*(reference|ref)?\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*$",
          "type": "string"
        },
        {
          "type": "number"
        }
      ],
      "title": "Mass"
    },
    "speed": {
      "description": "A speed.",
      "oneOf": [
        {
          "pattern": "^\\s*(reference|ref)?\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*$",
          "type": "string"
        },
        {
          "type": "number"
        }
      ],
      "title": "Speed"
    },
    "temperature": {
      "description": "A temperature.",
      "oneOf": [
        {
          "pattern": "^\\s*(reference|ref)?\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*$",
          "type": "string"
        },
        {
          "type": "number"
        }
      ],
      "title": "Temperature"
    },
    "time": {
      "description": "A time.",
      "oneOf": [
        {
          "pattern": "^\\s*(reference|ref)?\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*$",
          "type": "string"
        },
        {
          "type": "number"
        }
      ],
      "title": "Time"
    },
    "volume": {
      "description": "A volume.",
      "oneOf": [
        {
          "pattern": "^\\s*(reference|ref)?\\s*([+-]?[0-9_ ]*\\.?[0-9_ ]+?(?:e(?:\\+|-)?[.0-9]+)?)[ \\t]*([^0-9\\s.](?:.*?[^.])?)?\\s*$",
          "type": "string"
        },
        {
          "type": "number"
        }
      ],
      "title": "Volume"
    }
  },
  "required": [
    "meshes",
    "equations",
    "parameters",
    "unknowns",
    "functions",
    "solve"
  ]
}
