From d1cda2025fc9225cdad65d735081873253b1f4f0 Mon Sep 17 00:00:00 2001 From: lrennels Date: Sat, 9 Mar 2019 17:31:51 -0800 Subject: [PATCH 1/6] Various fixes for consistency with registry --- README.md | 36 +++++++++++++------ examples/main.jl | 7 ++++ src/MimiFUND.jl | 8 ++++- src/components/BioDiversityComponent.jl | 4 +-- src/components/ClimateCH4CycleComponent.jl | 4 +-- src/components/ClimateCO2CycleComponent.jl | 4 +-- src/components/ClimateDynamicsComponent.jl | 4 +-- src/components/ClimateForcingComponent.jl | 4 +-- src/components/ClimateN2OCycleComponent.jl | 4 +-- src/components/ClimateRegionalComponent.jl | 4 +-- src/components/ClimateSF6CycleComponent.jl | 4 +-- src/components/EmissionsComponent.jl | 4 +-- src/components/GeographyComponent.jl | 4 +-- src/components/ImpactAggregationComponent.jl | 4 +-- src/components/ImpactAgricultureComponent.jl | 4 +-- src/components/ImpactBioDiversityComponent.jl | 4 +-- ...mpactCardiovascularRespiratoryComponent.jl | 4 +-- src/components/ImpactCoolingComponent.jl | 4 +-- .../ImpactDeathMorbidityComponent.jl | 4 +-- src/components/ImpactDiarrhoeaComponent.jl | 4 +-- .../ImpactExtratropicalStormsComponent.jl | 4 +-- src/components/ImpactForestsComponent.jl | 4 +-- src/components/ImpactHeatingComponent.jl | 4 +-- src/components/ImpactSeaLevelRiseComponent.jl | 4 +-- .../ImpactTropicalStormsComponent.jl | 4 +-- .../ImpactVectorBorneDiseasesComponent.jl | 4 +-- .../ImpactWaterResourcesComponent.jl | 4 +-- src/components/OceanComponent.jl | 4 +-- src/components/PopulationComponent.jl | 4 +-- .../ScenarioUncertaintyComponent.jl | 4 +-- src/components/SocioEconomicComponent.jl | 4 +-- src/components/VslVmorbComponent.jl | 2 -- src/components/scenconverter.jl | 2 -- src/main.jl | 9 ----- src/marginaldamage3.jl | 5 --- src/marginaldamages.jl | 5 --- src/montecarlo/defmcs.jl | 3 +- src/montecarlo/run_fund_mcs.jl | 9 ++--- src/montecarlo/run_fund_scc_mcs.jl | 12 +++---- src/new_marginaldamages.jl | 6 ---- test/runtests.jl | 13 ------- 41 files changed, 75 insertions(+), 154 deletions(-) create mode 100644 examples/main.jl delete mode 100644 src/main.jl diff --git a/README.md b/README.md index 3f981dd6..874e8189 100644 --- a/README.md +++ b/README.md @@ -22,25 +22,41 @@ FUND was originally developed by Richard Tol. It is now co-developed by David An The minimum requirement to run FUND is [Julia](http://julialang.org/) and the [Mimi](https://github.com/davidanthoff/Mimi.jl) package. To run the example IJulia notebook file you need to install [IJulia](https://github.com/JuliaLang/IJulia.jl). -### Installing Julia +### Software Requirements -You can download Julia from [http://julialang.org/downloads/](http://julialang.org/downloads/). You should use the v0.6.x version and install it. +You need to install [Julia 1.1.0](https://julialang.org) or newer to run this model. You can download Julia from [http://julialang.org/downloads/](http://julialang.org/downloads/). -### Installing the Mimi package +### Preparing the Software Environment -Start Julia and enter the following command on the Julia prompt: +You first need to connect your julia installation with the central Mimi registry of Mimi models. This central registry is like a catalogue of models that use Mimi that is maintained by the Mimi project. To add this registry, run the following command at the julia package REPL: -````julia -Pkg.add("Mimi") -```` +```julia +pkg> registry add https://github.com/mimiframework/MimiRegistry.git +You only need to run this command once on a computer. +``` + +The next step is to install MimiRICE2010.jl itself. You need to run the following command at the julia package REPL: + +```julia +pkg> add MimiRICE2010 +``` + +You probably also want to install the Mimi package into your julia environment, so that you can use some of the tools in there: + +``` +pkg> add Mimi +``` ### Keeping requirements up-to-date (optional) Many of these requirements are regularly updated. To make sure you have the latest versions, periodically execute the following command on the Julia prompt: -````julia -Pkg.update() -```` +```julia +pkg> up +``` +##Running the model + +The model uses the Mimi framework and it is highly recommended to read the Mimi documentation first to understand the code structure. For starter code on running the model just once, see the code in the file `examples/main.jl`. ## Versions and academic use policy diff --git a/examples/main.jl b/examples/main.jl new file mode 100644 index 00000000..ae8e768b --- /dev/null +++ b/examples/main.jl @@ -0,0 +1,7 @@ +using Mimi +using MimiFUND + +m = getfund() +run(m) + +explore(m) diff --git a/src/MimiFUND.jl b/src/MimiFUND.jl index 58945d8b..539654e6 100644 --- a/src/MimiFUND.jl +++ b/src/MimiFUND.jl @@ -5,6 +5,11 @@ using DelimitedFiles #base.DelimitedFiles include("helper.jl") +include("new_marginaldamages.jl") +include("montecarlo/defmcs.jl") +include("montecarlo/run_fund_mcs.jl") +include("montecarlo/run_fund_scc_mcs.jl") + include("components/SocioEconomicComponent.jl") include("components/PopulationComponent.jl") include("components/EmissionsComponent.jl") @@ -36,7 +41,8 @@ include("components/ImpactAggregationComponent.jl") include("components/VslVmorbComponent.jl") export - getfund # Function that returns a version of fund allowing for different user specifications + getfund, get_social_cost, getmarginaldamages, getmcs, run_fund_mcs, run_fund_scc_mcs + # getfund is a Function that returns a version of fund allowing for different user specifications const global default_nsteps = 1050 diff --git a/src/components/BioDiversityComponent.jl b/src/components/BioDiversityComponent.jl index 05c50a7e..f17a5788 100644 --- a/src/components/BioDiversityComponent.jl +++ b/src/components/BioDiversityComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp biodiversity begin +@defcomp biodiversity begin # Number of species nospecies = Variable(index=[time]) diff --git a/src/components/ClimateCH4CycleComponent.jl b/src/components/ClimateCH4CycleComponent.jl index e92ee21b..813d2daf 100644 --- a/src/components/ClimateCH4CycleComponent.jl +++ b/src/components/ClimateCH4CycleComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp climatech4cycle begin +@defcomp climatech4cycle begin # Global CH4 emissions in Mt of CH4 globch4 = Parameter(index=[time]) diff --git a/src/components/ClimateCO2CycleComponent.jl b/src/components/ClimateCO2CycleComponent.jl index ffff7fe7..b2b87331 100644 --- a/src/components/ClimateCO2CycleComponent.jl +++ b/src/components/ClimateCO2CycleComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp climateco2cycle begin +@defcomp climateco2cycle begin # Anthropogenic CO2 emissions in Mt of C mco2 = Parameter(index=[time]) diff --git a/src/components/ClimateDynamicsComponent.jl b/src/components/ClimateDynamicsComponent.jl index 5c79b3bd..c3202fd1 100644 --- a/src/components/ClimateDynamicsComponent.jl +++ b/src/components/ClimateDynamicsComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp climatedynamics begin +@defcomp climatedynamics begin # Total radiative forcing radforc = Parameter(index=[time]) diff --git a/src/components/ClimateForcingComponent.jl b/src/components/ClimateForcingComponent.jl index 51285794..be891b62 100644 --- a/src/components/ClimateForcingComponent.jl +++ b/src/components/ClimateForcingComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -function interact(M, N) +function interact(M, N) d = 1.0 + (M * N)^0.75 * 2.01E-5 + (M * N)^1.52 * M * 5.31E-15 return 0.47 * log(d) end diff --git a/src/components/ClimateN2OCycleComponent.jl b/src/components/ClimateN2OCycleComponent.jl index 69027273..4dda8b47 100644 --- a/src/components/ClimateN2OCycleComponent.jl +++ b/src/components/ClimateN2OCycleComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp climaten2ocycle begin +@defcomp climaten2ocycle begin # Global N2O emissions in Mt of N globn2o = Parameter(index=[time]) diff --git a/src/components/ClimateRegionalComponent.jl b/src/components/ClimateRegionalComponent.jl index 2e508b5f..1c8b1444 100644 --- a/src/components/ClimateRegionalComponent.jl +++ b/src/components/ClimateRegionalComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp climateregional begin +@defcomp climateregional begin regions = Index() inputtemp = Parameter(index=[time]) bregtmp = Parameter(index=[regions]) diff --git a/src/components/ClimateSF6CycleComponent.jl b/src/components/ClimateSF6CycleComponent.jl index 0fe8d602..5918a090 100644 --- a/src/components/ClimateSF6CycleComponent.jl +++ b/src/components/ClimateSF6CycleComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp climatesf6cycle begin +@defcomp climatesf6cycle begin # Global SF6 emissions in kt of SF6 globsf6 = Parameter(index=[time]) diff --git a/src/components/EmissionsComponent.jl b/src/components/EmissionsComponent.jl index 6e8670f4..e5b13705 100644 --- a/src/components/EmissionsComponent.jl +++ b/src/components/EmissionsComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp emissions begin +@defcomp emissions begin regions = Index() mitigationcost = Variable(index=[time,regions]) diff --git a/src/components/GeographyComponent.jl b/src/components/GeographyComponent.jl index 22c99314..be403958 100644 --- a/src/components/GeographyComponent.jl +++ b/src/components/GeographyComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp geography begin +@defcomp geography begin regions = Index() area = Variable(index=[time,regions]) diff --git a/src/components/ImpactAggregationComponent.jl b/src/components/ImpactAggregationComponent.jl index 6f8bcd40..821eebc3 100644 --- a/src/components/ImpactAggregationComponent.jl +++ b/src/components/ImpactAggregationComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp impactaggregation begin +@defcomp impactaggregation begin regions = Index() eloss = Variable(index=[time,regions]) diff --git a/src/components/ImpactAgricultureComponent.jl b/src/components/ImpactAgricultureComponent.jl index 51ca28d9..d634d776 100644 --- a/src/components/ImpactAgricultureComponent.jl +++ b/src/components/ImpactAgricultureComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp impactagriculture begin +@defcomp impactagriculture begin regions = Index() gdp90 = Parameter(index=[regions]) diff --git a/src/components/ImpactBioDiversityComponent.jl b/src/components/ImpactBioDiversityComponent.jl index f6ac535f..afa40f6c 100644 --- a/src/components/ImpactBioDiversityComponent.jl +++ b/src/components/ImpactBioDiversityComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp impactbiodiversity begin +@defcomp impactbiodiversity begin regions = Index() # Change in number of species in relation to the year 2000 diff --git a/src/components/ImpactCardiovascularRespiratoryComponent.jl b/src/components/ImpactCardiovascularRespiratoryComponent.jl index b2416114..89db6680 100644 --- a/src/components/ImpactCardiovascularRespiratoryComponent.jl +++ b/src/components/ImpactCardiovascularRespiratoryComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp impactcardiovascularrespiratory begin +@defcomp impactcardiovascularrespiratory begin regions = Index() basecardvasc = Variable(index=[time,regions]) diff --git a/src/components/ImpactCoolingComponent.jl b/src/components/ImpactCoolingComponent.jl index 6ea8aa89..c0dcd4c2 100644 --- a/src/components/ImpactCoolingComponent.jl +++ b/src/components/ImpactCoolingComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp impactcooling begin +@defcomp impactcooling begin regions = Index() cooling = Variable(index=[time,regions]) diff --git a/src/components/ImpactDeathMorbidityComponent.jl b/src/components/ImpactDeathMorbidityComponent.jl index a1417efd..5e7b3e2e 100644 --- a/src/components/ImpactDeathMorbidityComponent.jl +++ b/src/components/ImpactDeathMorbidityComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp impactdeathmorbidity begin +@defcomp impactdeathmorbidity begin regions = Index() dead = Variable(index=[time,regions]) diff --git a/src/components/ImpactDiarrhoeaComponent.jl b/src/components/ImpactDiarrhoeaComponent.jl index 80e2689a..25bfb51c 100644 --- a/src/components/ImpactDiarrhoeaComponent.jl +++ b/src/components/ImpactDiarrhoeaComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp impactdiarrhoea begin +@defcomp impactdiarrhoea begin regions = Index() diadead = Variable(index=[time,regions]) diff --git a/src/components/ImpactExtratropicalStormsComponent.jl b/src/components/ImpactExtratropicalStormsComponent.jl index 4b8650a0..22c225cb 100644 --- a/src/components/ImpactExtratropicalStormsComponent.jl +++ b/src/components/ImpactExtratropicalStormsComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp impactextratropicalstorms begin +@defcomp impactextratropicalstorms begin regions = Index() extratropicalstormsdam = Variable(index=[time,regions]) diff --git a/src/components/ImpactForestsComponent.jl b/src/components/ImpactForestsComponent.jl index e3f70962..a16ec4c9 100644 --- a/src/components/ImpactForestsComponent.jl +++ b/src/components/ImpactForestsComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp impactforests begin +@defcomp impactforests begin regions = Index() forests = Variable(index=[time,regions]) diff --git a/src/components/ImpactHeatingComponent.jl b/src/components/ImpactHeatingComponent.jl index 1978450f..e18ab689 100644 --- a/src/components/ImpactHeatingComponent.jl +++ b/src/components/ImpactHeatingComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp impactheating begin +@defcomp impactheating begin regions = Index() heating = Variable(index=[time,regions]) diff --git a/src/components/ImpactSeaLevelRiseComponent.jl b/src/components/ImpactSeaLevelRiseComponent.jl index d9aecdc4..b1de754d 100644 --- a/src/components/ImpactSeaLevelRiseComponent.jl +++ b/src/components/ImpactSeaLevelRiseComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp impactsealevelrise begin +@defcomp impactsealevelrise begin regions = Index() wetval = Variable(index=[time,regions]) # Valuation of wetlands diff --git a/src/components/ImpactTropicalStormsComponent.jl b/src/components/ImpactTropicalStormsComponent.jl index 9daa2e27..dea26aab 100644 --- a/src/components/ImpactTropicalStormsComponent.jl +++ b/src/components/ImpactTropicalStormsComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp impacttropicalstorms begin +@defcomp impacttropicalstorms begin regions = Index() hurrdam = Variable(index=[time,regions]) diff --git a/src/components/ImpactVectorBorneDiseasesComponent.jl b/src/components/ImpactVectorBorneDiseasesComponent.jl index 79e05350..c8635a06 100644 --- a/src/components/ImpactVectorBorneDiseasesComponent.jl +++ b/src/components/ImpactVectorBorneDiseasesComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp impactvectorbornediseases begin +@defcomp impactvectorbornediseases begin regions = Index() dengue = Variable(index=[time,regions]) diff --git a/src/components/ImpactWaterResourcesComponent.jl b/src/components/ImpactWaterResourcesComponent.jl index 526d4014..caa38ed7 100644 --- a/src/components/ImpactWaterResourcesComponent.jl +++ b/src/components/ImpactWaterResourcesComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp impactwaterresources begin +@defcomp impactwaterresources begin regions = Index() watech = Variable(index=[time]) diff --git a/src/components/OceanComponent.jl b/src/components/OceanComponent.jl index e7648e89..9610a4a8 100644 --- a/src/components/OceanComponent.jl +++ b/src/components/OceanComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp ocean begin +@defcomp ocean begin # Sea-level rise in meters sea = Variable(index=[time]) diff --git a/src/components/PopulationComponent.jl b/src/components/PopulationComponent.jl index 28ea5eba..bf4f770e 100644 --- a/src/components/PopulationComponent.jl +++ b/src/components/PopulationComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp population begin +@defcomp population begin regions = Index() population = Variable(index=[time,regions]) diff --git a/src/components/ScenarioUncertaintyComponent.jl b/src/components/ScenarioUncertaintyComponent.jl index 4dcbe202..b06258c9 100644 --- a/src/components/ScenarioUncertaintyComponent.jl +++ b/src/components/ScenarioUncertaintyComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp scenariouncertainty begin +@defcomp scenariouncertainty begin regions = Index() pgrowth = Variable(index=[time,regions]) diff --git a/src/components/SocioEconomicComponent.jl b/src/components/SocioEconomicComponent.jl index 02d9c451..0a085e3e 100644 --- a/src/components/SocioEconomicComponent.jl +++ b/src/components/SocioEconomicComponent.jl @@ -1,6 +1,4 @@ -using Mimi - -@defcomp socioeconomic begin +@defcomp socioeconomic begin regions = Index() income = Variable(index=[time,regions]) diff --git a/src/components/VslVmorbComponent.jl b/src/components/VslVmorbComponent.jl index 69165602..3cabbf65 100644 --- a/src/components/VslVmorbComponent.jl +++ b/src/components/VslVmorbComponent.jl @@ -1,5 +1,3 @@ -using Mimi - @defcomp vslvmorb begin regions = Index() diff --git a/src/components/scenconverter.jl b/src/components/scenconverter.jl index 83c4a47d..24b5600c 100644 --- a/src/components/scenconverter.jl +++ b/src/components/scenconverter.jl @@ -1,5 +1,3 @@ -using Mimi - @defcomp scenconverter begin regions = Index() diff --git a/src/main.jl b/src/main.jl deleted file mode 100644 index e4edf58e..00000000 --- a/src/main.jl +++ /dev/null @@ -1,9 +0,0 @@ -using Mimi - -include("fund.jl") -using .Fund - -m = getfund() -run(m) - -explore(m) \ No newline at end of file diff --git a/src/marginaldamage3.jl b/src/marginaldamage3.jl index 827d721f..7295cc81 100644 --- a/src/marginaldamage3.jl +++ b/src/marginaldamage3.jl @@ -1,8 +1,3 @@ -using Mimi -include("helper.jl") -include("fund.jl") -using .Fund - """ Returns one default FUND model and one model with additional emissions of the specified gas in the specified year. """ diff --git a/src/marginaldamages.jl b/src/marginaldamages.jl index 5fedc71c..e8535bea 100644 --- a/src/marginaldamages.jl +++ b/src/marginaldamages.jl @@ -1,8 +1,3 @@ -using Mimi -include("helper.jl") -include("fund.jl") -using .Fund - """ Returns a matrix of marginal damages per one ton of additional emissions of the specified gas in the specified year. """ diff --git a/src/montecarlo/defmcs.jl b/src/montecarlo/defmcs.jl index 84593535..3775ffdd 100644 --- a/src/montecarlo/defmcs.jl +++ b/src/montecarlo/defmcs.jl @@ -1,9 +1,8 @@ -using Mimi using Distributions function getmcs() - mcs = @defmcs begin + mcs = @defsim begin aceiadd = ["USA" => Normal(0.0,0.025), "CAN" => Normal(0.0,0.025), "WEU" => Normal(0.0,0.025), "JPK" => Normal(0.0,0.0375), "ANZ" => Normal(0.0,0.0375), "EEU" => Normal(0.0,0.025), "FSU" => Normal(0.0,0.025), "MDE" => Normal(0.0,0.0875), "CAM" => Normal(0.0,0.05625), "LAM" => Normal(0.0,0.05625), "SAS" => Normal(0.0,0.0875), "SEA" => Normal(0.0,0.0875), "CHI" => Normal(0.0,0.0375), "MAF" => Normal(0.0,0.11875), "SSA" => Normal(0.0,0.11875), "SIS" => Normal(0.0,0.05625)] aeeiadd = ["USA" => Normal(0.0,0.0625), "CAN" => Normal(0.0,0.0625), "WEU" => Normal(0.0,0.0625), "JPK" => Normal(0.0,0.0625), "ANZ" => Normal(0.0,0.0625), "EEU" => Normal(0.0,0.1), "FSU" => Normal(0.0,0.1), "MDE" => Normal(0.0,0.15), "CAM" => Normal(0.0,0.15), "LAM" => Normal(0.0,0.15), "SAS" => Normal(0.0,0.15), "SEA" => Normal(0.0,0.15), "CHI" => Normal(0.0,0.175), "MAF" => Normal(0.0,0.15), "SSA" => Normal(0.0,0.15), "SIS" => Normal(0.0,0.15)] diff --git a/src/montecarlo/run_fund_mcs.jl b/src/montecarlo/run_fund_mcs.jl index b43e52ed..3423c9eb 100644 --- a/src/montecarlo/run_fund_mcs.jl +++ b/src/montecarlo/run_fund_mcs.jl @@ -1,10 +1,5 @@ -using Mimi using Dates -include(joinpath(@__DIR__, "defmcs.jl")) -include(joinpath(@__DIR__, "../fund.jl")) -using .Fund - """ Runs a Monte Carlo simulation with the FUND model over it's distributional parameters. `trials`: the number of trials to run. @@ -12,7 +7,7 @@ Runs a Monte Carlo simulation with the FUND model over it's distributional param `output_dir`: an output directory; if none provided, will create and use "output/yyyy-mm-dd HH-MM-SS MCtrials". `save_trials`: whether or not to generate and save the MC trial values up front to a file. """ -function run_fund_mcs(trials = 10000; ntimesteps = Fund.default_nsteps + 1, output_dir = nothing, save_trials = false) +function run_fund_mcs(trials = 10000; ntimesteps = MimiFUND.default_nsteps + 1, output_dir = nothing, save_trials = false) # Set up output directories output_dir = output_dir == nothing ? joinpath(@__DIR__, "../../output/", "SCC $(Dates.format(now(), "yyyy-mm-dd HH-MM-SS")) MC$trials") : output_dir @@ -28,7 +23,7 @@ function run_fund_mcs(trials = 10000; ntimesteps = Fund.default_nsteps + 1, outp # Run monte carlo trials set_models!(mcs, getfund()) - run_mcs(mcs, trials; ntimesteps = ntimesteps, output_dir = "$output_dir/results") + run_sim(mcs, trials; ntimesteps = ntimesteps, output_dir = "$output_dir/results") return nothing end diff --git a/src/montecarlo/run_fund_scc_mcs.jl b/src/montecarlo/run_fund_scc_mcs.jl index f75da727..9e643f44 100644 --- a/src/montecarlo/run_fund_scc_mcs.jl +++ b/src/montecarlo/run_fund_scc_mcs.jl @@ -1,9 +1,5 @@ -using Mimi using Dates -include(joinpath(@__DIR__, "defmcs.jl")) # Defines FUND's distributional parameters -include(joinpath(@__DIR__, "../new_marginaldamages.jl")) # Defines FUND's marginal emissions model - """ Runs a Monte Carlo simulation with the FUND model over it's distirbutional parameters, and calculates the Social Cost of Carbon for the specified `years` and discount `rates`. @@ -12,7 +8,7 @@ the Social Cost of Carbon for the specified `years` and discount `rates`. `output_dir`: an output directory; if none provided, will create and use "output/SCC yyyy-mm-dd HH-MM-SS MCtrials". `save_trials`: whether or not to generate and save the MC trial values up front to a file. """ -function run_fund_scc_mcs(trials = 10000; years = [2020], rates = [0.03], ntimesteps = Fund.default_nsteps + 1, output_dir = nothing, save_trials = false) +function run_fund_scc_mcs(trials = 10000; years = [2020], rates = [0.03], ntimesteps = MimiFUND.default_nsteps + 1, output_dir = nothing, save_trials = false) # Set up output directories output_dir = output_dir == nothing ? joinpath(@__DIR__, "../../output/", "SCC $(Dates.format(now(), "yyyy-mm-dd HH-MM-SS")) MC$trials") : output_dir @@ -41,7 +37,7 @@ function run_fund_scc_mcs(trials = 10000; years = [2020], rates = [0.03], ntimes set_models!(mcs, mm) # Define scenario function - function _scenario_func(mcs::MonteCarloSimulation, tup::Tuple) + function _scenario_func(mcs::Simulation, tup::Tuple) # Unpack scenario tuple argument (rate, emissionyear) = tup @@ -55,7 +51,7 @@ function run_fund_scc_mcs(trials = 10000; years = [2020], rates = [0.03], ntimes end # Define post trial function - function scc_calculation(mcs::MonteCarloSimulation, trialnum::Int, ntimesteps::Int, tup::Tuple) + function scc_calculation(mcs::Simulation, trialnum::Int, ntimesteps::Int, tup::Tuple) # Unpack scenario tuple argument (rate, emissionyear) = tup @@ -82,7 +78,7 @@ function run_fund_scc_mcs(trials = 10000; years = [2020], rates = [0.03], ntimes end # Run monte carlo trials - run_mcs(mcs, trials, 2; + run_sim(mcs, trials, 2; ntimesteps = ntimesteps, output_dir = "$output_dir/results", scenario_args = scenario_args, diff --git a/src/new_marginaldamages.jl b/src/new_marginaldamages.jl index 8ee8126f..84b5460f 100644 --- a/src/new_marginaldamages.jl +++ b/src/new_marginaldamages.jl @@ -1,11 +1,5 @@ -using Mimi import Mimi.compinstance -include("helper.jl") -include("fund.jl") -using .Fund - - """ Creates a MarginalModel of FUND with additional emissions in the specified year for the specified gas. """ diff --git a/test/runtests.jl b/test/runtests.jl index e9f41d94..6be9fb7e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,17 +80,9 @@ end #fund-integration testset @testset "test-marginaldamages" begin -include("../src/marginaldamages.jl") -md = getmarginaldamages() - -include("../src/marginaldamage3.jl") -md3 = marginaldamage3() - -include("../src/new_marginaldamages.jl") scc = get_social_cost() md = getmarginaldamages() - end #marginaldamages testset #------------------------------------------------------------------------------ @@ -99,14 +91,9 @@ end #marginaldamages testset @testset "test-mcs" begin -include("../src/montecarlo/run_fund_mcs.jl") -include("../src/montecarlo/run_fund_scc_mcs.jl") - run_fund_mcs(10) # Run 10 trials of basic FUND MCS run_fund_scc_mcs(10) # Run 10 trials of FUND MCS SCC calculations end #test-mcs testset end #fund testset - -nothing From df122d2d28ec318c26c6b5649e339095878c8875 Mon Sep 17 00:00:00 2001 From: lrennels Date: Sat, 9 Mar 2019 17:35:51 -0800 Subject: [PATCH 2/6] Bugfix to README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 874e8189..cdd1c34e 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Many of these requirements are regularly updated. To make sure you have the late ```julia pkg> up ``` -##Running the model +## Running the model The model uses the Mimi framework and it is highly recommended to read the Mimi documentation first to understand the code structure. For starter code on running the model just once, see the code in the file `examples/main.jl`. From 4624a4aaf630560ab5e5334b39a2da82905bcfd7 Mon Sep 17 00:00:00 2001 From: lrennels Date: Sat, 9 Mar 2019 17:50:32 -0800 Subject: [PATCH 3/6] Add nothing to end of runtests.jl --- test/runtests.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 6be9fb7e..4bbb7504 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -97,3 +97,5 @@ run_fund_scc_mcs(10) # Run 10 trials of FUND MCS SCC calculations end #test-mcs testset end #fund testset + +nothing From 5d0bd94227617e72c7a98dcbeea85b1764803d56 Mon Sep 17 00:00:00 2001 From: lrennels Date: Sat, 9 Mar 2019 19:16:13 -0800 Subject: [PATCH 4/6] Update travis.yml file --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cc0d64f1..d8992ab2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,8 @@ before_install: - julia -e 'using Pkg; Pkg.add("CSVFiles")' - julia -e 'using Pkg; Pkg.add("DataFrames")' - julia -e 'using Pkg; Pkg.add("StatsBase")' - - julia -e 'using Pkg; Pkg.add("Mimi")' + - julia -e 'using Pkg; registry add https://github.com/mimiframework/MimiRegistry.git' + - julia -e 'using Pkg; Pkg.add("MimiPAGE2009")' script: - julia test/runtests.jl From f66fb60ebd239561dbee0df7bcf5f7213f78c43f Mon Sep 17 00:00:00 2001 From: lrennels Date: Sat, 9 Mar 2019 19:17:02 -0800 Subject: [PATCH 5/6] Update travis.yml file --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d8992ab2..77abfbc0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: julia os: - linux julia: - - 1.0 + - 1.1 notifications: email: false before_install: From 158d1be50da2600b6f19307a5d84ed51b7db956a Mon Sep 17 00:00:00 2001 From: lrennels Date: Tue, 12 Mar 2019 14:40:12 -0700 Subject: [PATCH 6/6] Restrict exported fcns; fix travis.yml --- .travis.yml | 2 -- src/MimiFUND.jl | 3 +-- test/runtests.jl | 14 ++++++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 77abfbc0..d3189661 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,5 @@ before_install: - julia -e 'using Pkg; Pkg.add("DataFrames")' - julia -e 'using Pkg; Pkg.add("StatsBase")' - julia -e 'using Pkg; Pkg.add("Mimi")' - - julia -e 'using Pkg; registry add https://github.com/mimiframework/MimiRegistry.git' - - julia -e 'using Pkg; Pkg.add("MimiPAGE2009")' script: - julia test/runtests.jl diff --git a/src/MimiFUND.jl b/src/MimiFUND.jl index 539654e6..97dcae27 100644 --- a/src/MimiFUND.jl +++ b/src/MimiFUND.jl @@ -41,8 +41,7 @@ include("components/ImpactAggregationComponent.jl") include("components/VslVmorbComponent.jl") export - getfund, get_social_cost, getmarginaldamages, getmcs, run_fund_mcs, run_fund_scc_mcs - # getfund is a Function that returns a version of fund allowing for different user specifications + getfund # a function that returns a version of fund allowing for different user specifications const global default_nsteps = 1050 diff --git a/test/runtests.jl b/test/runtests.jl index 4bbb7504..ff30b567 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -56,7 +56,7 @@ for c in map(name, Mimi.compdefs(m)), v in Mimi.variable_names(m, c) @test results ≈ validation_results atol = err_number #slight imprecision with these values due to rounding else - validation_results = convert(Array, df) + validation_results = convert(Matrix, df) #replace missings with missingvalue so they can be compared results[ismissing.(results)] .= missingvalue @@ -80,19 +80,21 @@ end #fund-integration testset @testset "test-marginaldamages" begin -scc = get_social_cost() -md = getmarginaldamages() +# new_marginaldamages.jl +scc = MimiFUND.get_social_cost() +md = MimiFUND.getmarginaldamages() end #marginaldamages testset #------------------------------------------------------------------------------ -# 4. Run basic test of MCS functionality +# 4. Run basic test of Marginal Damages and MCS functionality #------------------------------------------------------------------------------ @testset "test-mcs" begin -run_fund_mcs(10) # Run 10 trials of basic FUND MCS -run_fund_scc_mcs(10) # Run 10 trials of FUND MCS SCC calculations +# mcs +MimiFUND.run_fund_mcs(10) # Run 10 trials of basic FUND MCS +MimiFUND.run_fund_scc_mcs(10) # Run 10 trials of FUND MCS SCC calculations end #test-mcs testset