Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions benchmarks/benchmark_optim_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ def setup(self, model, parameter_set, optimiser):
# Define fitting parameters
parameter_values.update(
{
"Negative electrode active material volume fraction": pybop.Parameter(
prior=pybop.Gaussian(0.6, 0.02),
bounds=[0.375, 0.7],
"Negative electrode active material volume fraction": pybop.ParameterDistribution(
pybop.Gaussian(0.6, 0.02, truncated_at=[0.375, 0.7]),
initial_value=0.63,
),
"Positive electrode active material volume fraction": pybop.Parameter(
prior=pybop.Gaussian(0.5, 0.02),
bounds=[0.375, 0.625],
"Positive electrode active material volume fraction": pybop.ParameterDistribution(
pybop.Gaussian(0.5, 0.02, truncated_at=[0.375, 0.625]),
initial_value=0.51,
),
}
Expand Down
10 changes: 4 additions & 6 deletions benchmarks/benchmark_parameterisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ def setup(self, model, parameter_set, optimiser):
# Define fitting parameters
parameter_values.update(
{
"Negative electrode active material volume fraction": pybop.Parameter(
prior=pybop.Gaussian(0.55, 0.03),
bounds=[0.375, 0.7],
"Negative electrode active material volume fraction": pybop.ParameterDistribution(
pybop.Gaussian(0.55, 0.03, truncated_at=[0.375, 0.7]),
),
"Positive electrode active material volume fraction": pybop.Parameter(
prior=pybop.Gaussian(0.55, 0.03),
bounds=[0.375, 0.7],
"Positive electrode active material volume fraction": pybop.ParameterDistribution(
pybop.Gaussian(0.55, 0.03, truncated_at=[0.375, 0.7]),
),
}
)
Expand Down
10 changes: 4 additions & 6 deletions benchmarks/benchmark_track_parameterisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ def setup(self, model, parameter_set, optimiser):
# Define fitting parameters
parameter_values.update(
{
"Negative electrode active material volume fraction": pybop.Parameter(
prior=pybop.Gaussian(0.55, 0.03),
bounds=[0.375, 0.7],
"Negative electrode active material volume fraction": pybop.ParameterDistribution(
pybop.Gaussian(0.55, 0.03, truncated_at=[0.375, 0.7]),
),
"Positive electrode active material volume fraction": pybop.Parameter(
prior=pybop.Gaussian(0.55, 0.03),
bounds=[0.375, 0.7],
"Positive electrode active material volume fraction": pybop.ParameterDistribution(
pybop.Gaussian(0.55, 0.03, truncated_at=[0.375, 0.7]),
),
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,11 @@
"outputs": [],
"source": [
"parameters = {\n",
" \"Negative electrode thickness [m]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(8.52e-05, 0.05e-05),\n",
" bounds=[75e-06, 95e-06],\n",
" \"Negative electrode thickness [m]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(8.52e-05, 0.05e-05, truncated_at=[75e-06, 95e-06]),\n",
" ),\n",
" \"Positive electrode thickness [m]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(7.56e-05, 0.05e-05),\n",
" bounds=[65e-06, 85e-06],\n",
" \"Positive electrode thickness [m]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(7.56e-05, 0.05e-05, truncated_at=[65e-06, 85e-06]),\n",
" ),\n",
"}\n",
"true_values = [parameter_values[p] for p in parameters.keys()]\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,14 @@
"source": [
"parameter_values.update(\n",
" {\n",
" \"R0 [Ohm]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(3e-3, 1e-3),\n",
" bounds=[1e-5, 1e-2],\n",
" \"R0 [Ohm]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(3e-3, 1e-3, truncated_at=[1e-5, 1e-2]),\n",
" ),\n",
" \"R1 [Ohm]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(5e-3, 1e-3),\n",
" bounds=[1e-5, 1e-2],\n",
" \"R1 [Ohm]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(5e-3, 1e-3, truncated_at=[1e-5, 1e-2]),\n",
" ),\n",
" \"R2 [Ohm]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(1e-4, 5e-5),\n",
" bounds=[1e-5, 1e-2],\n",
" \"R2 [Ohm]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(1e-4, 5e-5, truncated_at=[1e-5, 1e-2]),\n",
" ),\n",
" }\n",
")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,25 +273,20 @@
"r0_guess = 0.005\n",
"parameter_values.update(\n",
" {\n",
" \"R0 [Ohm]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(r0_guess, r0_guess / 10),\n",
" bounds=[0, 0.1],\n",
" \"R0 [Ohm]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(r0_guess, r0_guess / 10, truncated_at=[0, 0.1]),\n",
" ),\n",
" \"R1 [Ohm]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(r0_guess, r0_guess / 10),\n",
" bounds=[0, 0.1],\n",
" \"R1 [Ohm]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(r0_guess, r0_guess / 10, truncated_at=[0, 0.1]),\n",
" ),\n",
" \"C1 [F]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(500, 100),\n",
" bounds=[100, 1000],\n",
" \"R2 [Ohm]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(r0_guess, r0_guess / 10, truncated_at=[0, 0.1]),\n",
" ),\n",
" \"R2 [Ohm]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(r0_guess, r0_guess / 10),\n",
" bounds=[0, 0.1],\n",
" \"C1 [F]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(500, 100, truncated_at=[100, 1000]),\n",
" ),\n",
" \"C2 [F]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(2000, 500),\n",
" bounds=[1000, 10000],\n",
" \"C2 [F]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(2000, 500, truncated_at=[1000, 10000]),\n",
" ),\n",
" }\n",
")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,14 @@
"source": [
"parameter_values.update(\n",
" {\n",
" \"R0 [Ohm]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(1e-2, 1e-3),\n",
" bounds=[1e-3, 1e-1],\n",
" \"R0 [Ohm]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(1e-2, 1e-3, truncated_at=[1e-3, 1e-1]),\n",
" ),\n",
" \"R1 [Ohm]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(4e-3, 1e-4),\n",
" bounds=[1e-5, 1e-2],\n",
" \"R1 [Ohm]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(4e-3, 1e-4, truncated_at=[1e-5, 1e-2]),\n",
" ),\n",
" \"C1 [F]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(7000, 300),\n",
" bounds=[1e3, 1e5],\n",
" \"C1 [F]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(7000, 300, truncated_at=[1e3, 1e5]),\n",
" ),\n",
" }\n",
")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,13 @@
"source": [
"parameter_values.update(\n",
" {\n",
" \"Initial SoC\": pybop.Parameter(\n",
" prior=pybop.Uniform(0, 0.5),\n",
" \"Initial SoC\": pybop.ParameterDistribution(\n",
" pybop.Uniform(0, 0.5),\n",
" initial_value=0.05,\n",
" bounds=[0, 0.5],\n",
" ),\n",
" \"Cell capacity [A.h]\": pybop.Parameter(\n",
" \"Cell capacity [A.h]\": pybop.ParameterDistribution(\n",
" pybop.Uniform(0.01, 50),\n",
" initial_value=20,\n",
" prior=pybop.Uniform(0.01, 50),\n",
" bounds=[0.01, 50],\n",
" ),\n",
" }\n",
")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
"source": [
"## Identifying the parameters\n",
"\n",
"Now that the initial parameter values and model are defined, we can start the PyBOP fitting process. In this example, we are going to try to fit all five resistance and capacitance parameters at once. To do this, we define a `pybop.Parameter` for each fitting parameter and compile them into a list."
"Now that the initial parameter values and model are defined, we can start the PyBOP fitting process. In this example, we are going to try to fit all five resistance and capacitance parameters at once. To do this, we define a `pybop.ParameterDistribution` for each fitting parameter and compile them into a list."
]
},
{
Expand All @@ -280,25 +280,20 @@
"source": [
"parameter_values.update(\n",
" {\n",
" \"R0 [Ohm]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(0.005, 0.0001),\n",
" bounds=[1e-6, 2e-1],\n",
" \"R0 [Ohm]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(0.005, 0.0001, truncated_at=[1e-6, 2e-1]),\n",
" ),\n",
" \"R1 [Ohm]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(0.0001, 0.0001),\n",
" bounds=[1e-6, 1],\n",
" \"R1 [Ohm]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(0.0001, 0.0001, truncated_at=[1e-6, 1]),\n",
" ),\n",
" \"R2 [Ohm]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(0.0001, 0.0001),\n",
" bounds=[1e-6, 1],\n",
" \"R2 [Ohm]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(0.0001, 0.0001, truncated_at=[1e-6, 1]),\n",
" ),\n",
" \"C1 [F]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(3000, 2500),\n",
" bounds=[0.5, 1e4],\n",
" \"C1 [F]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(3000, 2500, truncated_at=[0.5, 1e4]),\n",
" ),\n",
" \"C2 [F]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(3000, 2500),\n",
" bounds=[0.5, 1e4],\n",
" \"C2 [F]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(3000, 2500, truncated_at=[0.5, 1e4]),\n",
" ),\n",
" }\n",
")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
"source": [
"## Identifying the parameters\n",
"\n",
"To set up the parameter estimation process, we select the parameters for estimation and set up their prior distributions and bounds."
"To set up the parameter estimation process, we select the parameters for estimation and set up their distributions and bounds."
]
},
{
Expand All @@ -158,13 +158,11 @@
"source": [
"parameter_values.update(\n",
" {\n",
" \"Negative electrode active material volume fraction\": pybop.Parameter(\n",
" prior=pybop.Gaussian(0.7, 0.05),\n",
" bounds=[0.45, 0.9],\n",
" \"Negative electrode active material volume fraction\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(0.7, 0.05, truncated_at=[0.45, 0.9]),\n",
" ),\n",
" \"Positive electrode active material volume fraction\": pybop.Parameter(\n",
" prior=pybop.Gaussian(0.58, 0.05),\n",
" bounds=[0.5, 0.8],\n",
" \"Positive electrode active material volume fraction\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(0.58, 0.05, truncated_at=[0.5, 0.8]),\n",
" ),\n",
" }\n",
")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,11 @@
"source": [
"parameter_values.update(\n",
" {\n",
" \"Positive electrode thickness [m]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(7.56e-05, 0.5e-05),\n",
" bounds=[65e-06, 10e-05],\n",
" \"Positive electrode thickness [m]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(7.56e-05, 0.5e-05, truncated_at=[65e-06, 10e-05]),\n",
" ),\n",
" \"Positive particle radius [m]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(5.22e-06, 0.5e-06),\n",
" bounds=[2e-06, 9e-06],\n",
" \"Positive particle radius [m]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(5.22e-06, 0.5e-06, truncated_at=[2e-06, 9e-06]),\n",
" ),\n",
" }\n",
")\n",
Expand Down Expand Up @@ -215,7 +213,7 @@
}
],
"source": [
"samples = simulator.parameters.sample_from_priors(2)\n",
"samples = simulator.parameters.sample_from_distributions(2)\n",
"print(\"Samples:\", samples)\n",
"inputs = [simulator.parameters.to_dict(s) for s in samples]\n",
"solution = simulator.solve(inputs)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"source": [
"## Identifying the parameters\n",
"\n",
"We select the parameters for estimation and set up their prior distributions and bounds:"
"We select the parameters for estimation and set up their distributions and bounds:"
]
},
{
Expand All @@ -121,10 +121,10 @@
"outputs": [],
"source": [
"parameters = {\n",
" \"Negative electrode active material volume fraction\": pybop.Parameter(\n",
" \"Negative electrode active material volume fraction\": pybop.ParameterInfo(\n",
" initial_value=0.5,\n",
" ),\n",
" \"Positive electrode active material volume fraction\": pybop.Parameter(\n",
" \"Positive electrode active material volume fraction\": pybop.ParameterInfo(\n",
" initial_value=0.5,\n",
" ),\n",
"}\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"id": "ffS3CF_704qA"
},
"source": [
"Next, we define the model parameters for optimisation. Furthermore, PyBOP provides functionality to define a prior for the parameters. The initial parameters values used in the optimisation will be randomly drawn from the prior distribution."
"Next, we define the model parameters for optimisation. Furthermore, PyBOP provides functionality to define a distribution for the parameters. The initial parameters values used in the optimisation will be randomly drawn from the prior distribution."
]
},
{
Expand All @@ -104,13 +104,11 @@
"source": [
"parameter_values.update(\n",
" {\n",
" \"Positive electrode thickness [m]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(7.56e-05, 0.05e-05),\n",
" bounds=[65e-06, 10e-05],\n",
" \"Positive electrode thickness [m]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(7.56e-05, 0.05e-05, truncated_at=[65e-06, 10e-05]),\n",
" ),\n",
" \"Positive particle radius [m]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(5.22e-06, 0.05e-06),\n",
" bounds=[2e-06, 9e-06],\n",
" \"Positive particle radius [m]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(5.22e-06, 0.05e-06, truncated_at=[2e-06, 9e-06]),\n",
" ),\n",
" }\n",
")"
Expand Down
4 changes: 2 additions & 2 deletions examples/notebooks/getting_started/cost_compute_methods.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@
"source": [
"parameter_values.update(\n",
" {\n",
" \"Negative electrode active material volume fraction\": pybop.Parameter(\n",
" \"Negative electrode active material volume fraction\": pybop.ParameterInfo(\n",
" initial_value=0.6,\n",
" ),\n",
" \"Positive electrode active material volume fraction\": pybop.Parameter(\n",
" \"Positive electrode active material volume fraction\": pybop.ParameterInfo(\n",
" initial_value=0.6,\n",
" ),\n",
" }\n",
Expand Down
8 changes: 4 additions & 4 deletions examples/notebooks/getting_started/maximum_a_posteriori.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@
"outputs": [],
"source": [
"parameters = {\n",
" \"Negative particle radius [m]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(4e-6, 1e-6),\n",
" \"Negative particle radius [m]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(4e-6, 1e-6),\n",
" ),\n",
" \"Positive particle radius [m]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(5e-6, 1e-6),\n",
" \"Positive particle radius [m]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(5e-6, 1e-6),\n",
" ),\n",
"}\n",
"true_values = [parameter_values[p] for p in parameters.keys()]\n",
Expand Down
12 changes: 5 additions & 7 deletions examples/notebooks/getting_started/optimising_with_adamw.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"source": [
"## Identifying the parameters\n",
"\n",
"We select the model parameters for estimation and set up their prior distributions and bounds:"
"We select the model parameters for estimation and set up their distributions and bounds:"
]
},
{
Expand All @@ -112,13 +112,11 @@
"source": [
"parameter_values.update(\n",
" {\n",
" \"Negative electrode active material volume fraction\": pybop.Parameter(\n",
" prior=pybop.Gaussian(0.6, 0.02),\n",
" bounds=[0.5, 0.8],\n",
" \"Negative electrode active material volume fraction\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(0.6, 0.02, truncated_at=[0.5, 0.8]),\n",
" ),\n",
" \"Positive electrode active material volume fraction\": pybop.Parameter(\n",
" prior=pybop.Gaussian(0.48, 0.02),\n",
" bounds=[0.4, 0.7],\n",
" \"Positive electrode active material volume fraction\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(0.48, 0.02, truncated_at=[0.4, 0.7]),\n",
" ),\n",
" }\n",
")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@
"# Define the fitting parameter\n",
"parameter_values.update(\n",
" {\n",
" \"R0 [Ohm]\": pybop.Parameter(\n",
" prior=pybop.Gaussian(0.0002, 0.0001),\n",
" bounds=[1e-4, 1e-2],\n",
" \"R0 [Ohm]\": pybop.ParameterDistribution(\n",
" pybop.Gaussian(\n",
" 0.0002,\n",
" 0.0001,\n",
" truncated_at=[1e-4, 1e-2],\n",
" )\n",
" )\n",
" }\n",
")\n",
Expand Down
Loading