From 626f9acd5a0935cf8d209abc3c326bb0799a3511 Mon Sep 17 00:00:00 2001 From: Frames White Date: Wed, 1 Oct 2025 10:38:00 +0800 Subject: [PATCH 1/2] Add example for getting name of species/parameters --- docs/src/model_creation/dsl_advanced.md | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/src/model_creation/dsl_advanced.md b/docs/src/model_creation/dsl_advanced.md index 3aeb468132..d00c6ed29c 100644 --- a/docs/src/model_creation/dsl_advanced.md +++ b/docs/src/model_creation/dsl_advanced.md @@ -158,6 +158,32 @@ sol = solve(oprob, Tsit5()) plot(sol) ``` Please note that `X₀` is still a parameter of the system, and as such its value must still be designated to simulate the model (even if it is not actually used). +### [Accessing species and parameter names](@id species_and_parameter_names) +Sometimes you may need to access the name for a part of a model as a `Symbol` (which you could then convert to a `String`). +This can be done with `ModelingToolkit.getname`. + +```@example species_and_parameter_names +rn = @reaction_network begin + @species X(t) + @parameters k + k, X --> 0 +end +``` + +```@example species_and_parameter_names +rn.X + +ModelingToolkit.getname(rn.X) + +rn.k + +ModelingToolkit.getname(rn.k) +``` + +For parameters you can also use `nameof` +```@example species_and_parameter_names +nameof(rn.k) +``` ### [Designating metadata for species and parameters](@id dsl_advanced_options_species_and_parameters_metadata) Catalyst permits the user to define *metadata* for species and parameters. This permits the user to assign additional information to these, which can be used for a variety of purposes. Some Catalyst features depend on using metadata (with each such case describing specifically how this is done). Here we will introduce how to set metadata, and describe some common metadata types. From 3733c02981a79fafb8ce38306a33c6e742e6d951 Mon Sep 17 00:00:00 2001 From: Frames White Date: Wed, 1 Oct 2025 10:39:57 +0800 Subject: [PATCH 2/2] whitepace --- docs/src/model_creation/dsl_advanced.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/model_creation/dsl_advanced.md b/docs/src/model_creation/dsl_advanced.md index d00c6ed29c..83e7ba9d2d 100644 --- a/docs/src/model_creation/dsl_advanced.md +++ b/docs/src/model_creation/dsl_advanced.md @@ -158,6 +158,7 @@ sol = solve(oprob, Tsit5()) plot(sol) ``` Please note that `X₀` is still a parameter of the system, and as such its value must still be designated to simulate the model (even if it is not actually used). + ### [Accessing species and parameter names](@id species_and_parameter_names) Sometimes you may need to access the name for a part of a model as a `Symbol` (which you could then convert to a `String`). This can be done with `ModelingToolkit.getname`.