Skip to content

Latest commit

 

History

History
103 lines (61 loc) · 4.2 KB

File metadata and controls

103 lines (61 loc) · 4.2 KB

Functional parameters

Battery models contain functional parameters. The most important one is probably the OCV function, but we have also the ionic conductivity and diffusion in the electrolyte.

The function definitions are given in the input json file, using one of the following formats:

  1. :ref:`Function name <functioninterface:Function name>`
  2. :ref:`Function formula <functioninterface:Function formula>`
  3. :ref:`Tabulated function <functioninterface:Tabulated function>`
  4. :ref:`CSV file <functioninterface:CSV file>`

The json schema that describes the interface is available :battmofile:`here <Utilities/JsonSchemas/Function.schema.json>`.

The keyword to choose the format is given by functionFormat.

The keyword argumentList is common to all the formats and is used to describe the list of arguments that will be sent to the function. The argument names given there are independent to the implementation in itself. They indicates the meaning of the arguments.

Note

After parsing a function can be setup directly using setupFunction, see :ref:`Example of the function interface <nblinks/functionInterfaceExample:Example of the function interface>`

Let us go through each different format separatly. For each format, we start by giving an example.

Function name

.. literalinclude:: exampleCodeSnippets/function_interface_name.json
   :language: json

For a formula, the function format is set to "named function".

With the key "functionName", we give the name of the function. In matlab, this function should then be found in the function path (more on the in matlab documentation).

The key argumentList is used to describe the list of arguments that will be sent to the function. Note that the names do not necessarily to the one used in the implementation itself, as we can check in the implementation of :battmo:`computeOCP_Graphite_Torchio` where the argument there is set to the variable name theta.

Function formula

.. literalinclude:: exampleCodeSnippets/function_interface_string.json
   :language: json

For a formula, the function format is set to "string expression".

The key argumentList is used to describe the list of arguments that will be sent to the functions. Again, it is not related to the actual implementation described under the key expression.

With the key "expression", we give the expression which, once evaluated, will give the value of the function.

The key language is used to provide the programming language that the expression should be evaluated with. The default value is matlab but we aim at a language agnostic interface and we open for the possibility to include an expression using an other language, even if it is not supported in the matlab code.

The key formula is used to give the expression that we will be run and return the value. The variable names should be given using the key variableNames.

You can find an example in the json file :battmofile:`chen2020_positive_electrode_interface.json <ParameterData/ParameterSets/Chen2020/chen2020_positive_electrode_interface.json#10>`.

Tabulated function

.. literalinclude:: exampleCodeSnippets/function_interface_tabulated.json
   :language: json


Tabulated functions are given by a set of point values in the form of a table. Between the given points, the value is obtained by linear interpolation.

For a tabulated function, the function format is set to "tabulated".

The keys dataX and dataY are used to provide the data points of the function.

You can find an example in the json file :battmofile:`LFP_Xu2015.json <ParameterData/MaterialProperties/LFP/LFP_Xu2015.json#11>`

CSV file

.. literalinclude:: exampleCodeSnippets/function_interface_csv.json
   :language: json

We can import CSV file. The file is read and a tabulated function is set up

Example

:ref:`Example script<nblinks/functionInterfaceExample:Example of the function interface>`

.. toctree::
   :hidden:

   nblinks/functionInterfaceExample.ipynb