From 764f71f41fc8934733df44d2adcba1d1e14c4e4e Mon Sep 17 00:00:00 2001 From: James Gardner Date: Wed, 3 Nov 2021 15:51:10 +0000 Subject: [PATCH] docs: fix examples --- docs/src/dynamicssimulations/dynamicsmethods/nrpmd.md | 2 +- docs/src/dynamicssimulations/dynamicsmethods/rpsh.md | 3 ++- docs/src/ensemble_simulations.md | 2 +- docs/src/examples/spinboson.md | 2 +- docs/src/examples/threestatemorse.md | 5 +++-- docs/src/examples/tully_scattering.md | 8 +++++++- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/src/dynamicssimulations/dynamicsmethods/nrpmd.md b/docs/src/dynamicssimulations/dynamicsmethods/nrpmd.md index daef30805..5f3acdf6c 100644 --- a/docs/src/dynamicssimulations/dynamicsmethods/nrpmd.md +++ b/docs/src/dynamicssimulations/dynamicsmethods/nrpmd.md @@ -142,7 +142,7 @@ like to average the results so we use the `MeanReduction`. ```@example nrpmd output = Ensembles.OutputDiabaticPopulation(sim) -reduction = Ensembles.MeanReduction() +reduction = Ensembles.MeanReduction([zeros(2) for _ in 1:0.1:30]) nothing # hide ``` diff --git a/docs/src/dynamicssimulations/dynamicsmethods/rpsh.md b/docs/src/dynamicssimulations/dynamicsmethods/rpsh.md index 7b1186bd4..fa6c2fef6 100644 --- a/docs/src/dynamicssimulations/dynamicsmethods/rpsh.md +++ b/docs/src/dynamicssimulations/dynamicsmethods/rpsh.md @@ -59,7 +59,8 @@ and it will be averaged over all trajectories by the `MeanReduction`. ```@example rpsh solution = Ensembles.run_ensemble(sim, (0.0, 3000.0), distribution; saveat=50, trajectories=5e2, dt=1, - output=Ensembles.OutputDiabaticPopulation(sim), reduction=Ensembles.MeanReduction()) + output=Ensembles.OutputDiabaticPopulation(sim), + reduction=Ensembles.MeanReduction([zeros(2) for _=0:3000])) ``` !!! note diff --git a/docs/src/ensemble_simulations.md b/docs/src/ensemble_simulations.md index 259e82de7..c4476a5b2 100644 --- a/docs/src/ensemble_simulations.md +++ b/docs/src/ensemble_simulations.md @@ -37,7 +37,7 @@ Here we choose to output the populations of each diabatic state and reduce by av the results over all trajectories. ```@example ensemble output = Ensembles.OutputDiabaticPopulation(sim) -reduction = Ensembles.MeanReduction() +reduction = Ensembles.MeanReduction([zeros(2) for _ in 0:10:3000]) nothing # hide ``` diff --git a/docs/src/examples/spinboson.md b/docs/src/examples/spinboson.md index 7cabe436a..69843b405 100644 --- a/docs/src/examples/spinboson.md +++ b/docs/src/examples/spinboson.md @@ -33,7 +33,7 @@ analytic form and we can use the distributions included in the package. ```@example spinboson position = PositionHarmonicWigner.(model.ωⱼ, β, 1) velocity = VelocityHarmonicWigner.(model.ωⱼ, β, 1) -distribution = DynamicalDistribution(velocity, position, (1, 100))) * SingleState(1) +distribution = DynamicalDistribution(velocity, position, (1, 100)) * SingleState(1) nothing # hide ``` diff --git a/docs/src/examples/threestatemorse.md b/docs/src/examples/threestatemorse.md index b55be0d01..88d4b8e9f 100644 --- a/docs/src/examples/threestatemorse.md +++ b/docs/src/examples/threestatemorse.md @@ -66,14 +66,15 @@ The [`OutputDiabaticPopulation`](@ref Ensembles.OutputDiabaticPopulation) will e the diabatic population estimator at each timestep. ```@example threestatemorse +reduction = Ensembles.MeanReduction([zeros(3) for _=1:10:3000]) sim = Simulation{FSSH}(atoms, model) fssh_result = Ensembles.run_ensemble(sim, (0.0, 3000.0), distribution; saveat=10, trajectories=1e3, - output=Ensembles.OutputDiabaticPopulation(sim), reduction=Ensembles.MeanReduction(), dt=1) + output=Ensembles.OutputDiabaticPopulation(sim), reduction=reduction, dt=1) sim = Simulation{Ehrenfest}(atoms, model) ehrenfest_result = Ensembles.run_ensemble(sim, (0.0, 3000.0), distribution; saveat=10, trajectories=1e3, - output=Ensembles.OutputDiabaticPopulation(sim), reduction=Ensembles.MeanReduction(), dt=1) + output=Ensembles.OutputDiabaticPopulation(sim), reduction=reduction, dt=1) fig = Figure() ax = Axis(fig[1,1], xlabel="Time /a.u.", ylabel="Population") diff --git a/docs/src/examples/tully_scattering.md b/docs/src/examples/tully_scattering.md index c6144939f..2d957e0d9 100644 --- a/docs/src/examples/tully_scattering.md +++ b/docs/src/examples/tully_scattering.md @@ -16,8 +16,14 @@ We can use our [`Ensembles`](@ref) setup to run a set of trajectories for every momentum value. Firstly, we can prepare the parts that will be the same for every ensemble: ```@example tullymodeltwo +using ComponentArrays: ComponentVector + output = Ensembles.OutputStateResolvedScattering1D(sim, :adiabatic) -reduction = Ensembles.MeanReduction() +template = ComponentVector( + reflection=zeros(2), + transmission=zeros(2) +) +reduction = Ensembles.MeanReduction(templates) ``` Here we are using the [`OutputStateResolvedScattering1D`](@ref Ensembles.OutputStateResolvedScattering1D)