diff --git a/cmake/Doc.cmake b/cmake/Doc.cmake index 1bbfb9d8c..2689c7b96 100644 --- a/cmake/Doc.cmake +++ b/cmake/Doc.cmake @@ -3,14 +3,19 @@ if(${BUILD_DOC}) COMMAND mkdir -p doc/gnufig ) add_custom_command(OUTPUT doc/components.tex - COMMAND ${DAISY_BIN_NAME} -d doc all.dai -p document + COMMAND ${DAISY_BIN_NAME} -d doc + -D ${CMAKE_SOURCE_DIR}/lib + ${CMAKE_SOURCE_DIR}/lib/all.dai + -p document COMMAND cd doc && gnuplot document.gnuplot DEPENDS doc_setup ) add_custom_command(OUTPUT doc/stdlog.tex - COMMAND ${DAISY_BIN_NAME} -d doc ${CMAKE_SOURCE_DIR}/txt/stdlog.dai + COMMAND ${DAISY_BIN_NAME} -d doc + -D ${CMAKE_SOURCE_DIR}/lib + ${CMAKE_SOURCE_DIR}/txt/stdlog.dai DEPENDS doc_setup ) @@ -104,8 +109,8 @@ if(${BUILD_DOC}) # The docs target first builds reference.pdf, tutorial.pdf and exercises.pdf; then it deletes all # the files used/generated during build. add_custom_target(docs - COMMAND rm -r doc/gnufig - COMMAND find doc/ -type f -regex .+\.[^pdf] | xargs rm + COMMAND ${CMAKE_COMMAND} -E rm -rf doc/gnufig + COMMAND find doc -type f ! -name "*.pdf" -delete DEPENDS reference tutorial exercises ) endif() diff --git a/doc/testing.md b/doc/testing.md index 5cc40582d..22d664763 100644 --- a/doc/testing.md +++ b/doc/testing.md @@ -1,13 +1,25 @@ # Testing ## Install test dependencies -We use a set of python tools to check Daisy output against a baseline. These are available from [daispy-test](https://github.com/daisy-model/daisypy-test) and can be installed with +We use a set of python tools to check Daisy output against a baseline. These are available from [daisypy-test](https://github.com/daisy-model/daisypy-test) and can be installed with pip install daisypy-test@git+https://github.com/daisy-model/daisypy-test +## Recommended local entrypoints +For local development, the recommended way to run the test suites is via the +platform-specific Makefile targets: + + make linux-test + make macos-test + make windows-test + +These targets build Daisy, create or reuse the local `uv` environment in the +build directory, install `daisypy-test`, and then run `ctest`. + Test scenarios are in [test/dai_test_files](test/dai_test_files). When adding a test you need to add it as a `dai_test_case` in [test/CMakeLists.txt](test/CMakeLists.txt). -Use [ctest](https://cmake.org/cmake/help/latest/manual/ctest.1.html) to run tests. +Use [ctest](https://cmake.org/cmake/help/latest/manual/ctest.1.html) directly if +you need lower-level control from a configured build directory. ctest @@ -26,6 +38,10 @@ and activate it source ~/.venvs/daisy/bin/activate -Then you can use `pip` to install `daispy-test`. +Then you can use `pip` to install `daisypy-test`. -NOTE: This will most likely fail if you have already built daisy and try to setup the test environment from the build directory. The reason is that python binaries are copied to the build direcotry. The solution is to run the commands from another directory or specify the full path to the msys installed python binary. +NOTE: This will most likely fail if you have already built daisy and try to set +up the test environment from the build directory. The reason is that python +binaries are copied to the build directory. The solution is to run the commands +from another directory or specify the full path to the MSYS-installed python +binary. diff --git a/include/daisy/daisy_registration.h b/include/daisy/daisy_registration.h new file mode 100644 index 000000000..4bfae919c --- /dev/null +++ b/include/daisy/daisy_registration.h @@ -0,0 +1,26 @@ +// daisy_registration.h -- Explicit registration for Daisy models. +// +// Copyright 2026 The Daisy Authors. +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef DAISY_REGISTRATION_H +#define DAISY_REGISTRATION_H + +void register_daisy_models (); + +#endif // DAISY_REGISTRATION_H diff --git a/include/daisy/daisy_registration_internal.h b/include/daisy/daisy_registration_internal.h new file mode 100644 index 000000000..219798c28 --- /dev/null +++ b/include/daisy/daisy_registration_internal.h @@ -0,0 +1,334 @@ +// daisy_registration_internal.h -- Internal Daisy registration declarations. +// +// Copyright 2026 The Daisy Authors. +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef DAISY_REGISTRATION_INTERNAL_H +#define DAISY_REGISTRATION_INTERNAL_H + +void register_column_models (); +void register_column_standard_models (); +void register_condition_models (); +void register_condition_BBCH_models (); +void register_condition_boolean_models (); +void register_condition_crop_models (); +void register_condition_daisy_state_models (); +void register_condition_extern_models (); +void register_condition_logic_models (); +void register_condition_soil_models (); +void register_condition_time_models (); +void register_condition_walltime_models (); +void register_condition_weather_models (); +void register_action_models (); +void register_action_BBCH_models (); +void register_action_activity_models (); +void register_action_crop_models (); +void register_action_extern_models (); +void register_action_fertilize_models (); +void register_action_harvest_models (); +void register_action_irrigate_models (); +void register_action_lisp_models (); +void register_action_markvand_models (); +void register_action_message_models (); +void register_action_repeat_models (); +void register_action_sow_models (); +void register_action_spray_models (); +void register_action_stop_models (); +void register_action_surface_models (); +void register_action_table_models (); +void register_action_tillage_models (); +void register_action_wait_models (); +void register_action_while_models (); +void register_action_with_models (); +void register_am_models (); +void register_aom_models (); +void register_bioincorporation_models (); +void register_clay_om_biomod_models (); +void register_clay_om_models (); +void register_clay_om_old_models (); +void register_daisy_program_models (); +void register_daisy_time_models (); +void register_doe_models (); +void register_dom_models (); +void register_domsorp_models (); +void register_domsorp_standard_models (); +void register_fetch_models (); +void register_fetch_pretty_models (); +void register_groundwater_models (); +void register_groundwater_aquitard_models (); +void register_groundwater_deep_models (); +void register_groundwater_extern_models (); +void register_groundwater_file_models (); +void register_groundwater_fixed_models (); +void register_groundwater_flux_models (); +void register_groundwater_lysimeter_models (); +void register_groundwater_source_models (); +void register_groundwater_static_models (); +void register_harvest_models (); +void register_irrigation_models (); +void register_log_models (); +void register_log_checkpoint_models (); +void register_log_extern_models (); +void register_log_harvest_models (); +void register_log_select_models (); +void register_log_table_models (); +void register_organic_matter_models (); +void register_organic_none_models (); +void register_organic_standard_models (); +void register_output_models (); +void register_select_models (); +void register_select_array_models (); +void register_select_content_models (); +void register_select_flow_models (); +void register_select_index_models (); +void register_select_number_models (); +void register_select_quiver_models (); +void register_select_value_models (); +void register_select_volume_models (); +void register_summary_models (); +void register_summary_balance_models (); +void register_summary_fractiles_models (); +void register_summary_Rsqr_models (); +void register_summary_RsqrW_models (); +void register_summary_simple_models (); +void register_smb_models (); +void register_som_models (); +void register_timestep_models (); +void register_chemistry_models (); +void register_chemical_models (); +void register_chemical_standard_models (); +void register_chemistry_standard_models (); +void register_chemistry_multi_models (); +void register_reaction_models (); +void register_reaction_adsorption_models (); +void register_reaction_boundrel_models (); +void register_reaction_colgen_models (); +void register_reaction_denit_models (); +void register_reaction_dom_models (); +void register_reaction_equil_models (); +void register_reaction_filter_models (); +void register_reaction_jarvis99_models (); +void register_reaction_morgan98_models (); +void register_reaction_nit_models (); +void register_reaction_python_models (); +void register_reaction_shoot_models (); +void register_reaction_sorption_models (); +void register_reaction_std_models (); +void register_reaction_styczen88_models (); +void register_transform_models (); +void register_transform_equil_models (); +void register_adsorption_models (); +void register_adsorption_air_models (); +void register_adsorption_freundlich_models (); +void register_adsorption_guo2020_models (); +void register_adsorption_langmuir_models (); +void register_adsorption_linear_models (); +void register_adsorption_python_models (); +void register_adsorption_vS_S_models (); +void register_equilibrium_models (); +void register_equil_goal_models (); +void register_equil_langmuir_models (); +void register_equil_linear_models (); +void register_nitrification_models (); +void register_nitrification_soil_models (); +void register_nitrification_solute_models (); +void register_denprod_models (); +void register_denprod_parton1996_models (); +void register_awi_models (); +void register_ponddamp_models (); +void register_rainergy_models (); + +void register_crop_models (); +void register_crop_simple_models (); +void register_crop_standard_models (); +void register_canopy_simple_models (); +void register_canopy_std_models (); +void register_crpn_models (); +void register_cstage_models (); +void register_harvesting_models (); +void register_partition_models (); +void register_phenology_models (); +void register_phenology_standard_models (); +void register_phenology_TSum_models (); +void register_photo_models (); +void register_photo_Farquhar_models (); +void register_photo_FCC3_models (); +void register_photo_FCC4_models (); +void register_photo_GL_models (); +void register_production_models (); +void register_seed_models (); +void register_seed_LAI_models (); +void register_seed_release_models (); +void register_stomatacon_models (); +void register_stomatacon_SHA_models (); +void register_vernalization_models (); +void register_wse_models (); +void register_crop_root_models (); +void register_rootdens_models (); +void register_rootdens_AP_models (); +void register_rootdens_GP1D_models (); +void register_rootdens_GP2D_models (); +void register_rootdens_G_P_models (); +void register_rootdens_growth_models (); +void register_rootdens_local_models (); +void register_rootdens_PLF_models (); +void register_root_system_models (); +void register_rubiscoN_models (); +void register_rubiscoNdist_models (); +void register_rubiscoNdist_DPF_models (); +void register_rubiscoNdist_expr_models (); +void register_rubiscoNdist_forced_models (); +void register_rubiscoNdist_uniform_models (); +void register_ABAprod_models (); +void register_ABAprod_root_models (); +void register_ABAprod_soil_models (); +void register_ABAprod_uptake_models (); +void register_solupt_models (); + + +void register_soil_models (); +void register_abiotic_models (); +void register_hydraulic_models (); +void register_hydraulic_B_BaC_models (); +void register_hydraulic_B_BaC_Bimodal_models (); +void register_hydraulic_B_C_models (); +void register_hydraulic_B_C_inverse_models (); +void register_hydraulic_B_vG_models (); +void register_hydraulic_Cosby_models (); +void register_hydraulic_MACRO_models (); +void register_hydraulic_M_BaC_models (); +void register_hydraulic_M_BaC_Bimodal_models (); +void register_hydraulic_M_BivG_models (); +void register_hydraulic_M_C_models (); +void register_hydraulic_M_vG_models (); +void register_hydraulic_M_vG_compact_models (); +void register_hydraulic_M_vGip_models (); +void register_hydraulic_M_vGp_models (); +void register_hydraulic_hypres_models (); +void register_hydraulic_hyprop_models (); +void register_hydraulic_linear_models (); +void register_hydraulic_mod_C_models (); +void register_hydraulic_old2_models (); +void register_hydraulic_table_models (); +void register_hydraulic_wepp_models (); +void register_hydraulic_yolo_models (); +void register_horizon_models (); +void register_horizon_numeric_models (); +void register_soilph_models (); +void register_tortuosity_models (); +void register_tortuosity_M_Q_models (); +void register_tortuosity_linear_models (); +void register_transport_models (); +void register_average_models (); +void register_biopore_models (); +void register_biopore_drain_models (); +void register_biopore_matrix_models (); +void register_bound_models (); +void register_condedge_models (); +void register_drain_models (); +void register_drain_lateral_models (); +void register_draineqd_models (); +void register_heatrect_models (); +void register_heatrect_Mollerup_models (); +void register_heatrect_linear_models (); +void register_heatrect_none_models (); +void register_macro_models (); +void register_macro_none_models (); +void register_macro_std_models (); +void register_mactrans_models (); +void register_mactrans_std_models (); +void register_movement_models (); +void register_movement_1D_models (); +void register_movement_rect_models (); +void register_movement_solute_models (); +void register_secondary_models (); +void register_tertiary_models (); +void register_tertiary_biopores_models (); +void register_tertiary_old_models (); +void register_transport_Hansen_models (); +void register_transport_Mollerup_models (); +void register_transport_convection_models (); +void register_transport_none_models (); +void register_uz1d_models (); +void register_uz1d_none_models (); +void register_uz1d_richard_models (); +void register_uzlr_models (); +void register_uzmodel_models (); +void register_uznone_models (); +void register_uzrect_models (); +void register_uzrect_2x1_models (); +void register_uzrect_Mollerup_models (); +void register_uzrect_const_models (); +void register_uzrichard_models (); +void register_uzrichard2_models (); +void register_volume_models (); +void register_volume_box_models (); +void register_zone_models (); +void register_zone_box_models (); +void register_zone_poly_models (); + +void register_upper_boundary_models (); +void register_bioclimate_models (); +void register_bioclimate_standard_models (); +void register_cloudiness_models (); +void register_difrad_models (); +void register_difrad_BRL_models (); +void register_difrad_DPF_models (); +void register_difrad_weather_models (); +void register_ghf_models (); +void register_net_radiation_models (); +void register_pet_models (); +void register_pet_FAO_PM_models (); +void register_pet_FAO_PM_hourly_models (); +void register_pet_Hargreaves_models (); +void register_pet_PM_models (); +void register_pet_makkink_models (); +void register_pet_weather_models (); +void register_raddist_models (); +void register_raddist_DPF_models (); +void register_raddist_standard_models (); +void register_svat_models (); +void register_svat_none_models (); +void register_svat_pmsw_models (); +void register_svat_ssoc_models (); +void register_litter_models (); +void register_litter_mulch_models (); +void register_litter_residue_models (); +void register_retention_models (); +void register_surface_models (); +void register_max_exfiltration_models (); +void register_surface_simple_models (); +void register_surface_source_models (); +void register_surface_standard_models (); +void register_vegetation_models (); +void register_vegetation_afforestation_models (); +void register_vegetation_crops_models (); +void register_vegetation_permanent_models (); +void register_weather_models (); +void register_deposition_models (); +void register_wsource_models (); +void register_wsource_base_models (); +void register_wsource_combine_models (); +void register_wsource_const_models (); +void register_wsource_indirect_models (); +void register_wsource_standard_models (); +void register_wsource_table_models (); +void register_wsource_time_models (); +void register_wsource_weather_models (); + +#endif // DAISY_REGISTRATION_INTERNAL_H diff --git a/include/gnuplot/gnuplot_registration.h b/include/gnuplot/gnuplot_registration.h new file mode 100644 index 000000000..824f07012 --- /dev/null +++ b/include/gnuplot/gnuplot_registration.h @@ -0,0 +1,26 @@ +// gnuplot_registration.h -- Explicit registration for gnuplot models. +// +// Copyright 2026 The Daisy Authors. +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef GNUPLOT_REGISTRATION_H +#define GNUPLOT_REGISTRATION_H + +void register_gnuplot_models (); + +#endif // GNUPLOT_REGISTRATION_H diff --git a/include/gnuplot/gnuplot_registration_internal.h b/include/gnuplot/gnuplot_registration_internal.h new file mode 100644 index 000000000..cb572172b --- /dev/null +++ b/include/gnuplot/gnuplot_registration_internal.h @@ -0,0 +1,49 @@ +// gnuplot_registration_internal.h -- Internal gnuplot registration declarations. +// +// Copyright 2026 The Daisy Authors. +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef GNUPLOT_REGISTRATION_INTERNAL_H +#define GNUPLOT_REGISTRATION_INTERNAL_H + +void register_gnuplot_core_models (); +void register_gnuplot_base_models (); +void register_gnuplot_multi_models (); +void register_gnuplot_profile_models (); +void register_gnuplot_program_models (); +void register_gnuplot_source_combine_models (); +void register_gnuplot_source_expr_models (); +void register_gnuplot_source_merge_models (); +void register_gnuplot_soil_models (); +void register_gnuplot_source_models (); +void register_gnuplot_source_std_models (); +void register_gnuplot_time_models (); +void register_gnuplot_vector_models (); +void register_gnuplot_xysource_combine_models (); +void register_gnuplot_xysource_expr_models (); +void register_gnuplot_xysource_flux_models (); +void register_gnuplot_xysource_freq_models (); +void register_gnuplot_xysource_inline_models (); +void register_gnuplot_xysource_loop_models (); +void register_gnuplot_xysource_merge_models (); +void register_gnuplot_xysource_models (); +void register_gnuplot_xysource_profile_models (); +void register_gnuplot_xysource_xycombine_models (); +void register_gnuplot_xy_models (); + +#endif // GNUPLOT_REGISTRATION_INTERNAL_H diff --git a/include/object_model/object_model_registration.h b/include/object_model/object_model_registration.h new file mode 100644 index 000000000..812306fec --- /dev/null +++ b/include/object_model/object_model_registration.h @@ -0,0 +1,26 @@ +// object_model_registration.h -- Explicit registration for object_model models. +// +// Copyright 2026 The Daisy Authors. +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef OBJECT_MODEL_REGISTRATION_H +#define OBJECT_MODEL_REGISTRATION_H + +void register_object_model_models (); + +#endif // OBJECT_MODEL_REGISTRATION_H diff --git a/include/object_model/object_model_registration_internal.h b/include/object_model/object_model_registration_internal.h new file mode 100644 index 000000000..3210f4a21 --- /dev/null +++ b/include/object_model/object_model_registration_internal.h @@ -0,0 +1,46 @@ +// object_model_registration_internal.h -- Internal object_model registration declarations. +// +// Copyright 2026 The Daisy Authors. +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef OBJECT_MODEL_REGISTRATION_INTERNAL_H +#define OBJECT_MODEL_REGISTRATION_INTERNAL_H + +void register_boolean_models (); +void register_boolean_string_models (); +void register_function_models (); +#ifdef BUILD_PYTHON +void register_function_python_models (); +#endif +void register_integer_models (); +void register_integer_arithmetic_models (); +void register_number_models (); +void register_number_apply_models (); +void register_number_arithmetic_models (); +void register_number_const_models (); +void register_number_lisp_models (); +void register_number_plf_models (); +void register_number_soil_models (); +void register_number_source_models (); +void register_parser_file_models (); +void register_parser_models (); +void register_rate_models (); +void register_stringer_models (); +void register_unit_models (); + +#endif // OBJECT_MODEL_REGISTRATION_INTERNAL_H diff --git a/include/programs/program_registration.h b/include/programs/program_registration.h new file mode 100644 index 000000000..4e934adf7 --- /dev/null +++ b/include/programs/program_registration.h @@ -0,0 +1,26 @@ +// program_registration.h -- Explicit registration for program models. +// +// Copyright 2026 The Daisy Authors. +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef PROGRAM_REGISTRATION_H +#define PROGRAM_REGISTRATION_H + +void register_program_models (); + +#endif // PROGRAM_REGISTRATION_H diff --git a/include/programs/program_registration_internal.h b/include/programs/program_registration_internal.h new file mode 100644 index 000000000..0edb31960 --- /dev/null +++ b/include/programs/program_registration_internal.h @@ -0,0 +1,43 @@ +// program_registration_internal.h -- Internal program registration declarations. +// +// Copyright 2026 The Daisy Authors. +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef PROGRAM_REGISTRATION_INTERNAL_H +#define PROGRAM_REGISTRATION_INTERNAL_H + +void register_program_GP2D_models (); +void register_program_KM2_models (); +void register_program_astdump_models (); +void register_program_batch_models (); +void register_program_cpedata_models (); +void register_program_core_models (); +void register_program_document_models (); +void register_program_extract_models (); +void register_program_file_models (); +void register_program_hmovie_models (); +void register_program_nwaps_models (); +void register_program_optimize_models (); +void register_program_osvaldo_models (); +void register_program_post_models (); +void register_program_rootmatch_models (); +void register_program_sbrdata_models (); +void register_program_spawn_models (); +void register_program_weather_models (); + +#endif // PROGRAM_REGISTRATION_INTERNAL_H diff --git a/include/ui/ui_registration.h b/include/ui/ui_registration.h new file mode 100644 index 000000000..53ce3e123 --- /dev/null +++ b/include/ui/ui_registration.h @@ -0,0 +1,26 @@ +// ui_registration.h -- Explicit registration for UI models. +// +// Copyright 2026 The Daisy Authors. +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef UI_REGISTRATION_H +#define UI_REGISTRATION_H + +void register_ui_models (); + +#endif // UI_REGISTRATION_H diff --git a/include/ui/ui_registration_internal.h b/include/ui/ui_registration_internal.h new file mode 100644 index 000000000..6860476c3 --- /dev/null +++ b/include/ui/ui_registration_internal.h @@ -0,0 +1,27 @@ +// ui_registration_internal.h -- Internal UI registration declarations. +// +// Copyright 2026 The Daisy Authors. +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef UI_REGISTRATION_INTERNAL_H +#define UI_REGISTRATION_INTERNAL_H + +void register_ui_core_models (); +void register_ui_filter_models (); + +#endif // UI_REGISTRATION_INTERNAL_H diff --git a/include/util/format_registration.h b/include/util/format_registration.h new file mode 100644 index 000000000..c9078cba4 --- /dev/null +++ b/include/util/format_registration.h @@ -0,0 +1,26 @@ +// format_registration.h -- Explicit registration for the format component. +// +// Copyright 2026 The Daisy Authors. +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef FORMAT_REGISTRATION_H +#define FORMAT_REGISTRATION_H + +void register_format_models (); + +#endif // FORMAT_REGISTRATION_H diff --git a/include/util/util_registration.h b/include/util/util_registration.h new file mode 100644 index 000000000..62926d3b3 --- /dev/null +++ b/include/util/util_registration.h @@ -0,0 +1,26 @@ +// util_registration.h -- Explicit registration for util models. +// +// Copyright 2026 The Daisy Authors. +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef UTIL_REGISTRATION_H +#define UTIL_REGISTRATION_H + +void register_util_models (); + +#endif // UTIL_REGISTRATION_H diff --git a/include/util/util_registration_internal.h b/include/util/util_registration_internal.h new file mode 100644 index 000000000..2c6ea6065 --- /dev/null +++ b/include/util/util_registration_internal.h @@ -0,0 +1,35 @@ +// util_registration_internal.h -- Internal util registration declarations. +// +// Copyright 2026 The Daisy Authors. +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef UTIL_REGISTRATION_INTERNAL_H +#define UTIL_REGISTRATION_INTERNAL_H + +#include "util/format_registration.h" + +void register_depth_models (); +void register_scope_exchange_models (); +void register_scope_models (); +void register_scopesel_models (); +void register_solver_cxsparse_models (); +void register_solver_models (); +void register_solver_none_models (); +void register_solver_ublas_models (); + +#endif // UTIL_REGISTRATION_INTERNAL_H diff --git a/src/daisy/CMakeLists.txt b/src/daisy/CMakeLists.txt index 2b42242d1..80e50db2f 100644 --- a/src/daisy/CMakeLists.txt +++ b/src/daisy/CMakeLists.txt @@ -24,5 +24,6 @@ target_sources(${DAISY_CORE_NAME} PRIVATE daisy.C daisy_time.C field.C + registration.C timestep.C ) diff --git a/src/daisy/chemicals/adsorption.C b/src/daisy/chemicals/adsorption.C index 701e12978..cc76f67fc 100644 --- a/src/daisy/chemicals/adsorption.C +++ b/src/daisy/chemicals/adsorption.C @@ -23,6 +23,7 @@ #define BUILD_DLL #include "daisy/chemicals/adsorption.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/soil/soil.h" #include "object_model/block_model.h" #include "object_model/librarian.h" @@ -152,7 +153,6 @@ Adsorption::M_to_C_bisect (const Soil& soil, const Chemical& chemical, } } - Adsorption::Adsorption (const char *const type) : ModelDerived (symbol (type)) { } @@ -164,18 +164,6 @@ Adsorption::Adsorption (const BlockModel& al) Adsorption::~Adsorption () { } -static struct AdsorptionInit : public DeclareComponent -{ - AdsorptionInit () - : DeclareComponent (Adsorption::component, "\ -This component describes the adsorption of a chemical to the soil,\n\ -which among other things affects how large a fraction can be\n\ -transported with the water.") - { } - void load_frame (Frame& frame) const - { Model::load_model (frame); } -} Adsorption_init; - // "none" model. class AdsorptionNone : public Adsorption @@ -206,18 +194,6 @@ Adsorption::none () return none; } -static struct AdsorptionNoneSyntax : DeclareModel -{ - Model* make (const BlockModel& al) const - { return new AdsorptionNone (al); } - AdsorptionNoneSyntax () - : DeclareModel (Adsorption::component, "none", "No adsorption.\n\ -Used for solutes that are not adsorped to the soil.") - { } - void load_frame (Frame&) const - { } -} AdsorptionNone_syntax; - // "full" model. class AdsorptionFull : public Adsorption @@ -247,17 +223,52 @@ public: { } }; -static struct AdsorptionFullSyntax : DeclareModel +void +register_adsorption_models () { - Model* make (const BlockModel& al) const - { return new AdsorptionFull (al); } - AdsorptionFullSyntax () - : DeclareModel (Adsorption::component, "full", "Full adsorption.\n\ + static struct AdsorptionInit : public DeclareComponent + { + AdsorptionInit () + : DeclareComponent (Adsorption::component, "\ +This component describes the adsorption of a chemical to the soil,\n\ +which among other things affects how large a fraction can be\n\ +transported with the water.") + { } + void load_frame (Frame& frame) const + { Model::load_model (frame); } + } Adsorption_init; + + static struct AdsorptionNoneSyntax : DeclareModel + { + Model* make (const BlockModel& al) const + { return new AdsorptionNone (al); } + AdsorptionNoneSyntax () + : DeclareModel (Adsorption::component, "none", "No adsorption.\n\ +Used for solutes that are not adsorped to the soil.") + { } + void load_frame (Frame&) const + { } + } AdsorptionNone_syntax; + + static struct AdsorptionFullSyntax : DeclareModel + { + Model* make (const BlockModel& al) const + { return new AdsorptionFull (al); } + AdsorptionFullSyntax () + : DeclareModel (Adsorption::component, "full", "Full adsorption.\n\ Used for non-solutes, fully adsorped in the soil.") - { } - void load_frame (Frame& frame) const - { Model::load_model (frame); } -} AdsorptionFull_syntax; + { } + void load_frame (Frame& frame) const + { Model::load_model (frame); } + } AdsorptionFull_syntax; + + register_adsorption_air_models (); + register_adsorption_freundlich_models (); + register_adsorption_guo2020_models (); + register_adsorption_langmuir_models (); + register_adsorption_linear_models (); + register_adsorption_python_models (); + register_adsorption_vS_S_models (); +} // adsorption.C ends here. - diff --git a/src/daisy/chemicals/adsorption_Python.C b/src/daisy/chemicals/adsorption_Python.C index 1b3f84870..63d31cc6a 100644 --- a/src/daisy/chemicals/adsorption_Python.C +++ b/src/daisy/chemicals/adsorption_Python.C @@ -249,35 +249,38 @@ public: { } }; -static struct AdsorptionPythonSyntax : DeclareModel +void +register_adsorption_python_models () { - Model* make (const BlockModel& al) const + static struct AdsorptionPythonSyntax : DeclareModel { - return new AdsorptionPython (al); - } - AdsorptionPythonSyntax () - : DeclareModel (Adsorption::component, "Python", "\ + Model* make (const BlockModel& al) const + { + return new AdsorptionPython (al); + } + AdsorptionPythonSyntax () + : DeclareModel (Adsorption::component, "Python", "\ Adsorption defined in user specified Python module.") - { } - void load_frame (Frame& frame) const - { - frame.declare_string ("module", Attribute::Const, "\ + { } + void load_frame (Frame& frame) const + { + frame.declare_string ("module", Attribute::Const, "\ Python module to find the functions."); - frame.declare_string ("C_to_M", Attribute::Const, "\ + frame.declare_string ("C_to_M", Attribute::Const, "\ Name of function to convert concentration to mass.\n\ C_to_M (C, *extra*)\n\ -> [g CHEMICAL/cm^3 SPACE] total content in soil/water/air.\n\ \n\ where *extra* is the extra parameters specified by 'extra'."); - frame.declare_string ("M_to_C", Attribute::OptionalConst, "\ + frame.declare_string ("M_to_C", Attribute::OptionalConst, "\ Name of the function to convert mass to concentration.\n\ M_to_C (M *extra*)\n\ -> [g CHEMICAL/cm^3 WATER] concentration in soil water.\n\ \n\ where *extra* is the extra parameters specified by 'extra'.\n\ By default this will use C_to_M and bisection between 0 and 1."); - frame.declare_string ("extra", - Attribute::Const, Attribute::Variable, "\ + frame.declare_string ("extra", + Attribute::Const, Attribute::Variable, "\ Extra input parameters to Python soil function.\n\ \n\ Options include:\n\ @@ -291,24 +294,25 @@ Options include:\n\ area_AWI [cm^2/cm^3]: air-water interface area\n\ molar_mass [g/mol]: molar mass of compound\n\ T [dg C]: soil temperature."); - static struct ExtraCheck : public VCheck::Enum - { - ExtraCheck () - : VCheck::Enum () + static struct ExtraCheck : public VCheck::Enum { - add ("Theta_sat"); - add ("Theta"); - add ("rho_b"); - add ("f_OC"); - add ("f_clay"); - add ("d50"); - add ("area_AWI"); - add ("molar_mass"); - add ("T"); - } - } extra_check; - frame.set_check ("extra", extra_check); - } -} AdsorptionPython_syntax; + ExtraCheck () + : VCheck::Enum () + { + add ("Theta_sat"); + add ("Theta"); + add ("rho_b"); + add ("f_OC"); + add ("f_clay"); + add ("d50"); + add ("area_AWI"); + add ("molar_mass"); + add ("T"); + } + } extra_check; + frame.set_check ("extra", extra_check); + } + } AdsorptionPython_syntax; +} // adsorption_Python.C ends here. diff --git a/src/daisy/chemicals/adsorption_air.C b/src/daisy/chemicals/adsorption_air.C index c2dbacf7e..8fa8c92eb 100644 --- a/src/daisy/chemicals/adsorption_air.C +++ b/src/daisy/chemicals/adsorption_air.C @@ -88,38 +88,42 @@ public: { } }; -static struct AdsorptionAirSyntax : DeclareModel +void +register_adsorption_air_models () { - Model* make (const BlockModel& al) const + static struct AdsorptionAirSyntax : DeclareModel { - return new AdsorptionAir (al); - } + Model* make (const BlockModel& al) const + { + return new AdsorptionAir (al); + } - static bool check_alist (const Metalib&, const Frame& al, Treelog& err) - { - bool ok = true; - return ok; - } - AdsorptionAirSyntax () - : DeclareModel (Adsorption::component, "air", "\ + static bool check_alist (const Metalib&, const Frame& al, Treelog& err) + { + bool ok = true; + return ok; + } + AdsorptionAirSyntax () + : DeclareModel (Adsorption::component, "air", "\ Henry's law, fixed ratio between concentration in air and water.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "henry2023"); - frame.add_check (check_alist); - frame.declare ("K_wa", Attribute::None (), Check::positive (), - Attribute::Const, - "Ratio between concentration in air and in water.\n\ + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "henry2023"); + frame.add_check (check_alist); + frame.declare ("K_wa", Attribute::None (), Check::positive (), + Attribute::Const, + "Ratio between concentration in air and in water.\n\ K_wa = Ca / Cw\n\ where Ca is mass per volume air, and Cw is mass per volume water."); - frame.declare ("T_ref", "dg C", Check::none (), Attribute::Const, - "Temperature at which K_aw is valid."); - frame.set ("T_ref", 25.0); - frame.declare ("B", "K", Check::none (), Attribute::Const, - "Temperature effect coefficient."); + frame.declare ("T_ref", "dg C", Check::none (), Attribute::Const, + "Temperature at which K_aw is valid."); + frame.set ("T_ref", 25.0); + frame.declare ("B", "K", Check::none (), Attribute::Const, + "Temperature effect coefficient."); - } -} AdsorptionAir_syntax; + } + } AdsorptionAir_syntax; +} // adsorption_air.C ends here. diff --git a/src/daisy/chemicals/adsorption_freundlich.C b/src/daisy/chemicals/adsorption_freundlich.C index 0fcbc22ef..9c1bd7da1 100644 --- a/src/daisy/chemicals/adsorption_freundlich.C +++ b/src/daisy/chemicals/adsorption_freundlich.C @@ -134,54 +134,58 @@ AdsorptionFreundlich::M_to_C (const Soil& soil, const Chemical& chemical, return (min_C + max_C) / 2.0; } -static struct AdsorptionFreundlichSyntax : DeclareModel +void +register_adsorption_freundlich_models () { - Model* make (const BlockModel& al) const - { return new AdsorptionFreundlich (al); } - static bool check_alist (const Metalib&, const Frame& al, Treelog& err) + static struct AdsorptionFreundlichSyntax : DeclareModel { - bool ok = true; + Model* make (const BlockModel& al) const + { return new AdsorptionFreundlich (al); } + static bool check_alist (const Metalib&, const Frame& al, Treelog& err) + { + bool ok = true; - const bool has_K_clay = al.check ("K_clay"); - const bool has_K_OC = al.check ("K_OC"); + const bool has_K_clay = al.check ("K_clay"); + const bool has_K_OC = al.check ("K_OC"); - if (!has_K_clay && !has_K_OC) - { - err.entry ("You must specify either 'K_clay' or 'K_OC'"); - ok = false; - } - return ok; - } - AdsorptionFreundlichSyntax () - : DeclareModel (Adsorption::component, "Freundlich", "\ + if (!has_K_clay && !has_K_OC) + { + err.entry ("You must specify either 'K_clay' or 'K_OC'"); + ok = false; + } + return ok; + } + AdsorptionFreundlichSyntax () + : DeclareModel (Adsorption::component, "Freundlich", "\ M = rho K C_ref (C / C_ref)^m + Theta C.\n\ Formula from FOCUS page 93.") - { } - void load_frame (Frame& frame) const - { - frame.add_check (check_alist); - frame.set_strings ("cite", "freundlich1939adsorption", "focus2000"); - frame.declare ("K_clay", "cm^3/g", Check::non_negative (), - Attribute::OptionalConst, - "Clay dependent distribution parameter.\n\ + { } + void load_frame (Frame& frame) const + { + frame.add_check (check_alist); + frame.set_strings ("cite", "freundlich1939adsorption", "focus2000"); + frame.declare ("K_clay", "cm^3/g", Check::non_negative (), + Attribute::OptionalConst, + "Clay dependent distribution parameter.\n\ It is multiplied with the soil clay fraction to get the clay part of\n \ the 'K' factor. If 'K_OC' is specified, 'K_clay' defaults to 0."); - frame.declare ("K_OC", "cm^3/g", Check::non_negative (), - Attribute::OptionalConst, - "Humus dependent distribution parameter.\n\ + frame.declare ("K_OC", "cm^3/g", Check::non_negative (), + Attribute::OptionalConst, + "Humus dependent distribution parameter.\n\ It is multiplied with the soil organic carbon fraction to get the\n\ carbon part of the 'K' factor. By default, 'K_OC' is equal to 'K_clay'."); - frame.declare_number_cited ("m", Attribute::None (), Check::positive (), - Attribute::Const, Attribute::Singleton, "\ + frame.declare_number_cited ("m", Attribute::None (), Check::positive (), + Attribute::Const, Attribute::Singleton, "\ Freundlich parameter (1/n).\n\ If not known, FOCUS recommend a value of 0.9 (page 93).", - "focus2000"); - frame.declare_number_cited ("C_ref", "g/cm^3", Check::positive (), - Attribute::Const, Attribute::Singleton, "\ + "focus2000"); + frame.declare_number_cited ("C_ref", "g/cm^3", Check::positive (), + Attribute::Const, Attribute::Singleton, "\ Reference concentration for determining the other parameters.\n\ According to FOCUS, the usual value is 1 mg/L (page 93).", - "focus2000"); - } -} AdsorptionFreundlich_syntax; + "focus2000"); + } + } AdsorptionFreundlich_syntax; +} // adsorption_freundlich.C ends here. diff --git a/src/daisy/chemicals/adsorption_guo2020.C b/src/daisy/chemicals/adsorption_guo2020.C index f88048a8b..de8ecec76 100644 --- a/src/daisy/chemicals/adsorption_guo2020.C +++ b/src/daisy/chemicals/adsorption_guo2020.C @@ -94,57 +94,61 @@ public: { } }; -static struct AdsorptionGuo2020Syntax : DeclareModel +void +register_adsorption_guo2020_models () { - Model* make (const BlockModel& al) const + static struct AdsorptionGuo2020Syntax : DeclareModel { - return new AdsorptionGuo2020 (al); - } + Model* make (const BlockModel& al) const + { + return new AdsorptionGuo2020 (al); + } - static bool check_alist (const Metalib&, const Frame& al, Treelog& err) - { - bool ok = true; + static bool check_alist (const Metalib&, const Frame& al, Treelog& err) + { + bool ok = true; - const bool has_K_d = al.check ("K_d"); - const bool has_K_clay = al.check ("K_clay"); - const bool has_K_OC = al.check ("K_OC"); - - if (!has_K_d && !has_K_clay && !has_K_OC) - { - err.entry ("You must specify either 'K_d', 'K_clay' or 'K_OC'"); - ok = false; - } - return ok; - } - AdsorptionGuo2020Syntax () - : DeclareModel (Adsorption::component, "Guo2020", "\ + const bool has_K_d = al.check ("K_d"); + const bool has_K_clay = al.check ("K_clay"); + const bool has_K_OC = al.check ("K_OC"); + + if (!has_K_d && !has_K_clay && !has_K_OC) + { + err.entry ("You must specify either 'K_d', 'K_clay' or 'K_OC'"); + ok = false; + } + return ok; + } + AdsorptionGuo2020Syntax () + : DeclareModel (Adsorption::component, "Guo2020", "\ Linear sorption with K_awi estimated from Equation 11.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "guo2020mathematical"); - frame.add_check (check_alist); - frame.declare ("K_d", "cm^3/g", Check::non_negative (), - Attribute::OptionalConst, - "Soil dependent distribution parameter.\n\ + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "guo2020mathematical"); + frame.add_check (check_alist); + frame.declare ("K_d", "cm^3/g", Check::non_negative (), + Attribute::OptionalConst, + "Soil dependent distribution parameter.\n\ By default, it will be calculated from 'K_OC' and 'K_clay'."); - frame.declare ("K_clay", "cm^3/g", Check::non_negative (), - Attribute::OptionalConst, - "Clay dependent distribution parameter.\n\ + frame.declare ("K_clay", "cm^3/g", Check::non_negative (), + Attribute::OptionalConst, + "Clay dependent distribution parameter.\n\ It is multiplied with the soil clay fraction to get the clay part of\n\ the 'K_d' factor. If 'K_OC' is specified, 'K_clay' defaults to 0."); - frame.declare ("K_OC", "cm^3/g", Check::non_negative (), - Attribute::OptionalConst, - "Humus dependent distribution parameter.\n\ + frame.declare ("K_OC", "cm^3/g", Check::non_negative (), + Attribute::OptionalConst, + "Humus dependent distribution parameter.\n\ It is multiplied with the soil organic carbon fraction to get the\n\ carbon part of the 'K_d' factor. By default, 'K_OC' is equal to 'K_clay'."); - frame.declare ("a", "mol/cm^3", Check::non_negative (), - Attribute::Const, - "Fitting parameter, Eq11."); - frame.declare ("b", Attribute::None (), Check::non_negative (), - Attribute::Const, - "Fitting parameter, Eq11."); - } -} AdsorptionGuo2020_syntax; + frame.declare ("a", "mol/cm^3", Check::non_negative (), + Attribute::Const, + "Fitting parameter, Eq11."); + frame.declare ("b", Attribute::None (), Check::non_negative (), + Attribute::Const, + "Fitting parameter, Eq11."); + } + } AdsorptionGuo2020_syntax; +} // adsorption_guo2020.C ends here. diff --git a/src/daisy/chemicals/adsorption_langmuir.C b/src/daisy/chemicals/adsorption_langmuir.C index 50377890b..b478c0bf8 100644 --- a/src/daisy/chemicals/adsorption_langmuir.C +++ b/src/daisy/chemicals/adsorption_langmuir.C @@ -87,44 +87,48 @@ public: { } }; -static struct AdsorptionLangmuirSyntax : DeclareModel +void +register_adsorption_langmuir_models () { - Model* make (const BlockModel& al) const - { return new AdsorptionLangmuir (al); } - static bool check_alist (const Metalib&, const Frame& al, Treelog& err) + static struct AdsorptionLangmuirSyntax : DeclareModel { - bool ok = true; + Model* make (const BlockModel& al) const + { return new AdsorptionLangmuir (al); } + static bool check_alist (const Metalib&, const Frame& al, Treelog& err) + { + bool ok = true; - const bool has_my_max_clay = al.check ("my_max_clay"); - const bool has_my_max_OC = al.check ("my_max_OC"); + const bool has_my_max_clay = al.check ("my_max_clay"); + const bool has_my_max_OC = al.check ("my_max_OC"); - if (!has_my_max_clay && !has_my_max_OC) - { - err.entry ("You must specify either 'my_max_clay' or 'my_max_OC'"); - ok = false; - } - return ok; - } - AdsorptionLangmuirSyntax () - : DeclareModel (Adsorption::component, "Langmuir", "\ + if (!has_my_max_clay && !has_my_max_OC) + { + err.entry ("You must specify either 'my_max_clay' or 'my_max_OC'"); + ok = false; + } + return ok; + } + AdsorptionLangmuirSyntax () + : DeclareModel (Adsorption::component, "Langmuir", "\ M = rho (my_max C) / ((1/K) + C) + Theta C") - { } - void load_frame (Frame& frame) const - { - frame.add_check (check_alist); - frame.declare ("K", "cm^3/g", Check::positive (), Attribute::Const, - "Slope parameter."); - frame.declare ("my_max_clay", "g/g", Check::non_negative (), - Attribute::OptionalConst, - "Max adsorption capacity (clay).\n\ + { } + void load_frame (Frame& frame) const + { + frame.add_check (check_alist); + frame.declare ("K", "cm^3/g", Check::positive (), Attribute::Const, + "Slope parameter."); + frame.declare ("my_max_clay", "g/g", Check::non_negative (), + Attribute::OptionalConst, + "Max adsorption capacity (clay).\n\ It is multiplied with the soil clay fraction to get the clay part of\n\ 'my_max'. If 'my_max_OC' is specified, 'my_max_clay' defaults to 0."); - frame.declare ("my_max_OC", "g/g", Check::non_negative (), - Attribute::OptionalConst, - "Max adsorption capacity (humus).\n\ + frame.declare ("my_max_OC", "g/g", Check::non_negative (), + Attribute::OptionalConst, + "Max adsorption capacity (humus).\n\ It is multiplied with the soil organic carbon fraction to get the\n\ carbon part of 'my_max'. By default, 'my_max_OC' is equal to 'my_max_clay'."); - } -} AdsorptionLangmuir_syntax; + } + } AdsorptionLangmuir_syntax; +} // adsorption_langmuir.C ends here. diff --git a/src/daisy/chemicals/adsorption_linear.C b/src/daisy/chemicals/adsorption_linear.C index bdd7e2b6c..4d80e5a71 100644 --- a/src/daisy/chemicals/adsorption_linear.C +++ b/src/daisy/chemicals/adsorption_linear.C @@ -80,54 +80,58 @@ public: { } }; -static struct AdsorptionLinearSyntax : DeclareModel +void +register_adsorption_linear_models () { - Model* make (const BlockModel& al) const + static struct AdsorptionLinearSyntax : DeclareModel { - return new AdsorptionLinear (al); - } + Model* make (const BlockModel& al) const + { + return new AdsorptionLinear (al); + } - static bool check_alist (const Metalib&, const Frame& al, Treelog& err) - { - bool ok = true; + static bool check_alist (const Metalib&, const Frame& al, Treelog& err) + { + bool ok = true; - const bool has_K_d = al.check ("K_d"); - const bool has_K_clay = al.check ("K_clay"); - const bool has_K_OC = al.check ("K_OC"); - - if (!has_K_d && !has_K_clay && !has_K_OC) - { - err.entry ("You must specify either 'K_d', 'K_clay' or 'K_OC'"); - ok = false; - } - return ok; - } - AdsorptionLinearSyntax () - : DeclareModel (Adsorption::component, "linear", "M = rho K C + Theta C") - { } - void load_frame (Frame& frame) const - { - frame.add_check (check_alist); - frame.declare ("K_d", "cm^3/g", Check::non_negative (), - Attribute::OptionalConst, - "Soil dependent distribution parameter.\n\ + const bool has_K_d = al.check ("K_d"); + const bool has_K_clay = al.check ("K_clay"); + const bool has_K_OC = al.check ("K_OC"); + + if (!has_K_d && !has_K_clay && !has_K_OC) + { + err.entry ("You must specify either 'K_d', 'K_clay' or 'K_OC'"); + ok = false; + } + return ok; + } + AdsorptionLinearSyntax () + : DeclareModel (Adsorption::component, "linear", "M = rho K C + Theta C") + { } + void load_frame (Frame& frame) const + { + frame.add_check (check_alist); + frame.declare ("K_d", "cm^3/g", Check::non_negative (), + Attribute::OptionalConst, + "Soil dependent distribution parameter.\n\ By default, it will be calculated from 'K_OC' and 'K_clay'."); - frame.declare ("K_clay", "cm^3/g", Check::non_negative (), - Attribute::OptionalConst, - "Clay dependent distribution parameter.\n\ + frame.declare ("K_clay", "cm^3/g", Check::non_negative (), + Attribute::OptionalConst, + "Clay dependent distribution parameter.\n\ It is multiplied with the soil clay fraction to get the clay part of\n\ the 'K_d' factor. If 'K_OC' is specified, 'K_clay' defaults to 0."); - frame.declare ("K_OC", "cm^3/g", Check::non_negative (), - Attribute::OptionalConst, - "Humus dependent distribution parameter.\n\ + frame.declare ("K_OC", "cm^3/g", Check::non_negative (), + Attribute::OptionalConst, + "Humus dependent distribution parameter.\n\ It is multiplied with the soil organic carbon fraction to get the\n\ carbon part of the 'K_d' factor. By default, 'K_OC' is equal to 'K_clay'."); - frame.declare ("K_AWI", "cm^3/cm^2", Check::non_negative (), - Attribute::Const, - "Sorption to air-water interface."); - frame.set ("K_AWI", 0.0); + frame.declare ("K_AWI", "cm^3/cm^2", Check::non_negative (), + Attribute::Const, + "Sorption to air-water interface."); + frame.set ("K_AWI", 0.0); - } -} AdsorptionLinear_syntax; + } + } AdsorptionLinear_syntax; +} // adsorption_linear.C ends here. diff --git a/src/daisy/chemicals/adsorption_vS_S.C b/src/daisy/chemicals/adsorption_vS_S.C index 690e9e6ed..c2e56f111 100644 --- a/src/daisy/chemicals/adsorption_vS_S.C +++ b/src/daisy/chemicals/adsorption_vS_S.C @@ -124,62 +124,10 @@ Adsorption_vS_S::M_to_C (const Soil& soil, const Chemical& chemical, return C; } -static struct Adsorption_vS_SSyntax : DeclareModel -{ - Model* make (const BlockModel& al) const - { return new Adsorption_vS_S (al); } - Adsorption_vS_SSyntax () - : DeclareModel (Adsorption::component, "vS_S", "\ -Double langmuir description of NH4-N sorption to clay.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "van1963potassium"); - frame.declare ("S_planar", "g N/g clay", Check::non_negative (), Attribute::Const, "\ -Absorption capacity of the clay planar sites."); - frame.declare ("S_edge", "g N/g clay", Check::non_negative (), Attribute::Const, "\ -Absorption capacity of the clay edge sites."); - frame.declare ("K_planar", "g N/cm^3", Check::non_negative (), Attribute::Const, "\ -Half-saturation constant of the clay planer sites."); - frame.declare ("K_edge", "g N/cm^3", Check::non_negative (), Attribute::Const, "\ -Half-saturation constant of the clay edge sites."); - } -} Adsorption_vS_S_syntax; - // The 'vS_S_Hansen' parameterization. -static struct AdsorptionvS_S_HansenSyntax : public DeclareParam -{ - AdsorptionvS_S_HansenSyntax () - : DeclareParam (Adsorption::component, "vS_S_Hansen", "vS_S", "\ -.") - { } - void load_frame (Frame& frame) const - { - frame.set ("S_planar", 5.964e-3); - frame.set ("S_edge", 0.308e-3); - frame.set ("K_planar", 6.3e-5); - frame.set ("K_edge", 1.372e-5); - } -} AdsorptionvS_S_Hansen_syntax; - // The 'vS_S_Styczen' parameterization. -static struct AdsorptionvS_S_StyczenSyntax : public DeclareParam -{ - AdsorptionvS_S_StyczenSyntax () - : DeclareParam (Adsorption::component, "vS_S_Styczen", "vS_S", "\ -Parameter update..") - { } - void load_frame (Frame& frame) const - { - frame.set ("S_planar", 5.964e-3); - frame.set ("S_edge", 0.2801e-3); - frame.set ("K_planar", 6.338e-4); - frame.set ("K_edge", 1.369e-5); - } -} AdsorptionvS_S_Styczen_syntax; - // The 'vS_S_old' model. class Adsorption_vS_S_old : public Adsorption @@ -269,18 +217,74 @@ Adsorption_vS_S_old::M_to_C (const Soil& soil, const Chemical& chemical, return C; } -static struct Adsorption_vS_S_oldSyntax : DeclareModel +void +register_adsorption_vS_S_models () { - Model* make (const BlockModel& al) const - { return new Adsorption_vS_S_old (al); } - Adsorption_vS_S_oldSyntax () - : DeclareModel (Adsorption::component, "vS_S_old", "\ + static struct Adsorption_vS_SSyntax : DeclareModel + { + Model* make (const BlockModel& al) const + { return new Adsorption_vS_S (al); } + Adsorption_vS_SSyntax () + : DeclareModel (Adsorption::component, "vS_S", "\ +Double langmuir description of NH4-N sorption to clay.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "van1963potassium"); + frame.declare ("S_planar", "g N/g clay", Check::non_negative (), Attribute::Const, "\ +Absorption capacity of the clay planar sites."); + frame.declare ("S_edge", "g N/g clay", Check::non_negative (), Attribute::Const, "\ +Absorption capacity of the clay edge sites."); + frame.declare ("K_planar", "g N/cm^3", Check::non_negative (), Attribute::Const, "\ +Half-saturation constant of the clay planer sites."); + frame.declare ("K_edge", "g N/cm^3", Check::non_negative (), Attribute::Const, "\ +Half-saturation constant of the clay edge sites."); + } + } Adsorption_vS_S_syntax; + + static struct AdsorptionvS_S_HansenSyntax : public DeclareParam + { + AdsorptionvS_S_HansenSyntax () + : DeclareParam (Adsorption::component, "vS_S_Hansen", "vS_S", "\ +.") + { } + void load_frame (Frame& frame) const + { + frame.set ("S_planar", 5.964e-3); + frame.set ("S_edge", 0.308e-3); + frame.set ("K_planar", 6.3e-5); + frame.set ("K_edge", 1.372e-5); + } + } AdsorptionvS_S_Hansen_syntax; + + static struct AdsorptionvS_S_StyczenSyntax : public DeclareParam + { + AdsorptionvS_S_StyczenSyntax () + : DeclareParam (Adsorption::component, "vS_S_Styczen", "vS_S", "\ +Parameter update..") + { } + void load_frame (Frame& frame) const + { + frame.set ("S_planar", 5.964e-3); + frame.set ("S_edge", 0.2801e-3); + frame.set ("K_planar", 6.338e-4); + frame.set ("K_edge", 1.369e-5); + } + } AdsorptionvS_S_Styczen_syntax; + + static struct Adsorption_vS_S_oldSyntax : DeclareModel + { + Model* make (const BlockModel& al) const + { return new Adsorption_vS_S_old (al); } + Adsorption_vS_S_oldSyntax () + : DeclareModel (Adsorption::component, "vS_S_old", "\ Buggy implementation included as vS_S before Daisy 6.47.\n\ Included here as reference.\n\ Note, linear sorption was used as default for NH4 as long as memory serve.") - { } - void load_frame (Frame& frame) const - { } -} Adsorption_vS_S_old_syntax; + { } + void load_frame (Frame& frame) const + { } + } Adsorption_vS_S_old_syntax; +} // adsorption_vS_S.C ends here. diff --git a/src/daisy/chemicals/awi.C b/src/daisy/chemicals/awi.C index 5483f453c..b36f75f60 100644 --- a/src/daisy/chemicals/awi.C +++ b/src/daisy/chemicals/awi.C @@ -67,21 +67,6 @@ AWI::AWI (const BlockModel& al) AWI::~AWI () { } -static struct AWIInit : public DeclareComponent -{ - void load_frame (Frame& frame) const - { - Model::load_model (frame); - frame.declare ("area", "cm^2/cm^3", - Attribute::LogOnly, Attribute::SoilCells, - "Air-Water interface area."); - } - AWIInit () - : DeclareComponent (AWI::component, "\ -Estimate area of air-water interface.") - { } -} AWI_init; - // The 'Brusseau2023' AWI model. struct AWIBrusseau2023 : public AWI @@ -100,20 +85,6 @@ struct AWIBrusseau2023 : public AWI { } }; -static struct AWIBrusseau2023Syntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new AWIBrusseau2023 (al); } - AWIBrusseau2023Syntax () - : DeclareModel (AWI::component, "Brusseau2023", "\ -Estimate AWI area from water and median particle size (Equation 5).") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "brusseau2023"); - } -} AWIBrusseau2023_syntax; - // The 'Costanza2008x' AWI model. struct AWICostanza2008x : public AWI @@ -137,18 +108,51 @@ struct AWICostanza2008x : public AWI { } }; -static struct AWICostanza2008xSyntax : public DeclareModel +void +register_awi_models () { - Model* make (const BlockModel& al) const - { return new AWICostanza2008x (al); } - AWICostanza2008xSyntax () - : DeclareModel (AWI::component, "Costanza2008x", "\ -Estimate AWI area from water and median particle size (Equation 1 and 2).") - { } - void load_frame (Frame& frame) const + static struct AWIInit : public DeclareComponent { - frame.set_strings ("cite", "costanza2008x"); - } -} AWICostanza2008x_syntax; + void load_frame (Frame& frame) const + { + Model::load_model (frame); + frame.declare ("area", "cm^2/cm^3", + Attribute::LogOnly, Attribute::SoilCells, + "Air-Water interface area."); + } + AWIInit () + : DeclareComponent (AWI::component, "\ +Estimate area of air-water interface.") + { } + } AWI_init; + + static struct AWIBrusseau2023Syntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new AWIBrusseau2023 (al); } + AWIBrusseau2023Syntax () + : DeclareModel (AWI::component, "Brusseau2023", "\ +Estimate AWI area from water and median particle size (Equation 5).") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "brusseau2023"); + } + } AWIBrusseau2023_syntax; + + static struct AWICostanza2008xSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new AWICostanza2008x (al); } + AWICostanza2008xSyntax () + : DeclareModel (AWI::component, "Costanza2008x", "\ +Estimate AWI area from water and median particle size (Equation 1 and 2).") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "costanza2008x"); + } + } AWICostanza2008x_syntax; +} // AWI.C ends here. diff --git a/src/daisy/chemicals/chemical.C b/src/daisy/chemicals/chemical.C index e596a6553..65ed95743 100644 --- a/src/daisy/chemicals/chemical.C +++ b/src/daisy/chemicals/chemical.C @@ -21,8 +21,8 @@ #define BUILD_DLL - #include "daisy/chemicals/chemical.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" #include "object_model/vcheck.h" @@ -94,13 +94,19 @@ Chemical::Chemical (const BlockModel& al) Chemical::~Chemical () { } -static struct ChemicalInit : public DeclareComponent +void +register_chemical_models () { - ChemicalInit () - : DeclareComponent (Chemical::component, "\ + static struct ChemicalInit : public DeclareComponent + { + ChemicalInit () + : DeclareComponent (Chemical::component, "\ This component should, for a specific chemical (typically a pesticide),\n\ provide a description of the properties of interest to Daisy.") - { } -} Chemical_init; + { } + } Chemical_init; + + register_chemical_standard_models (); +} // chemical.C ends here. diff --git a/src/daisy/chemicals/chemical_std.C b/src/daisy/chemicals/chemical_std.C index 9c62a422c..f9fe6d68f 100644 --- a/src/daisy/chemicals/chemical_std.C +++ b/src/daisy/chemicals/chemical_std.C @@ -667,7 +667,6 @@ ChemicalBase::add_to_source_secondary (const std::vector& v) } } - void ChemicalBase::add_to_source_primary (const std::vector& v) { @@ -1052,8 +1051,6 @@ ChemicalBase::tick_top (const Vegetation& vegetation, surface_tillage /= dt; litter_tillage /= dt; - - const double old_storage = snow_storage + canopy_storage + litter_storage; // Snow pack @@ -1576,7 +1573,6 @@ ChemicalBase::decompose (const Geometry& geo, decompose_factor[c] = factor; rate_primary = rate_secondary = decompose_rate * factor; - // Adjust for concentration. if (decompose_conc_factor.size () > 0) { @@ -2192,372 +2188,6 @@ struct NumberInitialC : public Number { } }; -static struct NumberInitialCSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new NumberInitialC (al); } - NumberInitialCSyntax () - : DeclareModel (Number::component, "initial_C", "\ -Find initial content from concentration.") - { } - void load_frame (Frame& frame) const - { - - frame.declare ("C", "g/cm^3", Attribute::Const, "\ -Initial concentration in soil water with sorbtion ignored.\n\ -That is M = C * Theta."); - frame.order ("C"); - } -} NumberInitialC_syntax; - -static struct InitialZeroSyntax : public DeclareParam -{ - InitialZeroSyntax () - : DeclareParam (Number::component, "initial_zero", "const", "\ -Initial zero content.") - { } - void load_frame (Frame& frame) const - { - frame.set ("value", 0.0, "g/cm^3"); - } -} InitialZero_syntax; - -static struct ZeroGradientSyntax : public DeclareParam -{ - ZeroGradientSyntax () - : DeclareParam (Number::component, "zero_gradient", "const", "\ -Assume same concentration in groundwater as in the bottom of the soil profile.") - { } - void load_frame (Frame& frame) const - { - frame.set ("value", -1.0, "g/cm^3"); - } -} ZeroGradient_syntax; - -static struct ChemicalBaseSyntax : public DeclareBase -{ - ChemicalBaseSyntax () - : DeclareBase (Chemical::component, "base", "\ -Read chemical properties as normal Daisy parameters.") - { } - static bool check_alist (const Metalib&, const Frame& al, Treelog& msg) - { - bool ok = true; - return ok; - } - - static void load_C (Frame& frame) - { Geometry::add_layer (frame, "g/cm^3", Check::non_negative (), - Attribute::Const, "\ -Concentration in water."); } - - static void load_C_secondary (Frame& frame) - { Geometry::add_layer (frame, "g/cm^3", Check::non_negative (), - Attribute::Const, "\ -Concentration in secondary domain."); } - - static void load_C_primary (Frame& frame) - { Geometry::add_layer (frame, "g/cm^3", Check::non_negative (), - Attribute::Const, "\ -Concentration in primary domain."); } - - static void load_M (Frame& frame) - { Geometry::add_layer (frame, "g/cm^3", Check::non_negative (), - Attribute::Const, "\ -Total mass per volume water, soil, and air."); } - - static void load_M_secondary (Frame& frame) - { Geometry::add_layer (frame, "g/cm^3", Check::non_negative (), - Attribute::Const, "\ -Secondary domain mass per volume water, soil, and air."); } - - static void load_M_primary (Frame& frame) - { Geometry::add_layer (frame, "g/cm^3", Check::non_negative (), - Attribute::Const, "\ -Primary domain mass per volume water, soil, and air."); } - - static void load_Ms (Frame& frame) - { Geometry::add_layer (frame, Attribute::Fraction (), Check::none (), - Attribute::Const, "\ -Mass in dry soil.\n\ -This include all matter in both soil and water, relative to the\n\ -dry matter weight.\n\ -Only for initialization of the 'M' parameter."); } - - void load_frame (Frame& frame) const - { - frame.add_check (check_alist); - Model::load_model (frame); - - // Surface parameters. - frame.declare ("molar_mass", "g/mol", - Check::non_negative (), Attribute::OptionalConst, "\ -Molar mass of the chemical."); - frame.declare ("solubility", "g/cm^3", - Check::non_negative (), Attribute::Const, "\ -Maximal concentration in water at 20 dg C."); - frame.set ("solubility", 1.0); - frame.declare ("solubility_infiltration_factor", Attribute::None (), - Check::non_negative (), Attribute::Const, "\ -Adjustment for maximum concentration in infiltrated water."); - frame.set ("solubility_infiltration_factor", 1.0); - frame.declare_fraction ("crop_uptake_reflection_factor", - Attribute::Const, "\ -How much of the chemical is reflected at crop uptake."); - frame.set ("crop_uptake_reflection_factor", 1.0); - Rate::declare (frame, "canopy_dissipation", "\ -How fast does the chemical dissipate on canopy."); - frame.declare_fraction ("canopy_washoff_coefficient", Attribute::Const, "\ -Fraction of the chemical that follows the water off the canopy."); - Rate::declare_optional (frame, "surface_decompose", "\ -How fast does the chemical decompose on surface.\n\ -Defaults to 'canopy_dissipation' rate."); - Rate::declare_optional (frame, "litter_decompose", "\ -How fast does the chemical decompose on litter.\n\ -Default to 'canopy_dissipation' rate."); - frame.declare_fraction ("litter_washoff_coefficient", Attribute::Const, "\ -Fraction of the chemical that follows the water off the litter."); - frame.set ("litter_washoff_coefficient", 1.0); - Rate::declare (frame, "litter_diffusion", "\ -How fast chemical diffuse to water passing on surface."); - Rate::set_rate (frame, "litter_diffusion", 0.0); - - // Soil parameters. - frame.declare ("diffusion_coefficient", "cm^2/s", Check::non_negative (), - Attribute::Const, "Diffusion coefficient."); - Rate::declare (frame, "decompose", "\ -How fast the chemical is being decomposed in the soil."); - frame.declare ("decompose_conc_factor", "g/cm^3 H2O", Attribute::None (), - Attribute::Const, - "Concentration development factor on decomposition."); - frame.set ("decompose_conc_factor", PLF::empty ()); - frame.declare ("decompose_lag_increment", - "g/cm^3", "h^-1", Attribute::Const, - "Increment lag with the value of this PLF for the current\n\ -concentration each hour. When lag in any cell reaches 1.0,\n\ -decomposition begins. It can never be more than 1.0 or less than 0.0.\n\ -By default, there is no lag."); - frame.set ("decompose_lag_increment", PLF::empty ()); - frame.declare_boolean ("enable_surface_products", Attribute::Const, "\ -True if metabolites of this chemical can be generated on the surface."); - frame.set ("enable_surface_products", false); - frame.declare_boolean ("soil_affects_surface_decompose", - Attribute::Const, "\ -True if soil conditions affect surface decomposition."); - frame.set ("soil_affects_surface_decompose", false); - - frame.declare_boolean ("drain_secondary", Attribute::Const, "\ -Concentration in secondary soil water user for drainage.\n\ -If you set this to true the concentration in the secondary domain is used\n\ -for concentration in drain water. Otherwise, the average concentration is\n\ -the matix is used. Using the secondary domain is more physically correct,\n\ -but also more likely to give unstable results."); - frame.set ("drain_secondary", false); - frame.declare_object ("C_below", Number::component, - Attribute::Const, Attribute::Singleton, "\ -Concentration below the layer of soil being examined.\n\ -Use a negative number to indicate same concentration as in lowest cell."); - frame.declare_submodule_sequence ("decompose_products", Attribute::Const, "\ -List of products from decomposition.", ChemicalBase::Product::load_syntax); - frame.set_empty ("decompose_products"); - frame.set ("C_below", "zero_gradient"); - frame.declare_object ("initial", Number::component, - Attribute::Const, Attribute::Singleton, "\ -Initial content (M) if otherwise unspecified. [g/cm^3]."); - frame.set ("initial", "initial_zero"); - frame.declare_object ("adsorption", Adsorption::component, - Attribute::Const, Attribute::Singleton, "\ -Instant equilibrium between sorbed and solute phases.\n\ -\n\ -Specify the equilibrium model here for chemicals where the sorbed and\n\ -solute phases typically reaches equilibrium within a single timestep.\n\ -Slower adsorption processes should be modelled as two chemicals, one\n\ -with 'none' adsorption and one with 'full' adsorption, and an\n\ -'adsorption' reaction between them."); - frame.set ("adsorption", "none"); - - // Management and climate fluxes. - frame.declare ("deposit", "g/m^2/h", Attribute::LogOnly, - "Amount deposited from the atmosphere."); - frame.declare ("spray_overhead", "g/m^2/h", Attribute::LogOnly, - "Amount currently being applied above canopy."); - frame.declare ("spray_surface", "g/m^2/h", Attribute::LogOnly, - "Amount currently being applied below canopy."); - frame.declare ("spray", "g/m^2/h", Attribute::LogOnly, - "Amount currently being applied."); - frame.declare ("surface_tillage", "g/m^2/h", Attribute::LogOnly, - "Amount removed from surface due to tillage operations."); - frame.declare ("litter_tillage", "g/m^2/h", Attribute::LogOnly, - "Amount removed from litter due to tillage operations."); - - // Surface variables. - frame.declare ("snow_storage", "g/m^2", Attribute::State, - "Stored in the snow pack."); - frame.set ("snow_storage", 0.0); - frame.declare ("snow_in", "g/m^2/h", Attribute::LogOnly, - "Entering snow pack."); - frame.declare ("snow_out", "g/m^2/h", Attribute::LogOnly, - "Leaking from snow pack."); - - frame.declare ("canopy_storage", "g/m^2", Attribute::State, - "Stored on the canopy."); - frame.set ("canopy_storage", 0.0); - frame.declare ("canopy_in", "g/m^2/h", Attribute::LogOnly, - "Entering canopy."); - frame.declare ("canopy_dissipate", "g/m^2/h", Attribute::LogOnly, - "Dissipating from canopy."); - frame.declare ("canopy_out", "g/m^2/h", Attribute::LogOnly, - "Falling through or off the canopy."); - frame.declare ("canopy_transform", "g/m^2/h", Attribute::LogOnly, - "Added through transformation to canopy."); - frame.declare ("canopy_harvest", "g/m^2/h", Attribute::LogOnly, - "Amount removed with crop harvest."); - - frame.declare ("litter_storage", "g/m^2", Attribute::State, - "Stored in the litter (mulch, surface residuals)."); - frame.set ("litter_storage", 0.0); - frame.declare ("litter_in", "g/m^2/h", Attribute::LogOnly, - "Entering litter ."); - frame.declare ("litter_decomposed", "g/m^2/h", Attribute::LogOnly, - "Decomposed from the litter."); - frame.declare ("litter_transform", "g/m^2/h", Attribute::LogOnly, - "Added through transformation in litter layer."); - frame.declare ("litter_out", "g/m^2/h", Attribute::LogOnly, - "Leaking from litter."); - frame.declare ("litter_leak", "g/m^2/h", Attribute::LogOnly, - "Leaking from bottom litter."); - frame.declare ("litter_diffuse", "g/m^2/h", Attribute::LogOnly, - "Diffusing from litter to water passing on surface."); - - frame.declare ("surface_storage", "g/m^2", Attribute::State, - "Stored on the soil surface.\n\ -This includes the mixing layer, and constitute 'surface_solute'\n\ -and 'surface_immobile'."); - frame.set ("surface_storage", 0.0); - frame.declare ("surface_solute", "g/m^2", Attribute::LogOnly, - "Stored in the soil water of the mixing layer.\n\ -This is part of 'surface_storage'."); - frame.declare ("surface_immobile", "g/m^2", Attribute::LogOnly, - "Bound to soil particles in the mixing layer.\n\ -This is part of 'surface_storage'."); - frame.declare ("surface_in", "g/m^2/h", Attribute::LogOnly, - "Falling on the bare soil surface."); - frame.declare ("surface_runoff", "g/m^2/h", Attribute::LogOnly, - "Removed through lateral movement on the soil."); - frame.declare ("surface_decomposed", "g/m^2/h", Attribute::LogOnly, - "Decomposed from the surface."); - frame.declare ("surface_transform", "g/m^2/h", Attribute::LogOnly, - "Added through transformation to surface."); - frame.declare ("surface_mixture", "g/m^2/h", Attribute::LogOnly, - "Entering the soil through mixture with ponded water."); - frame.declare ("surface_out", "g/m^2/h", Attribute::LogOnly, - "Entering the soil with water infiltration."); - frame.declare ("surface_release", Attribute::Fraction (), Attribute::LogOnly, "\ -Fraction of available soil particles released as colloids this timestep.\n\ -Only relevant for chemicals representing colloids.\n\ -\n\ -The idea behind this is that reactions that generate colloids will set the\n\ -value of this variable, and then reactions that convert immobile chemicals\n\ -into colloid bound chemicals will use it. For this to work, the reactions\n\ -that set the variable must be listed before the reactions that us it.\n\ -\n\ -Note that the value is relative to the current timestep."); - frame.declare ("top_storage", "g/m^2", Attribute::LogOnly, "\ -Sum of above ground (surface, liter, snow, canopy) storage."); - frame.declare ("top_loss", "g/m^2/h", Attribute::LogOnly, "\ -Amount lost from the system from the surface.\n \ -This includes runoff, canopy dissipation and harvest, but not soil\n \ -infiltration. It also includes the net loss through transformation,\n \ -which can be negative."); - - // Soil variables. - Geometry::add_layer (frame, Attribute::OptionalState, "C", load_C); - Geometry::add_layer (frame, Attribute::OptionalState, "C_secondary", - load_C_secondary); - Geometry::add_layer (frame, Attribute::LogOnly, "C_primary", - load_C_primary); - Geometry::add_layer (frame, Attribute::OptionalState, "M", load_M); - Geometry::add_layer (frame, Attribute::OptionalState, "M_secondary", - load_M_secondary); - Geometry::add_layer (frame, Attribute::LogOnly, "M_primary", - load_M_primary); - Geometry::add_layer (frame, Attribute::OptionalConst, "Ms", load_Ms); -#if 0 - frame.declare ("M_secondary", "g/cm^3", - Attribute::LogOnly, Attribute::SoilCells, - "Mass in secondary domain."); -#endif - frame.declare ("M_error", "g/cm^3", Attribute::LogOnly, Attribute::SoilCells, - "Mass substracted to avoid negative values."); - frame.declare ("M_tertiary", "g/cm^3", Attribute::LogOnly, Attribute::SoilCells, - "Mass in tertiary domain (biopores)."); - frame.declare ("S_secondary", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Secondary matrix source term."); - frame.declare ("S_primary", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Primary matrix source term."); - frame.declare ("S_exchange", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Exchange from primary to secondary domain."); - frame.declare ("S_indirect_drain", "g/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, "\ -Added to the soil matrix from drains indirectly via biopores.\n\ -This can be non-zero whereever there are drain connected biopores."); - frame.declare ("S_soil_drain", "g/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, "\ -Added to the soil matrix from drains directly, not via biopores.\n\ -This is only non-zero in drain nodes."); - frame.declare ("S_p_drain", "g/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, "\ -Removed from the biopores to the drain.\n\ -This is only non-zero in drain nodes."); - frame.declare ("S_B2M", "g/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, "\ -Biopores to matrix."); - frame.declare ("S_M2B", "g/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, "\ -Matrix to biopores (negative matrix source).\n\ -Does not count flow to drain connected biopores."); - frame.declare ("S_external", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "External source, such as incorporated fertilizer."); - frame.declare ("S_permanent", "g/cm^3/h", Attribute::State, Attribute::SoilCells, - "Permanent external source, e.g. subsoil irrigation."); - std::vector empty; - frame.set ("S_permanent", empty); - frame.declare ("S_root", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Source term (root uptake only, always negative)."); - frame.declare ("S_decompose", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Source term for decompose, is never positive."); - frame.declare ("S_decompose_primary", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Source term for decompose in primary domain, is never positive."); - frame.declare ("S_decompose_secondary", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Source term for decompose in secondary domain, is never positive."); - frame.declare ("S_transform", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Source term for transformations other than sorption."); - frame.declare ("decompose_factor", Attribute::None (), Attribute::LogOnly, Attribute::SoilCells, - "Decompose factor due to soil conditions."); - frame.declare ("surface_decompose_factor", Attribute::None (), - Attribute::LogOnly, - "Decompose factor due to soil conditions near surface."); - frame.declare ("J_primary", "g/cm^2/h", Attribute::LogOnly, Attribute::SoilEdges, - "Transportation in primary matrix water (positive up)."); - frame.declare ("J_secondary", "g/cm^2/h", Attribute::LogOnly, Attribute::SoilEdges, - "Transportation in secondary matrix water (positive up)."); - frame.declare ("J_matrix", "g/cm^2/h", Attribute::LogOnly, Attribute::SoilEdges, - "Transportation in matrix (positive up)."); - frame.declare ("J_tertiary", "g/cm^2/h", Attribute::LogOnly, Attribute::SoilEdges, - "Transportation in tertiary water (positive up)."); - frame.declare ("tillage", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Changes during tillage."); - frame.declare ("lag", Attribute::None (), Attribute::OptionalState, - Attribute::SoilCells, - "This state variable grows with lag_increment (C) each hour.\n\ -When it reached 1.0, decomposition begins."); - frame.declare ("dt", "h", Attribute::LogOnly, "\ -Suggested timestep length based on sink terms."); - frame.declare_integer ("sink_cell", Attribute::LogOnly, "\ -Cell with largest forward sink compared to available matter."); - } -} ChemicalBase_syntax; - // The 'default' chemical model. struct ChemicalStandard : public ChemicalBase @@ -2670,28 +2300,6 @@ ChemicalStandard::decompose_soil_factor return factor; } -static struct ChemicalStandardSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new ChemicalStandard (al); } - void load_frame (Frame& frame) const - { - Abiotic::load_frame (frame); - frame.declare ("decompose_CO2_factor", "g CO2-C/cm^3/h", Attribute::None (), - Attribute::Const, - "CO2 development factor on decomposition."); - frame.set ("decompose_CO2_factor", PLF::empty ()); - frame.declare ("decompose_depth_factor", "cm", Attribute::None (), - Attribute::Const, - "Depth influence on decomposition."); - frame.set ("decompose_depth_factor", PLF::always_1 ()); - } - ChemicalStandardSyntax () - : DeclareModel (Chemical::component, "default", "base", "\ -Read chemical properties as normal Daisy parameters.") - { } -} ChemicalStandard_syntax; - // The 'FOCUS' chemical model. struct ChemicalFOCUS : public ChemicalBase @@ -2770,36 +2378,441 @@ ChemicalFOCUS::decompose_soil_factor (size_t c, return depth_factor * water_factor * heat_factor; } -static struct ChemicalFOCUSSyntax : public DeclareModel +// The 'nutrient' chemical model. + +struct ChemicalNutrient : public ChemicalBase { - Model* make (const BlockModel& al) const - { return new ChemicalFOCUS (al); } - void load_frame (Frame& frame) const + double decompose_soil_factor (size_t c, // FIXME: WHy is c not used? + const Geometry&, const Soil&, + const SoilWater&, const SoilHeat&, + const OrganicMatter&) const + { return 1.0; } + ChemicalNutrient (const BlockModel& al) + : ChemicalBase (al) + { } +}; + +void +register_chemical_standard_models () +{ + static struct NumberInitialCSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new NumberInitialC (al); } + NumberInitialCSyntax () + : DeclareModel (Number::component, "initial_C", "\ +Find initial content from concentration.") + { } + void load_frame (Frame& frame) const + { + + frame.declare ("C", "g/cm^3", Attribute::Const, "\ +Initial concentration in soil water with sorbtion ignored.\n\ +That is M = C * Theta."); + frame.order ("C"); + } + } NumberInitialC_syntax; + + static struct InitialZeroSyntax : public DeclareParam + { + InitialZeroSyntax () + : DeclareParam (Number::component, "initial_zero", "const", "\ +Initial zero content.") + { } + void load_frame (Frame& frame) const + { + frame.set ("value", 0.0, "g/cm^3"); + } + } InitialZero_syntax; + + static struct ZeroGradientSyntax : public DeclareParam + { + ZeroGradientSyntax () + : DeclareParam (Number::component, "zero_gradient", "const", "\ +Assume same concentration in groundwater as in the bottom of the soil profile.") + { } + void load_frame (Frame& frame) const + { + frame.set ("value", -1.0, "g/cm^3"); + } + } ZeroGradient_syntax; + + static struct ChemicalBaseSyntax : public DeclareBase + { + ChemicalBaseSyntax () + : DeclareBase (Chemical::component, "base", "\ +Read chemical properties as normal Daisy parameters.") + { } + static bool check_alist (const Metalib&, const Frame& al, Treelog& msg) + { + bool ok = true; + return ok; + } + + static void load_C (Frame& frame) + { Geometry::add_layer (frame, "g/cm^3", Check::non_negative (), + Attribute::Const, "\ +Concentration in water."); } + + static void load_C_secondary (Frame& frame) + { Geometry::add_layer (frame, "g/cm^3", Check::non_negative (), + Attribute::Const, "\ +Concentration in secondary domain."); } + + static void load_C_primary (Frame& frame) + { Geometry::add_layer (frame, "g/cm^3", Check::non_negative (), + Attribute::Const, "\ +Concentration in primary domain."); } + + static void load_M (Frame& frame) + { Geometry::add_layer (frame, "g/cm^3", Check::non_negative (), + Attribute::Const, "\ +Total mass per volume water, soil, and air."); } + + static void load_M_secondary (Frame& frame) + { Geometry::add_layer (frame, "g/cm^3", Check::non_negative (), + Attribute::Const, "\ +Secondary domain mass per volume water, soil, and air."); } + + static void load_M_primary (Frame& frame) + { Geometry::add_layer (frame, "g/cm^3", Check::non_negative (), + Attribute::Const, "\ +Primary domain mass per volume water, soil, and air."); } + + static void load_Ms (Frame& frame) + { Geometry::add_layer (frame, Attribute::Fraction (), Check::none (), + Attribute::Const, "\ +Mass in dry soil.\n\ +This include all matter in both soil and water, relative to the\n\ +dry matter weight.\n\ +Only for initialization of the 'M' parameter."); } + + void load_frame (Frame& frame) const + { + frame.add_check (check_alist); + Model::load_model (frame); + + // Surface parameters. + frame.declare ("molar_mass", "g/mol", + Check::non_negative (), Attribute::OptionalConst, "\ +Molar mass of the chemical."); + frame.declare ("solubility", "g/cm^3", + Check::non_negative (), Attribute::Const, "\ +Maximal concentration in water at 20 dg C."); + frame.set ("solubility", 1.0); + frame.declare ("solubility_infiltration_factor", Attribute::None (), + Check::non_negative (), Attribute::Const, "\ +Adjustment for maximum concentration in infiltrated water."); + frame.set ("solubility_infiltration_factor", 1.0); + frame.declare_fraction ("crop_uptake_reflection_factor", + Attribute::Const, "\ +How much of the chemical is reflected at crop uptake."); + frame.set ("crop_uptake_reflection_factor", 1.0); + Rate::declare (frame, "canopy_dissipation", "\ +How fast does the chemical dissipate on canopy."); + frame.declare_fraction ("canopy_washoff_coefficient", Attribute::Const, "\ +Fraction of the chemical that follows the water off the canopy."); + Rate::declare_optional (frame, "surface_decompose", "\ +How fast does the chemical decompose on surface.\n\ +Defaults to 'canopy_dissipation' rate."); + Rate::declare_optional (frame, "litter_decompose", "\ +How fast does the chemical decompose on litter.\n\ +Default to 'canopy_dissipation' rate."); + frame.declare_fraction ("litter_washoff_coefficient", Attribute::Const, "\ +Fraction of the chemical that follows the water off the litter."); + frame.set ("litter_washoff_coefficient", 1.0); + Rate::declare (frame, "litter_diffusion", "\ +How fast chemical diffuse to water passing on surface."); + Rate::set_rate (frame, "litter_diffusion", 0.0); + + // Soil parameters. + frame.declare ("diffusion_coefficient", "cm^2/s", Check::non_negative (), + Attribute::Const, "Diffusion coefficient."); + Rate::declare (frame, "decompose", "\ +How fast the chemical is being decomposed in the soil."); + frame.declare ("decompose_conc_factor", "g/cm^3 H2O", Attribute::None (), + Attribute::Const, + "Concentration development factor on decomposition."); + frame.set ("decompose_conc_factor", PLF::empty ()); + frame.declare ("decompose_lag_increment", + "g/cm^3", "h^-1", Attribute::Const, + "Increment lag with the value of this PLF for the current\n\ +concentration each hour. When lag in any cell reaches 1.0,\n\ +decomposition begins. It can never be more than 1.0 or less than 0.0.\n\ +By default, there is no lag."); + frame.set ("decompose_lag_increment", PLF::empty ()); + frame.declare_boolean ("enable_surface_products", Attribute::Const, "\ +True if metabolites of this chemical can be generated on the surface."); + frame.set ("enable_surface_products", false); + frame.declare_boolean ("soil_affects_surface_decompose", + Attribute::Const, "\ +True if soil conditions affect surface decomposition."); + frame.set ("soil_affects_surface_decompose", false); + + frame.declare_boolean ("drain_secondary", Attribute::Const, "\ +Concentration in secondary soil water user for drainage.\n\ +If you set this to true the concentration in the secondary domain is used\n\ +for concentration in drain water. Otherwise, the average concentration is\n\ +the matix is used. Using the secondary domain is more physically correct,\n\ +but also more likely to give unstable results."); + frame.set ("drain_secondary", false); + frame.declare_object ("C_below", Number::component, + Attribute::Const, Attribute::Singleton, "\ +Concentration below the layer of soil being examined.\n\ +Use a negative number to indicate same concentration as in lowest cell."); + frame.declare_submodule_sequence ("decompose_products", Attribute::Const, "\ +List of products from decomposition.", ChemicalBase::Product::load_syntax); + frame.set_empty ("decompose_products"); + frame.set ("C_below", "zero_gradient"); + frame.declare_object ("initial", Number::component, + Attribute::Const, Attribute::Singleton, "\ +Initial content (M) if otherwise unspecified. [g/cm^3]."); + frame.set ("initial", "initial_zero"); + frame.declare_object ("adsorption", Adsorption::component, + Attribute::Const, Attribute::Singleton, "\ +Instant equilibrium between sorbed and solute phases.\n\ +\n\ +Specify the equilibrium model here for chemicals where the sorbed and\n\ +solute phases typically reaches equilibrium within a single timestep.\n\ +Slower adsorption processes should be modelled as two chemicals, one\n\ +with 'none' adsorption and one with 'full' adsorption, and an\n\ +'adsorption' reaction between them."); + frame.set ("adsorption", "none"); + + // Management and climate fluxes. + frame.declare ("deposit", "g/m^2/h", Attribute::LogOnly, + "Amount deposited from the atmosphere."); + frame.declare ("spray_overhead", "g/m^2/h", Attribute::LogOnly, + "Amount currently being applied above canopy."); + frame.declare ("spray_surface", "g/m^2/h", Attribute::LogOnly, + "Amount currently being applied below canopy."); + frame.declare ("spray", "g/m^2/h", Attribute::LogOnly, + "Amount currently being applied."); + frame.declare ("surface_tillage", "g/m^2/h", Attribute::LogOnly, + "Amount removed from surface due to tillage operations."); + frame.declare ("litter_tillage", "g/m^2/h", Attribute::LogOnly, + "Amount removed from litter due to tillage operations."); + + // Surface variables. + frame.declare ("snow_storage", "g/m^2", Attribute::State, + "Stored in the snow pack."); + frame.set ("snow_storage", 0.0); + frame.declare ("snow_in", "g/m^2/h", Attribute::LogOnly, + "Entering snow pack."); + frame.declare ("snow_out", "g/m^2/h", Attribute::LogOnly, + "Leaking from snow pack."); + + frame.declare ("canopy_storage", "g/m^2", Attribute::State, + "Stored on the canopy."); + frame.set ("canopy_storage", 0.0); + frame.declare ("canopy_in", "g/m^2/h", Attribute::LogOnly, + "Entering canopy."); + frame.declare ("canopy_dissipate", "g/m^2/h", Attribute::LogOnly, + "Dissipating from canopy."); + frame.declare ("canopy_out", "g/m^2/h", Attribute::LogOnly, + "Falling through or off the canopy."); + frame.declare ("canopy_transform", "g/m^2/h", Attribute::LogOnly, + "Added through transformation to canopy."); + frame.declare ("canopy_harvest", "g/m^2/h", Attribute::LogOnly, + "Amount removed with crop harvest."); + + frame.declare ("litter_storage", "g/m^2", Attribute::State, + "Stored in the litter (mulch, surface residuals)."); + frame.set ("litter_storage", 0.0); + frame.declare ("litter_in", "g/m^2/h", Attribute::LogOnly, + "Entering litter ."); + frame.declare ("litter_decomposed", "g/m^2/h", Attribute::LogOnly, + "Decomposed from the litter."); + frame.declare ("litter_transform", "g/m^2/h", Attribute::LogOnly, + "Added through transformation in litter layer."); + frame.declare ("litter_out", "g/m^2/h", Attribute::LogOnly, + "Leaking from litter."); + frame.declare ("litter_leak", "g/m^2/h", Attribute::LogOnly, + "Leaking from bottom litter."); + frame.declare ("litter_diffuse", "g/m^2/h", Attribute::LogOnly, + "Diffusing from litter to water passing on surface."); + + frame.declare ("surface_storage", "g/m^2", Attribute::State, + "Stored on the soil surface.\n\ +This includes the mixing layer, and constitute 'surface_solute'\n\ +and 'surface_immobile'."); + frame.set ("surface_storage", 0.0); + frame.declare ("surface_solute", "g/m^2", Attribute::LogOnly, + "Stored in the soil water of the mixing layer.\n\ +This is part of 'surface_storage'."); + frame.declare ("surface_immobile", "g/m^2", Attribute::LogOnly, + "Bound to soil particles in the mixing layer.\n\ +This is part of 'surface_storage'."); + frame.declare ("surface_in", "g/m^2/h", Attribute::LogOnly, + "Falling on the bare soil surface."); + frame.declare ("surface_runoff", "g/m^2/h", Attribute::LogOnly, + "Removed through lateral movement on the soil."); + frame.declare ("surface_decomposed", "g/m^2/h", Attribute::LogOnly, + "Decomposed from the surface."); + frame.declare ("surface_transform", "g/m^2/h", Attribute::LogOnly, + "Added through transformation to surface."); + frame.declare ("surface_mixture", "g/m^2/h", Attribute::LogOnly, + "Entering the soil through mixture with ponded water."); + frame.declare ("surface_out", "g/m^2/h", Attribute::LogOnly, + "Entering the soil with water infiltration."); + frame.declare ("surface_release", Attribute::Fraction (), Attribute::LogOnly, "\ +Fraction of available soil particles released as colloids this timestep.\n\ +Only relevant for chemicals representing colloids.\n\ +\n\ +The idea behind this is that reactions that generate colloids will set the\n\ +value of this variable, and then reactions that convert immobile chemicals\n\ +into colloid bound chemicals will use it. For this to work, the reactions\n\ +that set the variable must be listed before the reactions that us it.\n\ +\n\ +Note that the value is relative to the current timestep."); + frame.declare ("top_storage", "g/m^2", Attribute::LogOnly, "\ +Sum of above ground (surface, liter, snow, canopy) storage."); + frame.declare ("top_loss", "g/m^2/h", Attribute::LogOnly, "\ +Amount lost from the system from the surface.\n \ +This includes runoff, canopy dissipation and harvest, but not soil\n \ +infiltration. It also includes the net loss through transformation,\n \ +which can be negative."); + + // Soil variables. + Geometry::add_layer (frame, Attribute::OptionalState, "C", load_C); + Geometry::add_layer (frame, Attribute::OptionalState, "C_secondary", + load_C_secondary); + Geometry::add_layer (frame, Attribute::LogOnly, "C_primary", + load_C_primary); + Geometry::add_layer (frame, Attribute::OptionalState, "M", load_M); + Geometry::add_layer (frame, Attribute::OptionalState, "M_secondary", + load_M_secondary); + Geometry::add_layer (frame, Attribute::LogOnly, "M_primary", + load_M_primary); + Geometry::add_layer (frame, Attribute::OptionalConst, "Ms", load_Ms); + #if 0 + frame.declare ("M_secondary", "g/cm^3", + Attribute::LogOnly, Attribute::SoilCells, + "Mass in secondary domain."); + #endif + frame.declare ("M_error", "g/cm^3", Attribute::LogOnly, Attribute::SoilCells, + "Mass substracted to avoid negative values."); + frame.declare ("M_tertiary", "g/cm^3", Attribute::LogOnly, Attribute::SoilCells, + "Mass in tertiary domain (biopores)."); + frame.declare ("S_secondary", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Secondary matrix source term."); + frame.declare ("S_primary", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Primary matrix source term."); + frame.declare ("S_exchange", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Exchange from primary to secondary domain."); + frame.declare ("S_indirect_drain", "g/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, "\ +Added to the soil matrix from drains indirectly via biopores.\n\ +This can be non-zero whereever there are drain connected biopores."); + frame.declare ("S_soil_drain", "g/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, "\ +Added to the soil matrix from drains directly, not via biopores.\n\ +This is only non-zero in drain nodes."); + frame.declare ("S_p_drain", "g/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, "\ +Removed from the biopores to the drain.\n\ +This is only non-zero in drain nodes."); + frame.declare ("S_B2M", "g/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, "\ +Biopores to matrix."); + frame.declare ("S_M2B", "g/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, "\ +Matrix to biopores (negative matrix source).\n\ +Does not count flow to drain connected biopores."); + frame.declare ("S_external", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "External source, such as incorporated fertilizer."); + frame.declare ("S_permanent", "g/cm^3/h", Attribute::State, Attribute::SoilCells, + "Permanent external source, e.g. subsoil irrigation."); + std::vector empty; + frame.set ("S_permanent", empty); + frame.declare ("S_root", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Source term (root uptake only, always negative)."); + frame.declare ("S_decompose", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Source term for decompose, is never positive."); + frame.declare ("S_decompose_primary", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Source term for decompose in primary domain, is never positive."); + frame.declare ("S_decompose_secondary", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Source term for decompose in secondary domain, is never positive."); + frame.declare ("S_transform", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Source term for transformations other than sorption."); + frame.declare ("decompose_factor", Attribute::None (), Attribute::LogOnly, Attribute::SoilCells, + "Decompose factor due to soil conditions."); + frame.declare ("surface_decompose_factor", Attribute::None (), + Attribute::LogOnly, + "Decompose factor due to soil conditions near surface."); + frame.declare ("J_primary", "g/cm^2/h", Attribute::LogOnly, Attribute::SoilEdges, + "Transportation in primary matrix water (positive up)."); + frame.declare ("J_secondary", "g/cm^2/h", Attribute::LogOnly, Attribute::SoilEdges, + "Transportation in secondary matrix water (positive up)."); + frame.declare ("J_matrix", "g/cm^2/h", Attribute::LogOnly, Attribute::SoilEdges, + "Transportation in matrix (positive up)."); + frame.declare ("J_tertiary", "g/cm^2/h", Attribute::LogOnly, Attribute::SoilEdges, + "Transportation in tertiary water (positive up)."); + frame.declare ("tillage", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Changes during tillage."); + frame.declare ("lag", Attribute::None (), Attribute::OptionalState, + Attribute::SoilCells, + "This state variable grows with lag_increment (C) each hour.\n\ +When it reached 1.0, decomposition begins."); + frame.declare ("dt", "h", Attribute::LogOnly, "\ +Suggested timestep length based on sink terms."); + frame.declare_integer ("sink_cell", Attribute::LogOnly, "\ +Cell with largest forward sink compared to available matter."); + } + } ChemicalBase_syntax; + + static struct ChemicalStandardSyntax : public DeclareModel { - frame.set_strings ("cite", "focusgw2002", "focussw2002"); - frame.declare ("B", Attribute::None (), Check::none (), - Attribute::Const, "Soil moisture effect parameter."); - frame.set_cited ("B", 0.49, "Section 7.4.5", "focussw2002"); - frame.declare ("T_ref", "dg C", Check::none (), - Attribute::Const, "Reference temperature."); - frame.set_cited ("T_ref", 20.0, "Section 7.4.2", "focussw2002"); - frame.declare ("alpha", "K^-1", Check::none (), - Attribute::Const, "Temperature effect parameter."); - frame.set_cited ("alpha", 0.0948, "Section 7.4.4", "focussw2002"); - frame.declare ("z", "cm", Check::negative (), Attribute::Const, - Attribute::Variable, "\ + Model* make (const BlockModel& al) const + { return new ChemicalStandard (al); } + void load_frame (Frame& frame) const + { + Abiotic::load_frame (frame); + frame.declare ("decompose_CO2_factor", "g CO2-C/cm^3/h", Attribute::None (), + Attribute::Const, + "CO2 development factor on decomposition."); + frame.set ("decompose_CO2_factor", PLF::empty ()); + frame.declare ("decompose_depth_factor", "cm", Attribute::None (), + Attribute::Const, + "Depth influence on decomposition."); + frame.set ("decompose_depth_factor", PLF::always_1 ()); + } + ChemicalStandardSyntax () + : DeclareModel (Chemical::component, "default", "base", "\ +Read chemical properties as normal Daisy parameters.") + { } + } ChemicalStandard_syntax; + + static struct ChemicalFOCUSSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new ChemicalFOCUS (al); } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "focusgw2002", "focussw2002"); + frame.declare ("B", Attribute::None (), Check::none (), + Attribute::Const, "Soil moisture effect parameter."); + frame.set_cited ("B", 0.49, "Section 7.4.5", "focussw2002"); + frame.declare ("T_ref", "dg C", Check::none (), + Attribute::Const, "Reference temperature."); + frame.set_cited ("T_ref", 20.0, "Section 7.4.2", "focussw2002"); + frame.declare ("alpha", "K^-1", Check::none (), + Attribute::Const, "Temperature effect parameter."); + frame.set_cited ("alpha", 0.0948, "Section 7.4.4", "focussw2002"); + frame.declare ("z", "cm", Check::negative (), Attribute::Const, + Attribute::Variable, "\ End of each interval."); - frame.set_check ("z", VCheck::decreasing ()); - frame.set ("z", std::vector ({ -30.0, -60.0, -100.0 })); - frame.declare ("z_factor", Attribute::None (), Check::non_negative (), - Attribute::Const, Attribute::Variable, "\ + frame.set_check ("z", VCheck::decreasing ()); + frame.set ("z", std::vector ({ -30.0, -60.0, -100.0 })); + frame.declare ("z_factor", Attribute::None (), Check::non_negative (), + Attribute::Const, Attribute::Variable, "\ Factor to apply to decompose rate at each interval."); - frame.set ("z_factor", std::vector ({1.0, 0.5, 0.3})); + frame.set ("z_factor", std::vector ({1.0, 0.5, 0.3})); - // 'base' paramaters. - Rate::set_halftime_cited (frame, "canopy_dissipation", 10.0 * 24.0, - "Section 7.4.10", "focussw2002"); - frame.set_cited ("canopy_washoff_coefficient", 0.075, "\ + // 'base' paramaters. + Rate::set_halftime_cited (frame, "canopy_dissipation", 10.0 * 24.0, + "Section 7.4.10", "focussw2002"); + frame.set_cited ("canopy_washoff_coefficient", 0.075, "\ Washoff in FOCUS use FEXTRC = 0.05.\n\ CWC = IC * FEXTRC\n\ CWC = canopy_washoff_coefficient in Daisy\n\ @@ -2807,14 +2820,14 @@ IC = intercepted water in Daisy\n\ Default interception capacity in Daisy is LAI * 0.5 mm\n\ The FEXTRC parameter is based on an experiment with mature cotton.\n\ If we assume this is LAI=3, then corresponding CWC is 0.075.", - "focussw2002"); - frame.set_cited ("crop_uptake_reflection_factor", 1.0, - "Recommended value.", "focusgw2002"); - frame.set_cited ("diffusion_coefficient", 5e-6, - "Section 7.3.5", "focussw2002"); - } - ChemicalFOCUSSyntax () - : DeclareModel (Chemical::component, "FOCUS", "base", "\ + "focussw2002"); + frame.set_cited ("crop_uptake_reflection_factor", 1.0, + "Recommended value.", "focusgw2002"); + frame.set_cited ("diffusion_coefficient", 5e-6, + "Section 7.3.5", "focussw2002"); + } + ChemicalFOCUSSyntax () + : DeclareModel (Chemical::component, "FOCUS", "base", "\ Pesticides inspired by FOCUS surface water.\n\ \n\ Depth, moisture, and heat effect according to the FOCUS Surface Water WG.\n\ @@ -2828,180 +2841,167 @@ Heat factor is zero below zero degrees,\n\ and e^(alpha (T - T_ref)) above 5 dg C. From MACRO 5.0.\n\ \n\ Depth factor is specified by 'z' and 'z_factor'.") - { } -} ChemicalFOCUS_syntax; - -// The 'nutrient' chemical model. - -struct ChemicalNutrient : public ChemicalBase -{ - double decompose_soil_factor (size_t c, // FIXME: WHy is c not used? - const Geometry&, const Soil&, - const SoilWater&, const SoilHeat&, - const OrganicMatter&) const - { return 1.0; } - ChemicalNutrient (const BlockModel& al) - : ChemicalBase (al) - { } -}; + { } + } ChemicalFOCUS_syntax; -static struct ChemicalNutrientSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new ChemicalNutrient (al); } - void load_frame (Frame& frame) const + static struct ChemicalNutrientSyntax : public DeclareModel { - frame.set ("crop_uptake_reflection_factor", 1.0); // Specific uptake code. - Rate::set_rate (frame, "canopy_dissipation", 0.0); - frame.set ("canopy_washoff_coefficient", 1.0); - Rate::set_rate (frame, "decompose", 0.0); - } - ChemicalNutrientSyntax () - : DeclareModel (Chemical::component, "nutrient", "base", "\ + Model* make (const BlockModel& al) const + { return new ChemicalNutrient (al); } + void load_frame (Frame& frame) const + { + frame.set ("crop_uptake_reflection_factor", 1.0); // Specific uptake code. + Rate::set_rate (frame, "canopy_dissipation", 0.0); + frame.set ("canopy_washoff_coefficient", 1.0); + Rate::set_rate (frame, "decompose", 0.0); + } + ChemicalNutrientSyntax () + : DeclareModel (Chemical::component, "nutrient", "base", "\ Plants eat this stuff.") - { } -} ChemicalNutrient_syntax; + { } + } ChemicalNutrient_syntax; -static struct ChemicalNitrogenSyntax : public DeclareParam -{ - ChemicalNitrogenSyntax () - : DeclareParam (Chemical::component, "N", "nutrient", "\ + static struct ChemicalNitrogenSyntax : public DeclareParam + { + ChemicalNitrogenSyntax () + : DeclareParam (Chemical::component, "N", "nutrient", "\ Nitrogen.") - { } - void load_frame (Frame&) const - { } -} ChemicalNitrogen_syntax; + { } + void load_frame (Frame&) const + { } + } ChemicalNitrogen_syntax; -static struct ChemicalMINSyntax : public DeclareParam -{ - ChemicalMINSyntax () - : DeclareParam (Chemical::component, "MIN", "N", "\ + static struct ChemicalMINSyntax : public DeclareParam + { + ChemicalMINSyntax () + : DeclareParam (Chemical::component, "MIN", "N", "\ Non-organic nitrogen.") - { } - void load_frame (Frame&) const - { } -} ChemicalMIN_syntax; + { } + void load_frame (Frame&) const + { } + } ChemicalMIN_syntax; -static struct InitialNO3Syntax : public DeclareParam -{ - InitialNO3Syntax () - : DeclareParam (Number::component, "initial_NO3", "initial_C", "\ + static struct InitialNO3Syntax : public DeclareParam + { + InitialNO3Syntax () + : DeclareParam (Number::component, "initial_NO3", "initial_C", "\ Initial NO3 concentration in soil water.") - { } - void load_frame (Frame& frame) const - { - // We initialize to approximatey half the allowed content in - // drinking water [ 0.5 * 50 mg NO3/l ~= 5.0e-6 g NO3-N/cm^3 ] - frame.set ("C", 5e-6); - } -} InitialNO3_syntax; + { } + void load_frame (Frame& frame) const + { + // We initialize to approximatey half the allowed content in + // drinking water [ 0.5 * 50 mg NO3/l ~= 5.0e-6 g NO3-N/cm^3 ] + frame.set ("C", 5e-6); + } + } InitialNO3_syntax; -static struct ChemicalNO3Syntax : public DeclareParam -{ - ChemicalNO3Syntax () - : DeclareParam (Chemical::component, "NO3", "MIN", "\ + static struct ChemicalNO3Syntax : public DeclareParam + { + ChemicalNO3Syntax () + : DeclareParam (Chemical::component, "NO3", "MIN", "\ Nitrate-N.") - { } - void load_frame (Frame& frame) const - { - frame.set ("diffusion_coefficient", 2.0e-5); - frame.set ("initial", "initial_NO3"); - } -} ChemicalNO3_syntax; + { } + void load_frame (Frame& frame) const + { + frame.set ("diffusion_coefficient", 2.0e-5); + frame.set ("initial", "initial_NO3"); + } + } ChemicalNO3_syntax; -static struct AdsorptionNH4Syntax : public DeclareParam -{ - AdsorptionNH4Syntax () - : DeclareParam (Adsorption::component, "NH4", "linear", "\ + static struct AdsorptionNH4Syntax : public DeclareParam + { + AdsorptionNH4Syntax () + : DeclareParam (Adsorption::component, "NH4", "linear", "\ Adsorption of ammonium, fitted by Styczen for Daisy 7.") - { } - void load_frame (Frame& frame) const - { - frame.set ("K_clay", 28.); - frame.set ("K_OC", 213.); - } -} AdsorptionNH4_syntax; + { } + void load_frame (Frame& frame) const + { + frame.set ("K_clay", 28.); + frame.set ("K_OC", 213.); + } + } AdsorptionNH4_syntax; -static struct AdsorptionNH4_HansenSyntax : public DeclareParam -{ - AdsorptionNH4_HansenSyntax () - : DeclareParam (Adsorption::component, "NH4_Hansen", "linear", "\ + static struct AdsorptionNH4_HansenSyntax : public DeclareParam + { + AdsorptionNH4_HansenSyntax () + : DeclareParam (Adsorption::component, "NH4_Hansen", "linear", "\ Adsorption of ammonium, traditional value.") - { } - void load_frame (Frame& frame) const - { - frame.set ("K_clay", 117.116); - frame.set ("K_OC", 117.116); - } -} AdsorptionNH4_Hansen_syntax; + { } + void load_frame (Frame& frame) const + { + frame.set ("K_clay", 117.116); + frame.set ("K_OC", 117.116); + } + } AdsorptionNH4_Hansen_syntax; -static struct InitialNH4Syntax : public DeclareParam -{ - InitialNH4Syntax () - : DeclareParam (Number::component, "initial_NH4", "initial_C", "\ + static struct InitialNH4Syntax : public DeclareParam + { + InitialNH4Syntax () + : DeclareParam (Number::component, "initial_NH4", "initial_C", "\ Initial NH4 concentration in soil water.") - { } - void load_frame (Frame& frame) const - { - // We initialize to approximatey 5% of the N corresponding to the - // allowed content of NO3 in drinking water. - // [ 0.05 * 50 mg/l = 0.5e-6 g/cm^3 ] - frame.set ("C", 0.55e-6); - } -} InitialNH4_syntax; + { } + void load_frame (Frame& frame) const + { + // We initialize to approximatey 5% of the N corresponding to the + // allowed content of NO3 in drinking water. + // [ 0.05 * 50 mg/l = 0.5e-6 g/cm^3 ] + frame.set ("C", 0.55e-6); + } + } InitialNH4_syntax; -static struct ChemicalNH4Syntax : public DeclareParam -{ - ChemicalNH4Syntax () - : DeclareParam (Chemical::component, "NH4", "MIN", "\ + static struct ChemicalNH4Syntax : public DeclareParam + { + ChemicalNH4Syntax () + : DeclareParam (Chemical::component, "NH4", "MIN", "\ Ammonium-N.") - { } - void load_frame (Frame& frame) const - { - frame.set ("adsorption", "NH4"); - frame.set ("diffusion_coefficient", 1.8e-5); - frame.set ("initial", "initial_NH4"); - } -} ChemicalNH4_syntax; + { } + void load_frame (Frame& frame) const + { + frame.set ("adsorption", "NH4"); + frame.set ("diffusion_coefficient", 1.8e-5); + frame.set ("initial", "initial_NH4"); + } + } ChemicalNH4_syntax; -static struct ChemicalDONSyntax : public DeclareParam -{ - ChemicalDONSyntax () - : DeclareParam (Chemical::component, "DON", "N", "\ + static struct ChemicalDONSyntax : public DeclareParam + { + ChemicalDONSyntax () + : DeclareParam (Chemical::component, "DON", "N", "\ Nitrate-N.") - { } - void load_frame (Frame& frame) const - { - frame.set_cited ("diffusion_coefficient", 1.9e-6, "900 Da, 2.5 nm", - "hendry2003geochemical"); - // Max. for Dp, optimized at 1.46 h-1 for glyphosate. JV 2021-10-27 - Rate::set_rate (frame, "litter_diffusion_rate", 1.5); - } -} ChemicalDON_syntax; + { } + void load_frame (Frame& frame) const + { + frame.set_cited ("diffusion_coefficient", 1.9e-6, "900 Da, 2.5 nm", + "hendry2003geochemical"); + // Max. for Dp, optimized at 1.46 h-1 for glyphosate. JV 2021-10-27 + Rate::set_rate (frame, "litter_diffusion_rate", 1.5); + } + } ChemicalDON_syntax; -static struct ChemicalCarbonSyntax : public DeclareParam -{ - ChemicalCarbonSyntax () - : DeclareParam (Chemical::component, "C", "nutrient", "\ + static struct ChemicalCarbonSyntax : public DeclareParam + { + ChemicalCarbonSyntax () + : DeclareParam (Chemical::component, "C", "nutrient", "\ Carbon.") - { } - void load_frame (Frame&) const - { } -} ChemicalCarbon_syntax; + { } + void load_frame (Frame&) const + { } + } ChemicalCarbon_syntax; -static struct ChemicalDOCSyntax : public DeclareParam -{ - ChemicalDOCSyntax () - : DeclareParam (Chemical::component, "DOC", "C", "\ + static struct ChemicalDOCSyntax : public DeclareParam + { + ChemicalDOCSyntax () + : DeclareParam (Chemical::component, "DOC", "C", "\ Nitrate-N.") - { } - void load_frame (Frame& frame) const - { - frame.set_cited ("diffusion_coefficient", 1.9e-6, "900 Da, 2.5 nm", - "hendry2003geochemical"); - // Max. for Dp, optimized at 1.46 h-1 for glyphosate. JV 2021-10-27 - Rate::set_rate (frame, "litter_diffusion", 1.5); - } -} ChemicalDOC_syntax; + { } + void load_frame (Frame& frame) const + { + frame.set_cited ("diffusion_coefficient", 1.9e-6, "900 Da, 2.5 nm", + "hendry2003geochemical"); + // Max. for Dp, optimized at 1.46 h-1 for glyphosate. JV 2021-10-27 + Rate::set_rate (frame, "litter_diffusion", 1.5); + } + } ChemicalDOC_syntax; +} // chemical_std.C ends here. diff --git a/src/daisy/chemicals/chemistry.C b/src/daisy/chemicals/chemistry.C index fb139275e..e06de23ef 100644 --- a/src/daisy/chemicals/chemistry.C +++ b/src/daisy/chemicals/chemistry.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/chemicals/chemistry.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/chemicals/im.h" #include "daisy/chemicals/chemical.h" #include "object_model/treelog.h" @@ -113,14 +114,31 @@ Chemistry::Chemistry (const BlockModel& al) Chemistry::~Chemistry () { } -static struct ChemistryInit : public DeclareComponent +void +register_chemistry_models () { - ChemistryInit () - : DeclareComponent (Chemistry::component, "\ + static struct ChemistryInit : public DeclareComponent + { + ChemistryInit () + : DeclareComponent (Chemistry::component, "\ Pesticides and other chemicals.") - { } - void load_frame (Frame& frame) const - { Model::load_model (frame); } -} Chemistry_init; + { } + void load_frame (Frame& frame) const + { Model::load_model (frame); } + } Chemistry_init; + + register_awi_models (); + register_ponddamp_models (); + register_rainergy_models (); + register_denprod_models (); + register_nitrification_models (); + register_equilibrium_models (); + register_transform_models (); + register_adsorption_models (); + register_reaction_models (); + register_chemical_models (); + register_chemistry_standard_models (); + register_chemistry_multi_models (); +} // chemistry.C ends here. diff --git a/src/daisy/chemicals/chemistry_multi.C b/src/daisy/chemicals/chemistry_multi.C index de1cc24c6..1daed094d 100644 --- a/src/daisy/chemicals/chemistry_multi.C +++ b/src/daisy/chemicals/chemistry_multi.C @@ -448,7 +448,6 @@ ChemistryMulti::suggest_dt () const return dt; } - void ChemistryMulti::tick_top (const Geometry& geo, const Soil& soil, const SoilWater& soil_water, @@ -588,46 +587,49 @@ ChemistryMulti::ChemistryMulti (const BlockModel& al) chemicals (find_chemicals (combine)) { } -static struct ChemistryMultiSyntax : public DeclareModel +void +register_chemistry_multi_models () { - Model* make (const BlockModel& al) const - { return new ChemistryMulti (al); } - ChemistryMultiSyntax () - : DeclareModel (Chemistry::component, "multi", "Handle multile chemistries.") - { } - void load_frame (Frame& frame) const + static struct ChemistryMultiSyntax : public DeclareModel { + Model* make (const BlockModel& al) const + { return new ChemistryMulti (al); } + ChemistryMultiSyntax () + : DeclareModel (Chemistry::component, "multi", "Handle multile chemistries.") + { } + void load_frame (Frame& frame) const + { - frame.declare_object ("combine", Chemistry::component, - Attribute::State, Attribute::Variable, "\ + frame.declare_object ("combine", Chemistry::component, + Attribute::State, Attribute::Variable, "\ List of chemistry parameterizations you want to combine."); - frame.declare_string ("ignore", Attribute::State, Attribute::Variable, - "Don't warn when spraying one of these chemicals.\n\ + frame.declare_string ("ignore", Attribute::State, Attribute::Variable, + "Don't warn when spraying one of these chemicals.\n\ The first time an untraced chemical not on the list is sprayed on the\n\ field, Daisy will issue a warning and add the chemical to this list."); - frame.set_check ("ignore", VCheck::unique ()); - frame.set_empty ("ignore"); - frame.declare_object ("trace", Chemical::component, - Attribute::LogOnly, Attribute::Variable, "\ + frame.set_check ("ignore", VCheck::unique ()); + frame.set_empty ("ignore"); + frame.declare_object ("trace", Chemical::component, + Attribute::LogOnly, Attribute::Variable, "\ List of chemicals in nested chemistries."); - frame.declare ("max_sink_total", Attribute::None (), Check::positive (), - Attribute::Const, "\ + frame.declare ("max_sink_total", Attribute::None (), Check::positive (), + Attribute::Const, "\ Maximum allowed sink term as a fraction of total content.\n\ \n\ If variable timesteps are enabled, Daisy will try to scale down the\n\ timestep in order to ensure that no more than this fraction of the\n\ total content is removed by drains or biopores within the timestep."); - frame.set ("max_sink_total", 0.5); - frame.declare ("max_sink_solute", Attribute::None (), Check::positive (), - Attribute::Const, "\ + frame.set ("max_sink_total", 0.5); + frame.declare ("max_sink_solute", Attribute::None (), Check::positive (), + Attribute::Const, "\ Maximum allowed sink term as a fraction of solute content.\n\ \n\ If variable timesteps are enabled, Daisy will try to scale down the\n\ timestep in order to ensure that no more than this fraction of the\n\ solute content is removed by drains or biopores within the timestep."); - frame.set ("max_sink_solute", 0.9); - frame.declare ("max_sink_secondary", Attribute::None (), Check::positive (), - Attribute::Const, "\ + frame.set ("max_sink_solute", 0.9); + frame.declare ("max_sink_secondary", Attribute::None (), Check::positive (), + Attribute::Const, "\ Maximum allowed sink term as a fraction of secondary domain content.\n\ \n \ If variable timesteps are enabled, Daisy will try to scale down the\n\ @@ -635,35 +637,36 @@ timestep in order to ensure that no more than this fraction of the\n\ secondary domain content is removed by drains or biopores within the\n\ timestep. This should usually be above 1 to allow for the case where\n\ the secondary domain is emptied within a timestep."); - frame.set ("max_sink_secondary", 1.5); - - frame.declare ("min_sink_total", Attribute::None (), Check::positive (), - Attribute::Const, "\n\ + frame.set ("max_sink_secondary", 1.5); + + frame.declare ("min_sink_total", Attribute::None (), Check::positive (), + Attribute::Const, "\n\ Always allow this fraction of total content to be removed by sink term.\n\ \n\ This overwrites all the 'max_sink' parameters."); - frame.set ("min_sink_total", 0.01); - } -} ChemistryMulti_syntax; + frame.set ("min_sink_total", 0.01); + } + } ChemistryMulti_syntax; -static struct ChemistryNutrientSyntax : public DeclareParam -{ - ChemistryNutrientSyntax () - : DeclareParam (Chemistry::component, "nutrient", "multi", "\ + static struct ChemistryNutrientSyntax : public DeclareParam + { + ChemistryNutrientSyntax () + : DeclareParam (Chemistry::component, "nutrient", "multi", "\ Include 'N' chemistry so organic matter and plants will work.") - { } - void load_frame (Frame& frame) const - { frame.set_strings ("combine", "N"); } -} ChemistryNutrient_syntax; - -static struct ChemistryNoneSyntax : public DeclareParam -{ - ChemistryNoneSyntax () - : DeclareParam (Chemistry::component, "none", "multi", "\ + { } + void load_frame (Frame& frame) const + { frame.set_strings ("combine", "N"); } + } ChemistryNutrient_syntax; + + static struct ChemistryNoneSyntax : public DeclareParam + { + ChemistryNoneSyntax () + : DeclareParam (Chemistry::component, "none", "multi", "\ No active chemistries.") - { } - void load_frame (Frame& frame) const - { frame.set_empty ("combine"); } -} ChemistryNone_syntax; + { } + void load_frame (Frame& frame) const + { frame.set_empty ("combine"); } + } ChemistryNone_syntax; +} // chemistry_multi.C ends here diff --git a/src/daisy/chemicals/chemistry_std.C b/src/daisy/chemicals/chemistry_std.C index 59bd101eb..2fd124fd2 100644 --- a/src/daisy/chemicals/chemistry_std.C +++ b/src/daisy/chemicals/chemistry_std.C @@ -545,52 +545,56 @@ ChemistryStandard::ChemistryStandard (const BlockModel& al) reactions (Librarian::build_vector (al, "reaction")) { } -static struct ChemistryStandardSyntax : public DeclareModel +void +register_chemistry_standard_models () { - Model* make (const BlockModel& al) const - { return new ChemistryStandard (al); } - ChemistryStandardSyntax () - : DeclareModel (Chemistry::component, "default", "\ + static struct ChemistryStandardSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new ChemistryStandard (al); } + ChemistryStandardSyntax () + : DeclareModel (Chemistry::component, "default", "\ Handle chemicals and reactions.") - { } - void load_frame (Frame& frame) const - { - frame.declare_object ("trace", Chemical::component, - Attribute::State, Attribute::Variable, "\ + { } + void load_frame (Frame& frame) const + { + frame.declare_object ("trace", Chemical::component, + Attribute::State, Attribute::Variable, "\ List of chemicals you want to trace in the simulation."); - frame.set_check ("trace", VCheck::unique ()); - frame.set_empty ("trace"); - frame.declare_object ("reaction", Reaction::component, - Attribute::State, Attribute::Variable, "\ + frame.set_check ("trace", VCheck::unique ()); + frame.set_empty ("trace"); + frame.declare_object ("reaction", Reaction::component, + Attribute::State, Attribute::Variable, "\ List of chemical reactions you want to simulate."); - frame.set_empty ("reaction"); - } -} ChemistryStandard_syntax; + frame.set_empty ("reaction"); + } + } ChemistryStandard_syntax; -static struct ChemistryNitrogenSyntax : public DeclareParam -{ - ChemistryNitrogenSyntax () - : DeclareParam (Chemistry::component, "N", "default", "\ -Inorganic nitrogen.") - { } - void load_frame (Frame& frame) const + static struct ChemistryNitrogenSyntax : public DeclareParam { - frame.set_strings ("trace", "NO3", "NH4"); - frame.set_strings ("reaction", "nitrification", "denitrification"); - } -} ChemistryNitrogen_syntax; + ChemistryNitrogenSyntax () + : DeclareParam (Chemistry::component, "N", "default", "\ +Inorganic nitrogen.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("trace", "NO3", "NH4"); + frame.set_strings ("reaction", "nitrification", "denitrification"); + } + } ChemistryNitrogen_syntax; -static struct ChemistryDOMSyntax : public DeclareParam -{ - ChemistryDOMSyntax () - : DeclareParam (Chemistry::component, "DOM", "default", "\ -Disolved organic matter.") - { } - void load_frame (Frame& frame) const + static struct ChemistryDOMSyntax : public DeclareParam { - frame.set_strings ("trace", "DON", "DOC"); - frame.set_strings ("reaction", "DOM_turnover"); - } -} ChemistryDOM_syntax; + ChemistryDOMSyntax () + : DeclareParam (Chemistry::component, "DOM", "default", "\ +Disolved organic matter.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("trace", "DON", "DOC"); + frame.set_strings ("reaction", "DOM_turnover"); + } + } ChemistryDOM_syntax; +} // chemistry_std.C ends her. diff --git a/src/daisy/chemicals/denprod.C b/src/daisy/chemicals/denprod.C index 8e19df84d..4c1c0333a 100644 --- a/src/daisy/chemicals/denprod.C +++ b/src/daisy/chemicals/denprod.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/chemicals/denprod.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/librarian.h" #include "object_model/block_model.h" @@ -42,12 +43,18 @@ Denprod::Denprod (const BlockModel& al) Denprod::~Denprod () { } -static struct DenprodInit : public DeclareComponent +void +register_denprod_models () { - DenprodInit () - : DeclareComponent (Denprod::component, "\ + static struct DenprodInit : public DeclareComponent + { + DenprodInit () + : DeclareComponent (Denprod::component, "\ Find products (gasses) produced by denitrification.") - { } -} Denprod_init; + { } + } Denprod_init; + + register_denprod_parton1996_models (); +} // denprod.C ends here. diff --git a/src/daisy/chemicals/denprod_Parton1996.C b/src/daisy/chemicals/denprod_Parton1996.C index 14c5bd6a0..1a361d3bf 100644 --- a/src/daisy/chemicals/denprod_Parton1996.C +++ b/src/daisy/chemicals/denprod_Parton1996.C @@ -54,24 +54,6 @@ struct FunctionP96WFPS : public FunctionPlotable { } }; -static struct FunctionP96WFPSSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new FunctionP96WFPS (al); } - FunctionP96WFPSSyntax () - : DeclareModel (Function::component, "P96WFPS", - "Water filed pore space effect on N2/N2O ratio.\n\ -Figure 5, top. Note extra parentheses compared to source.") - { } - void load_frame (Frame& frame) const - { - frame.set ("domain", Attribute::Fraction ()); - frame.set ("range", Attribute::None ()); - frame.set_strings ("cite", "Parton1996"); - frame.set ("formula", "\\frac{1.4}{13^{\\left(13^{\\left(\\frac{17}{2.2\\; \\mathrm{wfps}}\\right)}\\right)}}"); - } -} FunctionP96WFPS_syntax; - // The 'P96NO3' function. struct FunctionP96NO3 : public FunctionPlotable @@ -92,24 +74,6 @@ struct FunctionP96NO3 : public FunctionPlotable { } }; -static struct FunctionP96NO3Syntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new FunctionP96NO3 (al); } - FunctionP96NO3Syntax () - : DeclareModel (Function::component, "P96NO3", - "NO3 effect on N2/N2O ratio.\n\ -Figure 5, middle. Note extra parentheses compared to source.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "Parton1996"); - frame.set ("domain", "ug N/g"); - frame.set ("range", Attribute::None ()); - frame.set ("formula", "\\left(1 - \\left(0.5 + \\frac{1\\arctan{(\\pi\\;0.01\\; (\\textrm{NO3}-190))}}{\\pi}\\right)\\right) 25"); - } -} FunctionP96NO3_syntax; - // The 'P96CO2' function. struct FunctionP96CO2 : public FunctionPlotable @@ -129,24 +93,6 @@ struct FunctionP96CO2 : public FunctionPlotable { } }; -static struct FunctionP96CO2Syntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new FunctionP96CO2 (al); } - FunctionP96CO2Syntax () - : DeclareModel (Function::component, "P96CO2", - "CO2 effect on N2/N2O ratio.\n\ -Figure 5, bottom.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "Parton1996"); - frame.set ("domain", "kg C/ha/d"); - frame.set ("range", Attribute::None ()); - frame.set ("formula", "13+\\frac{30.78 \\arctan{(\\pi\\;0.07\\;(\\textrm{CO2}-13))}}{\\pi}"); - } -} FunctionP96CO2_syntax; - // The 'Parton1996' denprod model. struct DenprodParton1996 : public Denprod @@ -206,33 +152,91 @@ struct DenprodParton1996 : public Denprod { } }; -static struct DenprodParton1996Syntax : public DeclareModel +void +register_denprod_parton1996_models () { - Model* make (const BlockModel& al) const - { return new DenprodParton1996 (al); } - DenprodParton1996Syntax () - : DeclareModel (Denprod::component, "Parton1996", "\ -Find N2O from denitrification based on WFPS, NO3, and CO2.") - { } - void load_frame (Frame& frame) const + static struct FunctionP96WFPSSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new FunctionP96WFPS (al); } + FunctionP96WFPSSyntax () + : DeclareModel (Function::component, "P96WFPS", + "Water filed pore space effect on N2/N2O ratio.\n\ +Figure 5, top. Note extra parentheses compared to source.") + { } + void load_frame (Frame& frame) const + { + frame.set ("domain", Attribute::Fraction ()); + frame.set ("range", Attribute::None ()); + frame.set_strings ("cite", "Parton1996"); + frame.set ("formula", "\\frac{1.4}{13^{\\left(13^{\\left(\\frac{17}{2.2\\; \\mathrm{wfps}}\\right)}\\right)}}"); + } + } FunctionP96WFPS_syntax; + + static struct FunctionP96NO3Syntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new FunctionP96NO3 (al); } + FunctionP96NO3Syntax () + : DeclareModel (Function::component, "P96NO3", + "NO3 effect on N2/N2O ratio.\n\ +Figure 5, middle. Note extra parentheses compared to source.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "Parton1996"); + frame.set ("domain", "ug N/g"); + frame.set ("range", Attribute::None ()); + frame.set ("formula", "\\left(1 - \\left(0.5 + \\frac{1\\arctan{(\\pi\\;0.01\\; (\\textrm{NO3}-190))}}{\\pi}\\right)\\right) 25"); + } + } FunctionP96NO3_syntax; + + static struct FunctionP96CO2Syntax : public DeclareModel { - frame.declare_function ("FR_NO3", "ug N/g", Attribute::None (), "\ + Model* make (const BlockModel& al) const + { return new FunctionP96CO2 (al); } + FunctionP96CO2Syntax () + : DeclareModel (Function::component, "P96CO2", + "CO2 effect on N2/N2O ratio.\n\ +Figure 5, bottom.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "Parton1996"); + frame.set ("domain", "kg C/ha/d"); + frame.set ("range", Attribute::None ()); + frame.set ("formula", "13+\\frac{30.78 \\arctan{(\\pi\\;0.07\\;(\\textrm{CO2}-13))}}{\\pi}"); + } + } FunctionP96CO2_syntax; + + static struct DenprodParton1996Syntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new DenprodParton1996 (al); } + DenprodParton1996Syntax () + : DeclareModel (Denprod::component, "Parton1996", "\ +Find N2O from denitrification based on WFPS, NO3, and CO2.") + { } + void load_frame (Frame& frame) const + { + frame.declare_function ("FR_NO3", "ug N/g", Attribute::None (), "\ NO3 effect N2O."); - frame.set ("FR_NO3", "P96NO3"); - frame.declare_function ("FR_CO2", "kg C/ha/d", Attribute::None (), "\ + frame.set ("FR_NO3", "P96NO3"); + frame.declare_function ("FR_CO2", "kg C/ha/d", Attribute::None (), "\ CO2 effect N2O."); - frame.set ("FR_CO2", "P96CO2"); - frame.declare_function ("FR_WFPS", - Attribute::Fraction (), Attribute::None (), "\ + frame.set ("FR_CO2", "P96CO2"); + frame.declare_function ("FR_WFPS", + Attribute::Fraction (), Attribute::None (), "\ WFPS effect N2O."); - frame.set ("FR_WFPS", "P96WFPS"); - frame.declare ("FR_CO2_depth", "cm", Attribute::Const, "\ + frame.set ("FR_WFPS", "P96WFPS"); + frame.declare ("FR_CO2_depth", "cm", Attribute::Const, "\ Depth used for converting CO2 from volume to area units."); - frame.set ("FR_CO2_depth", 30.0); - frame.declare ("N2O", "g N/cm^3/h", - Attribute::LogOnly, Attribute::Variable, - "Amount of N2O-N generated by denitrification."); - } -} DenprodParton1996_syntax; + frame.set ("FR_CO2_depth", 30.0); + frame.declare ("N2O", "g N/cm^3/h", + Attribute::LogOnly, Attribute::Variable, + "Amount of N2O-N generated by denitrification."); + } + } DenprodParton1996_syntax; +} // denprod.C ends here. diff --git a/src/daisy/chemicals/equil.C b/src/daisy/chemicals/equil.C index 8618d6fc3..f917eb64c 100644 --- a/src/daisy/chemicals/equil.C +++ b/src/daisy/chemicals/equil.C @@ -20,8 +20,8 @@ #define BUILD_DLL - #include "daisy/chemicals/equil.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" #include "object_model/frame.h" @@ -41,12 +41,20 @@ Equilibrium::Equilibrium (const BlockModel& al) // FIXME: Why is al not used? Equilibrium::~Equilibrium () { } -static struct EquilibriumInit : public DeclareComponent +void +register_equilibrium_models () { - EquilibriumInit () - : DeclareComponent (Equilibrium::component, "\ + static struct EquilibriumInit : public DeclareComponent + { + EquilibriumInit () + : DeclareComponent (Equilibrium::component, "\ Find equilibrium between two soil chemicals.") - { } - void load_frame (Frame& frame) const - { Model::load_model (frame); } -} Equilibrium_init; + { } + void load_frame (Frame& frame) const + { Model::load_model (frame); } + } Equilibrium_init; + + register_equil_goal_models (); + register_equil_langmuir_models (); + register_equil_linear_models (); +} diff --git a/src/daisy/chemicals/equil_goal.C b/src/daisy/chemicals/equil_goal.C index da87675c6..7603ba6e4 100644 --- a/src/daisy/chemicals/equil_goal.C +++ b/src/daisy/chemicals/equil_goal.C @@ -153,31 +153,34 @@ EquilibriumGoal_A::check (const Units& units, return ok; } -static struct EquilibriumGoal_ASyntax : public DeclareModel +void +register_equil_goal_models () { - Model* make (const BlockModel& al) const - { return new EquilibriumGoal_A (al); } - - EquilibriumGoal_ASyntax () - : DeclareModel (Equilibrium::component, "goal_A", "Attempt to maintain A at at fixed level.") - { } - void load_frame (Frame& frame) const + static struct EquilibriumGoal_ASyntax : public DeclareModel { - frame.declare_object ("goal_A", Number::component, Attribute::Const, - Attribute::Singleton, "The desired level of A [g/cm^3]."); - frame.declare_boolean ("A_solute", Attribute::Const, - "True iff 'goal_A' is in solute (mass per volume water).\n\ + Model* make (const BlockModel& al) const + { return new EquilibriumGoal_A (al); } + + EquilibriumGoal_ASyntax () + : DeclareModel (Equilibrium::component, "goal_A", "Attempt to maintain A at at fixed level.") + { } + void load_frame (Frame& frame) const + { + frame.declare_object ("goal_A", Number::component, Attribute::Const, + Attribute::Singleton, "The desired level of A [g/cm^3]."); + frame.declare_boolean ("A_solute", Attribute::Const, + "True iff 'goal_A' is in solute (mass per volume water).\n\ If false, the unit is assumed to be mass per volume space."); - frame.declare_object ("min_B", Number::component, Attribute::Const, - Attribute::Singleton, "\ + frame.declare_object ("min_B", Number::component, Attribute::Const, + Attribute::Singleton, "\ Do not convert B to A if B is smaller than this [g/cm^3]."); - frame.declare_boolean ("B_solute", Attribute::Const, - "True iff 'min_B' is in solute (mass per volume water).\n\ + frame.declare_boolean ("B_solute", Attribute::Const, + "True iff 'min_B' is in solute (mass per volume water).\n\ If false, the unit is assumed to be mass per volume space."); - frame.declare_integer ("debug_cell", Attribute::Const, - "Print debug information for this cell.\n\ + frame.declare_integer ("debug_cell", Attribute::Const, + "Print debug information for this cell.\n\ Set it to a negative number to disable it."); - frame.set ("debug_cell", -1); - } -} EquilibriumGoal_A_syntax; - + frame.set ("debug_cell", -1); + } + } EquilibriumGoal_A_syntax; +} diff --git a/src/daisy/chemicals/equil_langmuir.C b/src/daisy/chemicals/equil_langmuir.C index 05ac8fb37..db51843d0 100644 --- a/src/daisy/chemicals/equil_langmuir.C +++ b/src/daisy/chemicals/equil_langmuir.C @@ -118,22 +118,26 @@ EquilibriumLangmuir::check (const Units& units, return ok; } -static struct EquilibriumLangmuirSyntax : public DeclareModel +void +register_equil_langmuir_models () { - Model* make (const BlockModel& al) const - { return new EquilibriumLangmuir (al); } - - EquilibriumLangmuirSyntax () - : DeclareModel (Equilibrium::component, - "Langmuir", "A = (my_max B) / (K + B)") - { } - void load_frame (Frame& frame) const + static struct EquilibriumLangmuirSyntax : public DeclareModel { - frame.declare_object ("K", Number::component, - Attribute::Const, Attribute::Singleton, - "Half saturation constant [g/cm^3]."); - frame.declare_object ("my_max", Number::component, - Attribute::Const, Attribute::Singleton, - "Max equilibrium capacity [g/cm^3]."); - } -} EquilibriumLangmuir_syntax; + Model* make (const BlockModel& al) const + { return new EquilibriumLangmuir (al); } + + EquilibriumLangmuirSyntax () + : DeclareModel (Equilibrium::component, + "Langmuir", "A = (my_max B) / (K + B)") + { } + void load_frame (Frame& frame) const + { + frame.declare_object ("K", Number::component, + Attribute::Const, Attribute::Singleton, + "Half saturation constant [g/cm^3]."); + frame.declare_object ("my_max", Number::component, + Attribute::Const, Attribute::Singleton, + "Max equilibrium capacity [g/cm^3]."); + } + } EquilibriumLangmuir_syntax; +} diff --git a/src/daisy/chemicals/equil_linear.C b/src/daisy/chemicals/equil_linear.C index 4a8cbcc04..a8424ea2f 100644 --- a/src/daisy/chemicals/equil_linear.C +++ b/src/daisy/chemicals/equil_linear.C @@ -104,18 +104,22 @@ EquilibriumLinear::check (const Units& units, const Scope& scope, Treelog& msg) return ok; } -static struct EquilibriumLinearSyntax : public DeclareModel +void +register_equil_linear_models () { - Model* make (const BlockModel& al) const - { return new EquilibriumLinear (al); } - - EquilibriumLinearSyntax () - : DeclareModel (Equilibrium::component, "linear", "A = K B") - { } - void load_frame (Frame& frame) const + static struct EquilibriumLinearSyntax : public DeclareModel { - frame.declare_object ("K", Number::component, Attribute::Const, - Attribute::Singleton, "The ratio A/B at equilibrium []."); + Model* make (const BlockModel& al) const + { return new EquilibriumLinear (al); } - } -} EquilibriumLinear_syntax; + EquilibriumLinearSyntax () + : DeclareModel (Equilibrium::component, "linear", "A = K B") + { } + void load_frame (Frame& frame) const + { + frame.declare_object ("K", Number::component, Attribute::Const, + Attribute::Singleton, "The ratio A/B at equilibrium []."); + + } + } EquilibriumLinear_syntax; +} diff --git a/src/daisy/chemicals/nitrification.C b/src/daisy/chemicals/nitrification.C index 67aec4f34..bddf86c23 100644 --- a/src/daisy/chemicals/nitrification.C +++ b/src/daisy/chemicals/nitrification.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/chemicals/nitrification.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/frame.h" #include "daisy/soil/soil.h" @@ -71,18 +72,24 @@ Nitrification::Nitrification (const Frame& al) Nitrification::~Nitrification () { } -static struct NitrificationInit : public DeclareComponent +void +register_nitrification_models () { - NitrificationInit () - : DeclareComponent (Nitrification::component, "\ + static struct NitrificationInit : public DeclareComponent + { + NitrificationInit () + : DeclareComponent (Nitrification::component, "\ The nitrification process, transforming ammonium into nitrate and\n\ nitrous oxide.") - { } - void load_frame (Frame& frame) const - { - frame.declare_fraction ("N2O_fraction", Attribute::Const, - "Fraction of ammonium lost as N2O."); - frame.set ("N2O_fraction", 0.02); - } -} Nitrification_init; + { } + void load_frame (Frame& frame) const + { + frame.declare_fraction ("N2O_fraction", Attribute::Const, + "Fraction of ammonium lost as N2O."); + frame.set ("N2O_fraction", 0.02); + } + } Nitrification_init; + register_nitrification_soil_models (); + register_nitrification_solute_models (); +} diff --git a/src/daisy/chemicals/nitrification_soil.C b/src/daisy/chemicals/nitrification_soil.C index 1a2dab667..e6b8d2a4d 100644 --- a/src/daisy/chemicals/nitrification_soil.C +++ b/src/daisy/chemicals/nitrification_soil.C @@ -104,32 +104,6 @@ NitrificationSoil::NitrificationSoil (const Frame& al) water_factor (al.plf ("water_factor")) { } -static struct NitrificationSoilSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new NitrificationSoil (al); } - NitrificationSoilSyntax () - : DeclareModel (Nitrification::component, "soil", - "k_10 * M / (k + M). Michaelis-Menten kinetics,\n\ -with nitrification based on total ammonium content.") - { } - void load_frame (Frame& frame) const - { - frame.declare ("k", "g N/cm^3", Check::positive (), Attribute::Const, - "Half saturation constant."); - frame.set ("k", 5.0e-5); // [g N/cm^3] - frame.declare ("k_10", "g N/cm^3/h", Check::non_negative (), Attribute::Const, - "Max rate."); - frame.set ("k_10", 2.08333333333e-7); // 5e-6/24 [1/h] - frame.declare ("heat_factor", "dg C", Attribute::None (), Attribute::Const, - "Heat factor."); - frame.set ("heat_factor", PLF::empty ()); - frame.declare ("water_factor", "cm", Attribute::None (), Attribute::Const, - "Water potential factor."); - frame.set ("water_factor", PLF::empty ()); - } -} NitrificationSoil_syntax; - std::unique_ptr Nitrification::create_default () { @@ -139,4 +113,34 @@ Nitrification::create_default () return std::unique_ptr (new NitrificationSoil (frame)); } +void +register_nitrification_soil_models () +{ + static struct NitrificationSoilSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new NitrificationSoil (al); } + NitrificationSoilSyntax () + : DeclareModel (Nitrification::component, "soil", + "k_10 * M / (k + M). Michaelis-Menten kinetics,\n\ +with nitrification based on total ammonium content.") + { } + void load_frame (Frame& frame) const + { + frame.declare ("k", "g N/cm^3", Check::positive (), Attribute::Const, + "Half saturation constant."); + frame.set ("k", 5.0e-5); // [g N/cm^3] + frame.declare ("k_10", "g N/cm^3/h", Check::non_negative (), Attribute::Const, + "Max rate."); + frame.set ("k_10", 2.08333333333e-7); // 5e-6/24 [1/h] + frame.declare ("heat_factor", "dg C", Attribute::None (), Attribute::Const, + "Heat factor."); + frame.set ("heat_factor", PLF::empty ()); + frame.declare ("water_factor", "cm", Attribute::None (), Attribute::Const, + "Water potential factor."); + frame.set ("water_factor", PLF::empty ()); + } + } NitrificationSoil_syntax; +} + // nitrification_soil.C ends here. diff --git a/src/daisy/chemicals/nitrification_solute.C b/src/daisy/chemicals/nitrification_solute.C index d381148f7..881a0b804 100644 --- a/src/daisy/chemicals/nitrification_solute.C +++ b/src/daisy/chemicals/nitrification_solute.C @@ -85,29 +85,33 @@ NitrificationSolute::NitrificationSolute (const BlockModel& al) water_factor (al.plf ("water_factor")) { } -static struct NitrificationSoluteSyntax : public DeclareModel +void +register_nitrification_solute_models () { - Model* make (const BlockModel& al) const + static struct NitrificationSoluteSyntax : public DeclareModel { - return new NitrificationSolute (al); - } + Model* make (const BlockModel& al) const + { + return new NitrificationSolute (al); + } - NitrificationSoluteSyntax () - : DeclareModel (Nitrification::component, "solute", - "k_10 * C / (k + C). Michaelis-Menten kinetics,\n\ + NitrificationSoluteSyntax () + : DeclareModel (Nitrification::component, "solute", + "k_10 * C / (k + C). Michaelis-Menten kinetics,\n\ with nitrification based on ammonium solute.") - { } - void load_frame (Frame& frame) const - { - frame.declare ("k", "g/cm^3", Check::positive (), Attribute::Const, - "Half saturation constant."); - frame.declare ("k_10", "h^-1", Check::non_negative (), - Attribute::Const, "Max rate."); - frame.declare ("heat_factor", "dg C", Attribute::None (), Attribute::Const, - "Heat factor."); - frame.set ("heat_factor", PLF::empty ()); - frame.declare ("water_factor", "cm", Attribute::None (), Attribute::Const, - "Water potential factor."); - frame.set ("water_factor", PLF::empty ()); - } -} NitrificationSolute_syntax; + { } + void load_frame (Frame& frame) const + { + frame.declare ("k", "g/cm^3", Check::positive (), Attribute::Const, + "Half saturation constant."); + frame.declare ("k_10", "h^-1", Check::non_negative (), + Attribute::Const, "Max rate."); + frame.declare ("heat_factor", "dg C", Attribute::None (), Attribute::Const, + "Heat factor."); + frame.set ("heat_factor", PLF::empty ()); + frame.declare ("water_factor", "cm", Attribute::None (), Attribute::Const, + "Water potential factor."); + frame.set ("water_factor", PLF::empty ()); + } + } NitrificationSolute_syntax; +} diff --git a/src/daisy/chemicals/ponddamp.C b/src/daisy/chemicals/ponddamp.C index a5fb3ce25..4143dcb10 100644 --- a/src/daisy/chemicals/ponddamp.C +++ b/src/daisy/chemicals/ponddamp.C @@ -47,16 +47,6 @@ Ponddamp::Ponddamp () Ponddamp::~Ponddamp () { } -static struct PonddampInit : public DeclareComponent -{ - PonddampInit () - : DeclareComponent (Ponddamp::component, "\ -Dampening affect of ponding on soil erosion from rain.") - { } - void load_frame (Frame& frame) const - { Model::load_model (frame); } -} Ponddamp_init; - // The 'EUROSEM' model. struct PonddampEUROSEM : public Ponddamp @@ -75,25 +65,6 @@ struct PonddampEUROSEM : public Ponddamp { } }; -static struct PonddampEUROSEMSyntax : DeclareModel -{ - Model* make (const BlockModel& al) const - { return new PonddampEUROSEM (al); } - PonddampEUROSEMSyntax () - : DeclareModel (Ponddamp::component, "EUROSEM", "\ -KH = exp (-b h)") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "EUROSEM"); - frame.declare ("b", "mm^-1", Attribute::Const, "\ -Exponential degradation coefficient.\n\ -The range of 'b' is from 0.9 to 3.1, a default value of 2 is proposed\n\ -by the EUROSEM project."); - frame.set ("b", 2.0); - } -} PonddampEUROSEM_syntax; - // The 'Park82' model. struct PonddampPark82 : public Ponddamp @@ -113,20 +84,6 @@ struct PonddampPark82 : public Ponddamp { } }; -static struct PonddampPark82Syntax : DeclareModel -{ - Model* make (const BlockModel& al) const - { return new PonddampPark82 (al); } - PonddampPark82Syntax () - : DeclareModel (Ponddamp::component, "Park82", "\ -KH = 2.7183 * exp (-h / dds)") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "park82"); - } -} PonddampPark82_syntax; - // The 'Hairsine91' model. struct PonddampHairsine91 : public Ponddamp @@ -147,20 +104,6 @@ struct PonddampHairsine91 : public Ponddamp { } }; -static struct PonddampHairsine91Syntax : DeclareModel -{ - Model* make (const BlockModel& al) const - { return new PonddampHairsine91 (al); } - PonddampHairsine91Syntax () - : DeclareModel (Ponddamp::component, "Hairsine91", "\ -KH = (h / dds)^-0.8") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "hairsine91"); - } -} PonddampHairsine91_syntax; - // The 'none' model. struct PonddampNone : public Ponddamp @@ -176,16 +119,77 @@ struct PonddampNone : public Ponddamp { } }; -static struct PonddampNoneSyntax : DeclareModel +void +register_ponddamp_models () { - Model* make (const BlockModel& al) const - { return new PonddampNone (al); } - PonddampNoneSyntax () - : DeclareModel (Ponddamp::component, "none", "\ + static struct PonddampInit : public DeclareComponent + { + PonddampInit () + : DeclareComponent (Ponddamp::component, "\ +Dampening affect of ponding on soil erosion from rain.") + { } + void load_frame (Frame& frame) const + { Model::load_model (frame); } + } Ponddamp_init; + + static struct PonddampEUROSEMSyntax : DeclareModel + { + Model* make (const BlockModel& al) const + { return new PonddampEUROSEM (al); } + PonddampEUROSEMSyntax () + : DeclareModel (Ponddamp::component, "EUROSEM", "\ +KH = exp (-b h)") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "EUROSEM"); + frame.declare ("b", "mm^-1", Attribute::Const, "\ +Exponential degradation coefficient.\n\ +The range of 'b' is from 0.9 to 3.1, a default value of 2 is proposed\n\ +by the EUROSEM project."); + frame.set ("b", 2.0); + } + } PonddampEUROSEM_syntax; + + static struct PonddampPark82Syntax : DeclareModel + { + Model* make (const BlockModel& al) const + { return new PonddampPark82 (al); } + PonddampPark82Syntax () + : DeclareModel (Ponddamp::component, "Park82", "\ +KH = 2.7183 * exp (-h / dds)") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "park82"); + } + } PonddampPark82_syntax; + + static struct PonddampHairsine91Syntax : DeclareModel + { + Model* make (const BlockModel& al) const + { return new PonddampHairsine91 (al); } + PonddampHairsine91Syntax () + : DeclareModel (Ponddamp::component, "Hairsine91", "\ +KH = (h / dds)^-0.8") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "hairsine91"); + } + } PonddampHairsine91_syntax; + + static struct PonddampNoneSyntax : DeclareModel + { + Model* make (const BlockModel& al) const + { return new PonddampNone (al); } + PonddampNoneSyntax () + : DeclareModel (Ponddamp::component, "none", "\ KH = 1.0") - { } - void load_frame (Frame&) const - { } -} PonddampNone_syntax; + { } + void load_frame (Frame&) const + { } + } PonddampNone_syntax; +} // ponddamp.C ends here. diff --git a/src/daisy/chemicals/rainergy.C b/src/daisy/chemicals/rainergy.C index 172e732be..00fb2b443 100644 --- a/src/daisy/chemicals/rainergy.C +++ b/src/daisy/chemicals/rainergy.C @@ -43,16 +43,6 @@ Rainergy::Rainergy () Rainergy::~Rainergy () { } -static struct RainergyInit : public DeclareComponent -{ - RainergyInit () - : DeclareComponent (Rainergy::component, "\ -Energy in rain.") - { } - void load_frame (Frame& frame) const - { Model::load_model (frame); } -} Rainergy_init; - // The 'Brown87' model. struct RainergyBrown87 : public Rainergy @@ -76,21 +66,6 @@ struct RainergyBrown87 : public Rainergy { } }; -static struct RainergyBrown87Syntax : DeclareModel -{ - Model* make (const BlockModel& al) const - { return new RainergyBrown87 (al); } - RainergyBrown87Syntax () - : DeclareModel (Rainergy::component, "Brown87", "\ -Energy as a semi-empirical function of rain intensity.\n\ -The energy content in the fraction that hits the canopy is ignored.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "brown87"); - } -} RainergyBrown87_syntax; - // The 'EUROSEM' model. struct RainergyEUROSEM : public Rainergy @@ -127,16 +102,45 @@ struct RainergyEUROSEM : public Rainergy { } }; -static struct RainergyEUROSEMSyntax : DeclareModel +void +register_rainergy_models () { - Model* make (const BlockModel& al) const - { return new RainergyEUROSEM (al); } - RainergyEUROSEMSyntax () - : DeclareModel (Rainergy::component, "EUROSEM", "\ + static struct RainergyInit : public DeclareComponent + { + RainergyInit () + : DeclareComponent (Rainergy::component, "\ +Energy in rain.") + { } + void load_frame (Frame& frame) const + { Model::load_model (frame); } + } Rainergy_init; + + static struct RainergyBrown87Syntax : DeclareModel + { + Model* make (const BlockModel& al) const + { return new RainergyBrown87 (al); } + RainergyBrown87Syntax () + : DeclareModel (Rainergy::component, "Brown87", "\ +Energy as a semi-empirical function of rain intensity.\n\ +The energy content in the fraction that hits the canopy is ignored.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "brown87"); + } + } RainergyBrown87_syntax; + + static struct RainergyEUROSEMSyntax : DeclareModel + { + Model* make (const BlockModel& al) const + { return new RainergyEUROSEM (al); } + RainergyEUROSEMSyntax () + : DeclareModel (Rainergy::component, "EUROSEM", "\ Kinetic energy model taking vegetation into account.") - { } - void load_frame (Frame& frame) const - { frame.set_strings ("cite", "EUROSEM"); } -} RainergyEUROSEM_syntax; + { } + void load_frame (Frame& frame) const + { frame.set_strings ("cite", "EUROSEM"); } + } RainergyEUROSEM_syntax; +} // rainergy.C ends here. diff --git a/src/daisy/chemicals/reaction.C b/src/daisy/chemicals/reaction.C index 1c968dbc5..2422bbde9 100644 --- a/src/daisy/chemicals/reaction.C +++ b/src/daisy/chemicals/reaction.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/chemicals/reaction.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" @@ -63,14 +64,34 @@ Reaction::Reaction (const BlockModel& al) Reaction::~Reaction () { } -static struct ReactionInit : public DeclareComponent +void +register_reaction_models () { - ReactionInit () - : DeclareComponent (Reaction::component, "\ + static struct ReactionInit : public DeclareComponent + { + ReactionInit () + : DeclareComponent (Reaction::component, "\ Generic transformations between soil chemicals.") - { } - void load_frame (Frame& frame) const - { Model::load_model (frame); } -} Reaction_init; + { } + void load_frame (Frame& frame) const + { Model::load_model (frame); } + } Reaction_init; + + register_reaction_colgen_models (); + register_reaction_std_models (); + register_reaction_adsorption_models (); + register_reaction_boundrel_models (); + register_reaction_denit_models (); + register_reaction_dom_models (); + register_reaction_equil_models (); + register_reaction_filter_models (); + register_reaction_jarvis99_models (); + register_reaction_morgan98_models (); + register_reaction_nit_models (); + register_reaction_python_models (); + register_reaction_shoot_models (); + register_reaction_sorption_models (); + register_reaction_styczen88_models (); +} // reaction.C ends here. diff --git a/src/daisy/chemicals/reaction_Jarvis99.C b/src/daisy/chemicals/reaction_Jarvis99.C index 1df6516db..499b719bd 100644 --- a/src/daisy/chemicals/reaction_Jarvis99.C +++ b/src/daisy/chemicals/reaction_Jarvis99.C @@ -174,7 +174,6 @@ ReactionJarvis99::output (Log& log) const output_variable (E, log); } - void ReactionJarvis99::initialize (const Geometry& geo, const Soil& soil, const SoilWater&, @@ -256,57 +255,61 @@ ReactionJarvis99::ReactionJarvis99 (const BlockModel& al) E (0.0) { } -static struct ReactionJarvis99Syntax : public DeclareModel +void +register_reaction_jarvis99_models () { - Model* make (const BlockModel& al) const - { return new ReactionJarvis99 (al); } - ReactionJarvis99Syntax () - : DeclareModel (Reaction::component, "colgen_Jarvis99", "colgen", "\ -Colloid generation emulating the MACRO model.") - { } - void load_frame (Frame& frame) const + static struct ReactionJarvis99Syntax : public DeclareModel { - frame.set ("ponddamp", "none"); - frame.set_strings ("cite", "macro-colloid", "mmax"); - frame.declare_object ("rainergy", Rainergy::component, - Attribute::Const, Attribute::Singleton, - "Model for calculating energy in rain."); - frame.set ("rainergy", "Brown87"); - frame.declare_boolean ("tillage_replenish_all", Attribute::Const, "\ + Model* make (const BlockModel& al) const + { return new ReactionJarvis99 (al); } + ReactionJarvis99Syntax () + : DeclareModel (Reaction::component, "colgen_Jarvis99", "colgen", "\ +Colloid generation emulating the MACRO model.") + { } + void load_frame (Frame& frame) const + { + frame.set ("ponddamp", "none"); + frame.set_strings ("cite", "macro-colloid", "mmax"); + frame.declare_object ("rainergy", Rainergy::component, + Attribute::Const, Attribute::Singleton, + "Model for calculating energy in rain."); + frame.set ("rainergy", "Brown87"); + frame.declare_boolean ("tillage_replenish_all", Attribute::Const, "\ Set Ms = Mmax after tillage."); - frame.set ("tillage_replenish_all", false); - frame.declare ("Mmax", "g/g", Check::non_negative (), - Attribute::OptionalConst, "\ + frame.set ("tillage_replenish_all", false); + frame.declare ("Mmax", "g/g", Check::non_negative (), + Attribute::OptionalConst, "\ Maximum amount of detachable particles.\n\ By default, method 1 of Brubaker et al, 1992, will be used."); - // frame.set ("Mmax", 0.165); - frame.declare ("Mmax_tillage_factor", "d", Attribute::None (), - Check::non_negative (), Attribute::Const, "\ + // frame.set ("Mmax", 0.165); + frame.declare ("Mmax_tillage_factor", "d", Attribute::None (), + Check::non_negative (), Attribute::Const, "\ Factor to modify Mmax with as a fuction of days after tillage."); - frame.set ("Mmax_tillage_factor", PLF::always_1 ()); + frame.set ("Mmax_tillage_factor", PLF::always_1 ()); - frame.declare ("kd", "g/J", Check::non_negative (), Attribute::Const, - "Detachment rate coefficient."); - // frame.set ("kd", 15.0); - frame.declare ("kr", "g/cm^2/h", Check::non_negative (), Attribute::Const, - "Replenishment rate coefficient."); - // frame.declare ("kr", 0.1 /* [g/m^2/h] */ / (100.0 /* [cm/m] */ * 100.0)); - frame.declare ("zi", "cm", Check::positive (), Attribute::OptionalConst, - "Thickness of surface soil layer.\n\ + frame.declare ("kd", "g/J", Check::non_negative (), Attribute::Const, + "Detachment rate coefficient."); + // frame.set ("kd", 15.0); + frame.declare ("kr", "g/cm^2/h", Check::non_negative (), Attribute::Const, + "Replenishment rate coefficient."); + // frame.declare ("kr", 0.1 /* [g/m^2/h] */ / (100.0 /* [cm/m] */ * 100.0)); + frame.declare ("zi", "cm", Check::positive (), Attribute::OptionalConst, + "Thickness of surface soil layer.\n\ By default, the value of 'z_mixing' from 'Surface' is used."); - // frame.set ("zi", 0.1); - frame.declare ("Ms", "g/g", Check::non_negative (), Attribute::OptionalState, - "Current concentration of detachable particles in top soil.\n\ + // frame.set ("zi", 0.1); + frame.declare ("Ms", "g/g", Check::non_negative (), Attribute::OptionalState, + "Current concentration of detachable particles in top soil.\n\ By default, 10% of Mmax."); - frame.declare ("As", "g/cm^2", Attribute::LogOnly, - "Current amount of detachable particles in top soil."); - frame.declare ("P", "g/cm^2/h", Attribute::LogOnly, - "Replenishment of detachable particles to top soil."); - frame.declare ("KE", "J/cm^2/h", Attribute::LogOnly, - "Kinertic energy avalable for colloid generation."); - frame.declare ("E", "J/cm^2/mm", Attribute::LogOnly, - "Kinetic energy in rain."); - } -} ReactionJarvis99syntax; + frame.declare ("As", "g/cm^2", Attribute::LogOnly, + "Current amount of detachable particles in top soil."); + frame.declare ("P", "g/cm^2/h", Attribute::LogOnly, + "Replenishment of detachable particles to top soil."); + frame.declare ("KE", "J/cm^2/h", Attribute::LogOnly, + "Kinertic energy avalable for colloid generation."); + frame.declare ("E", "J/cm^2/mm", Attribute::LogOnly, + "Kinetic energy in rain."); + } + } ReactionJarvis99syntax; +} // reaction_Jarvis99.C ends here. diff --git a/src/daisy/chemicals/reaction_Morgan98.C b/src/daisy/chemicals/reaction_Morgan98.C index 7e809bfc8..b7970d066 100644 --- a/src/daisy/chemicals/reaction_Morgan98.C +++ b/src/daisy/chemicals/reaction_Morgan98.C @@ -126,7 +126,6 @@ ReactionMorgan98::output (Log& log) const output_variable (E, log); } - void ReactionMorgan98::initialize (const Geometry& geo, const Soil& soil, @@ -143,32 +142,36 @@ ReactionMorgan98::ReactionMorgan98 (const BlockModel& al) E (-42.42e42) { } -static struct ReactionMorgan98Syntax : public DeclareModel +void +register_reaction_morgan98_models () { - Model* make (const BlockModel& al) const - { return new ReactionMorgan98 (al); } - ReactionMorgan98Syntax () - : DeclareModel (Reaction::component, "colgen_Morgan98", "colgen", "\ -Colloid generation using kinetic energy, emulating EUROSEM.") - { } - void load_frame (Frame& frame) const + static struct ReactionMorgan98Syntax : public DeclareModel { - frame.set_strings ("cite", "EUROSEM"); + Model* make (const BlockModel& al) const + { return new ReactionMorgan98 (al); } + ReactionMorgan98Syntax () + : DeclareModel (Reaction::component, "colgen_Morgan98", "colgen", "\ +Colloid generation using kinetic energy, emulating EUROSEM.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "EUROSEM"); - frame.declare ("kd", "g/J", Check::non_negative (), Attribute::Const, - "Detachment rate coefficient.\n\ + frame.declare ("kd", "g/J", Check::non_negative (), Attribute::Const, + "Detachment rate coefficient.\n\ The EUROSEM user manual list values between 0.8 and 6.0 [g/J] for various\n\ soils in Table A9.1."); - frame.declare_object ("rainergy", Rainergy::component, - Attribute::Const, Attribute::Singleton, - "Model for calculating energy in rain."); - frame.set ("rainergy", "EUROSEM"); - - frame.declare ("KE", "J/cm^2/h", Attribute::LogOnly, - "Kinertic energy avalable for colloid generation."); - frame.declare ("E", "J/cm^2/mm", Attribute::LogOnly, - "Kinetic energy in rain."); - } -} ReactionMorgan98syntax; + frame.declare_object ("rainergy", Rainergy::component, + Attribute::Const, Attribute::Singleton, + "Model for calculating energy in rain."); + frame.set ("rainergy", "EUROSEM"); + + frame.declare ("KE", "J/cm^2/h", Attribute::LogOnly, + "Kinertic energy avalable for colloid generation."); + frame.declare ("E", "J/cm^2/mm", Attribute::LogOnly, + "Kinetic energy in rain."); + } + } ReactionMorgan98syntax; +} // reaction_Morgan98.C ends here. diff --git a/src/daisy/chemicals/reaction_Python.C b/src/daisy/chemicals/reaction_Python.C index f9689e525..6dbd9d542 100644 --- a/src/daisy/chemicals/reaction_Python.C +++ b/src/daisy/chemicals/reaction_Python.C @@ -414,68 +414,71 @@ struct ReactionPython : public Reaction { } }; -static struct ReactionPythonSyntax : public DeclareModel +void +register_reaction_python_models () { - Model* make (const BlockModel& al) const - { return new ReactionPython (al); } - ReactionPythonSyntax () - : DeclareModel (Reaction::component, "Python", "\ -Python interface for chemical reactions above and below ground.") - { } - static void load_in (Frame& frame) + static struct ReactionPythonSyntax : public DeclareModel { - frame.declare_string ("chemical", Attribute::Const, "\ + Model* make (const BlockModel& al) const + { return new ReactionPython (al); } + ReactionPythonSyntax () + : DeclareModel (Reaction::component, "Python", "\ +Python interface for chemical reactions above and below ground.") + { } + static void load_in (Frame& frame) + { + frame.declare_string ("chemical", Attribute::Const, "\ Name of chemical."); - static const VCheck::InLibrary is_chemical (Chemical::component); - frame.set_check ("chemical", is_chemical); - frame.declare_string ("handle", Attribute::OptionalConst, "\ + static const VCheck::InLibrary is_chemical (Chemical::component); + frame.set_check ("chemical", is_chemical); + frame.declare_string ("handle", Attribute::OptionalConst, "\ How to access it.\n\ One of 'C_primary', 'C_secondary', 'C_average',\n\ 'M_primary', 'M_secondary', or 'M_total'."); - static const VCheck::Enum is_handle - ("C_primary", "C_secondary", "C_average", - "M_primary", "M_secondary", "M_total"); - frame.set_check ("handle", is_handle); - frame.declare_string ("tag", Attribute::OptionalConst, "\ + static const VCheck::Enum is_handle + ("C_primary", "C_secondary", "C_average", + "M_primary", "M_secondary", "M_total"); + frame.set_check ("handle", is_handle); + frame.declare_string ("tag", Attribute::OptionalConst, "\ Nmae to use as a Python parameter."); - frame.order ("chemical", "handle", "tag"); - } + frame.order ("chemical", "handle", "tag"); + } - static void load_texture (Frame& frame) - { - frame.declare_string ("tag", Attribute::Const, "\ + static void load_texture (Frame& frame) + { + frame.declare_string ("tag", Attribute::Const, "\ Name of Python parameter."); - frame.declare ("size", "um", Attribute::Const, "\ + frame.declare ("size", "um", Attribute::Const, "\ Include particles below this size."); - frame.order ("tag", "size"); - } + frame.order ("tag", "size"); + } - static void load_out (Frame& frame) - { - frame.declare_string ("chemical", Attribute::Const, "\ + static void load_out (Frame& frame) + { + frame.declare_string ("chemical", Attribute::Const, "\ Name of chemical."); - frame.declare_string ("handle", Attribute::OptionalConst, "\ + frame.declare_string ("handle", Attribute::OptionalConst, "\ Where to add it.\n\ One of 'primary', 'secondary'."); - static const VCheck::Enum is_handle ("primary", "secondary", "none"); - frame.set_check ("handle", is_handle); - frame.declare_string ("tag", Attribute::OptionalConst, "\ + static const VCheck::Enum is_handle ("primary", "secondary", "none"); + frame.set_check ("handle", is_handle); + frame.declare_string ("tag", Attribute::OptionalConst, "\ Name to use both for logging and as Python output."); - frame.order ("chemical", "handle", "tag"); - } + frame.order ("chemical", "handle", "tag"); + } - void load_frame (Frame& frame) const - { - frame.declare_string ("module", Attribute::Const, "\ + void load_frame (Frame& frame) const + { + frame.declare_string ("module", Attribute::Const, "\ Python module to find the functions."); - frame.declare_string ("soil", Attribute::OptionalConst, "\ + frame.declare_string ("soil", Attribute::OptionalConst, "\ Name of Python function for soil reactions."); - frame.declare_submodule_sequence ("in", Attribute::Const, "\ + frame.declare_submodule_sequence ("in", Attribute::Const, "\ List of solutes to pass to Python as input.", load_in); - frame.declare_submodule_sequence ("texture", Attribute::Const, "\ + frame.declare_submodule_sequence ("texture", Attribute::Const, "\ List of texture classes to pass to Python.", load_texture); - frame.declare_string ("extra", - Attribute::Const, Attribute::Variable, "\ + frame.declare_string ("extra", + Attribute::Const, Attribute::Variable, "\ Extra input parameters to Python soil function.\n\ \n\ Options include:\n\ @@ -493,31 +496,32 @@ Options include:\n\ SMB_C [g C/cm^3 V]: Fast pool SMB carbon per system volume.\n\ ORG_C [g C/cm^3 V]: Stationary carbon per system volume.\n\ "); - static struct ExtraCheck : public VCheck::Enum - { - ExtraCheck () - : VCheck::Enum () + static struct ExtraCheck : public VCheck::Enum { - add ("z"); - add ("rho_b"); - add ("Theta_sat"); - add ("Theta"); - add ("Theta_primary"); - add ("Theta_secondary"); - add ("h"); - add ("T"); - add ("CO2_C"); - add ("CO2_C_fast"); - add ("SMB_C"); - add ("ORG_C"); - } - } extra_check; - frame.set_check ("extra", extra_check); - frame.declare_submodule_sequence ("out", Attribute::Const, "\ + ExtraCheck () + : VCheck::Enum () + { + add ("z"); + add ("rho_b"); + add ("Theta_sat"); + add ("Theta"); + add ("Theta_primary"); + add ("Theta_secondary"); + add ("h"); + add ("T"); + add ("CO2_C"); + add ("CO2_C_fast"); + add ("SMB_C"); + add ("ORG_C"); + } + } extra_check; + frame.set_check ("extra", extra_check); + frame.declare_submodule_sequence ("out", Attribute::Const, "\ List of Python as output.", load_out); - frame.declare_string ("top", Attribute::OptionalConst, "\ + frame.declare_string ("top", Attribute::OptionalConst, "\ Name of Python function for above ground reactions."); - } -} ReactionPython_syntax; + } + } ReactionPython_syntax; +} // reaction_Python.C ends here. diff --git a/src/daisy/chemicals/reaction_Styczen88.C b/src/daisy/chemicals/reaction_Styczen88.C index 4bbe145d5..268df7c73 100644 --- a/src/daisy/chemicals/reaction_Styczen88.C +++ b/src/daisy/chemicals/reaction_Styczen88.C @@ -265,7 +265,6 @@ ReactionStyczen88::output (Log& log) const output_variable (MR, log); } - void ReactionStyczen88::initialize (const Geometry& geo, const Soil& soil, @@ -285,32 +284,36 @@ ReactionStyczen88::ReactionStyczen88 (const BlockModel& al) MR (-42.42e42) { } -static struct ReactionStyczen88Syntax : public DeclareModel +void +register_reaction_styczen88_models () { - Model* make (const BlockModel& al) const - { return new ReactionStyczen88 (al); } - ReactionStyczen88Syntax () - : DeclareModel (Reaction::component, "colgen_Styczen88", "colgen", "\ -Colloid generation using rainfall momentum.") - { } - void load_frame (Frame& frame) const + static struct ReactionStyczen88Syntax : public DeclareModel { - frame.set_strings ("cite", "styczen88"); + Model* make (const BlockModel& al) const + { return new ReactionStyczen88 (al); } + ReactionStyczen88Syntax () + : DeclareModel (Reaction::component, "colgen_Styczen88", "colgen", "\ +Colloid generation using rainfall momentum.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "styczen88"); - frame.declare ("Ae", "h^2/g/cm^2", Check::positive (), Attribute::Const, - "Soil resistance factor."); - frame.declare ("MA", Attribute::Fraction (), Attribute::OptionalConst, - "Protective cover (mulch factor).\n\ + frame.declare ("Ae", "h^2/g/cm^2", Check::positive (), Attribute::Const, + "Soil resistance factor."); + frame.declare ("MA", Attribute::Fraction (), Attribute::OptionalConst, + "Protective cover (mulch factor).\n\ By default, use the cover predicted by the litter model."); - frame.declare ("droplet_diameter", "mm", Check::positive (), Attribute::Const, - "Size of droplets from vegetation."); - frame.declare ("DH", "kg^2/m/s^2", Attribute::LogOnly, - "Squared vegetation droplet momentum."); - frame.declare ("CM", Attribute::Fraction (), Attribute::LogOnly, - "Vegetation factor."); - frame.declare ("MR", "(N s)^2/m^2/s", Attribute::LogOnly, - "Squared direct rainfall momentum."); - } -} ReactionStyczen88syntax; + frame.declare ("droplet_diameter", "mm", Check::positive (), Attribute::Const, + "Size of droplets from vegetation."); + frame.declare ("DH", "kg^2/m/s^2", Attribute::LogOnly, + "Squared vegetation droplet momentum."); + frame.declare ("CM", Attribute::Fraction (), Attribute::LogOnly, + "Vegetation factor."); + frame.declare ("MR", "(N s)^2/m^2/s", Attribute::LogOnly, + "Squared direct rainfall momentum."); + } + } ReactionStyczen88syntax; +} // reaction_Styczen88.C ends here. diff --git a/src/daisy/chemicals/reaction_adsorption.C b/src/daisy/chemicals/reaction_adsorption.C index a0eb64a38..5d924ff8e 100644 --- a/src/daisy/chemicals/reaction_adsorption.C +++ b/src/daisy/chemicals/reaction_adsorption.C @@ -170,35 +170,39 @@ struct ReactionAdsorption : public Reaction { } }; -static struct ReactionAdsorptionSyntax : public DeclareModel +void +register_reaction_adsorption_models () { - Model* make (const BlockModel& al) const - { return new ReactionAdsorption (al); } - - ReactionAdsorptionSyntax () - : DeclareModel (Reaction::component, "adsorption", - "Maintain equilibrium between solute and sorbed from.") - { } - void load_frame (Frame& frame) const + static struct ReactionAdsorptionSyntax : public DeclareModel { - frame.declare_string ("solute", Attribute::Const, - "Name of solute form of chemical."); - frame.declare_string ("sorbed", Attribute::Const, - "Name of sorbed form of chemical."); - frame.declare_object ("equilibrium", Adsorption::component, "\ + Model* make (const BlockModel& al) const + { return new ReactionAdsorption (al); } + + ReactionAdsorptionSyntax () + : DeclareModel (Reaction::component, "adsorption", + "Maintain equilibrium between solute and sorbed from.") + { } + void load_frame (Frame& frame) const + { + frame.declare_string ("solute", Attribute::Const, + "Name of solute form of chemical."); + frame.declare_string ("sorbed", Attribute::Const, + "Name of sorbed form of chemical."); + frame.declare_object ("equilibrium", Adsorption::component, "\ Function for calculating equilibrium between solute and sorbed form."); - frame.declare_object ("adsorption_rate", Number::component, - Attribute::Const, Attribute::Singleton, - "Tranformation rate from solute to sorbed form."); - frame.declare_object ("desorption_rate", Number::component, - Attribute::OptionalConst, Attribute::Singleton, - "Tranformation rate from sorbed to solute form.\n\ + frame.declare_object ("adsorption_rate", Number::component, + Attribute::Const, Attribute::Singleton, + "Tranformation rate from solute to sorbed form."); + frame.declare_object ("desorption_rate", Number::component, + Attribute::OptionalConst, Attribute::Singleton, + "Tranformation rate from sorbed to solute form.\n\ By default, this is identical to 'adsorption_rate'."); - frame.declare ("adsorption_source", "g/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, "\ + frame.declare ("adsorption_source", "g/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, "\ Converted from solute to sorbed form this timestep (may be negative)."); - } -} ReactionAdsorption_syntax; + } + } ReactionAdsorption_syntax; +} // reaction_adsorption.C ends here. diff --git a/src/daisy/chemicals/reaction_boundrel.C b/src/daisy/chemicals/reaction_boundrel.C index 41877ed05..5250d61ad 100644 --- a/src/daisy/chemicals/reaction_boundrel.C +++ b/src/daisy/chemicals/reaction_boundrel.C @@ -69,7 +69,6 @@ struct ReactionBoundrel : public Reaction chemistry.find (bound).add_to_surface_transform_source (release); } - // Create. bool check (const Geometry&, const Soil&, const SoilWater&, const SoilHeat&, @@ -107,12 +106,15 @@ struct ReactionBoundrel : public Reaction { } }; -static struct ReactionBoundrelSyntax : public DeclareModel +void +register_reaction_boundrel_models () { - Model* make (const BlockModel& al) const - { return new ReactionBoundrel (al); } - ReactionBoundrelSyntax () - : DeclareModel (Reaction::component, "bound_release", "\ + static struct ReactionBoundrelSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new ReactionBoundrel (al); } + ReactionBoundrelSyntax () + : DeclareModel (Reaction::component, "bound_release", "\ Release of chemicals bound to colloids from surface soil.\n\ \n\ This follows the generation of colloids on the surface. The colloid\n\ @@ -124,25 +126,24 @@ chemical on the surface is released in the colloid bound form.\n\ \n\ This reaction must be listed after the colloid generation reaction in\n\ the setup file.") - { } - void load_frame (Frame& frame) const - { + { } + void load_frame (Frame& frame) const + { - frame.declare_string ("immobile", Attribute::Const, - "Immobile (or mixed form) chemical in the soil surface."); - frame.declare_string ("bound", Attribute::OptionalConst, - "Chemical bound to colloids.\n\ + frame.declare_string ("immobile", Attribute::Const, + "Immobile (or mixed form) chemical in the soil surface."); + frame.declare_string ("bound", Attribute::OptionalConst, + "Chemical bound to colloids.\n\ If unspecified, the colloid bound form will not be traced."); - frame.declare_string ("colloid", Attribute::OptionalConst, - "Name of colloid whose release we mimic."); - frame.set ("colloid", "colloid"); - frame.declare ("release", "g/cm^2/h", Attribute::LogOnly, - "Release rate of immobile chemical as colloids."); - } - -} ReactionBoundrel_syntax; + frame.declare_string ("colloid", Attribute::OptionalConst, + "Name of colloid whose release we mimic."); + frame.set ("colloid", "colloid"); + frame.declare ("release", "g/cm^2/h", Attribute::LogOnly, + "Release rate of immobile chemical as colloids."); + } + + } ReactionBoundrel_syntax; +} // reaction_boundrel.C ends here. - - diff --git a/src/daisy/chemicals/reaction_colgen.C b/src/daisy/chemicals/reaction_colgen.C index 790368f44..64218e2a0 100644 --- a/src/daisy/chemicals/reaction_colgen.C +++ b/src/daisy/chemicals/reaction_colgen.C @@ -88,26 +88,30 @@ ReactionColgen::ReactionColgen (const BlockModel& al) ReactionColgen::~ReactionColgen () { } -static struct ReactionColgenSyntax : public DeclareBase +void +register_reaction_colgen_models () { - ReactionColgenSyntax () - : DeclareBase (Reaction::component, "colgen", "\ -Shared parameter and log variable for colloid generation models.") - { } - void load_frame (Frame& frame) const + static struct ReactionColgenSyntax : public DeclareBase { - frame.declare_string ("colloid", Attribute::Const, "Colloid to generate."); - frame.declare_object ("ponddamp", Ponddamp::component, - Attribute::Const, Attribute::Singleton, - "Model for calculating 'KH'."); - frame.declare ("dds", "mm", Attribute::LogOnly, "Median raindrop size."); - frame.declare ("KH", Attribute::Fraction (), Attribute::LogOnly, - "Ponding factor."); - frame.declare ("D", "g/cm^2/h", Attribute::LogOnly, - "Depletion of detachable particles from top soil."); - frame.declare ("surface_release", Attribute::Fraction (), Attribute::LogOnly, "\ + ReactionColgenSyntax () + : DeclareBase (Reaction::component, "colgen", "\ +Shared parameter and log variable for colloid generation models.") + { } + void load_frame (Frame& frame) const + { + frame.declare_string ("colloid", Attribute::Const, "Colloid to generate."); + frame.declare_object ("ponddamp", Ponddamp::component, + Attribute::Const, Attribute::Singleton, + "Model for calculating 'KH'."); + frame.declare ("dds", "mm", Attribute::LogOnly, "Median raindrop size."); + frame.declare ("KH", Attribute::Fraction (), Attribute::LogOnly, + "Ponding factor."); + frame.declare ("D", "g/cm^2/h", Attribute::LogOnly, + "Depletion of detachable particles from top soil."); + frame.declare ("surface_release", Attribute::Fraction (), Attribute::LogOnly, "\ Fraction of available soil particles released as colloids this timestep."); - } -} ReactionColgen_syntax; + } + } ReactionColgen_syntax; +} // reaction_colgen.C ends here. diff --git a/src/daisy/chemicals/reaction_denit.C b/src/daisy/chemicals/reaction_denit.C index 1dfa86c68..95255f04b 100644 --- a/src/daisy/chemicals/reaction_denit.C +++ b/src/daisy/chemicals/reaction_denit.C @@ -204,12 +204,15 @@ ReactionDenit::ReactionDenit (const BlockModel& al) denprod (Librarian::build_item (al, "denprod")) { } -static struct ReactionDenitSyntax : public DeclareModel +void +register_reaction_denit_models () { - Model* make (const BlockModel& al) const - { return new ReactionDenit (al); } - ReactionDenitSyntax () - : DeclareModel (Reaction::component, "denitrification", "\ + static struct ReactionDenitSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new ReactionDenit (al); } + ReactionDenitSyntax () + : DeclareModel (Reaction::component, "denitrification", "\ Denitrification in soil, (conversion of nitrate to atmospheric nitrogen).\n\ \n\ In this model, it is made proportional to the CO2 development, as\n\ @@ -219,70 +222,71 @@ and water pressure. Additional denitrification from CO2 produced from\n\ fast OM pools can be triggered by setting alpha_fast or\n\ water_factor_fast different. This additional denitrification is\n\ limited by K_fast.") - { } - void load_frame (Frame& frame) const - { - frame.declare_object ("denprod", Denprod::component, - "Denitrification products."); - frame.set ("denprod", "Parton1996"); - frame.declare ("converted", "g/cm^3/h", - Attribute::LogOnly, Attribute::Variable, - "Amount of denitrification."); - frame.declare ("converted_fast", "g/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, - "Additional denitrification due to turnover in fast pools."); - frame.declare ("converted_redox", "g/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, "\ + { } + void load_frame (Frame& frame) const + { + frame.declare_object ("denprod", Denprod::component, + "Denitrification products."); + frame.set ("denprod", "Parton1996"); + frame.declare ("converted", "g/cm^3/h", + Attribute::LogOnly, Attribute::Variable, + "Amount of denitrification."); + frame.declare ("converted_fast", "g/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, + "Additional denitrification due to turnover in fast pools."); + frame.declare ("converted_redox", "g/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, "\ Additional denitrification due to chemical redox processes."); - frame.declare ("potential", "g/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, "\ + frame.declare ("potential", "g/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, "\ Potential amount of denitrification at anarobic conditions."); - frame.declare ("potential_fast", "g/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, - "Additional potential due to turnover in fast pools."); - frame.declare ("K", "h^-1", Check::fraction (), Attribute::Const, "\ + frame.declare ("potential_fast", "g/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, + "Additional potential due to turnover in fast pools."); + frame.declare ("K", "h^-1", Check::fraction (), Attribute::Const, "\ Maximum fraction of nitrate converted at each time step from slow pools."); - frame.set ("K", 0.020833); - frame.declare ("K_fast", "h^-1", Check::fraction (), - Attribute::OptionalConst, "\ + frame.set ("K", 0.020833); + frame.declare ("K_fast", "h^-1", Check::fraction (), + Attribute::OptionalConst, "\ Maximum fraction of nitrate converted at each time step from fast pools.\n \ By default this is identical to 'K'."); - frame.declare ("alpha", "(g NO3-N/h)/(g CO2-C/h)", Check::non_negative (), - Attribute::Const, "\ + frame.declare ("alpha", "(g NO3-N/h)/(g CO2-C/h)", Check::non_negative (), + Attribute::Const, "\ Anaerobic denitrification constant for slow pools."); - frame.set ("alpha", 0.1); - frame.declare ("alpha_fast", - "(g NO3-N/h)/(g CO2-C/h)", Check::non_negative (), - Attribute::OptionalConst, "\ + frame.set ("alpha", 0.1); + frame.declare ("alpha_fast", + "(g NO3-N/h)/(g CO2-C/h)", Check::non_negative (), + Attribute::OptionalConst, "\ Anaerobic denitrification constant for fast pools.\n \ This applies to the CO2 produced from turnover of fast OM pools.\n\ By default, this is identical to alpha."); - frame.declare ("heat_factor", "dg C", Attribute::None (), - Check::non_negative (), - Attribute::OptionalConst, "Heat factor.\n\ + frame.declare ("heat_factor", "dg C", Attribute::None (), + Check::non_negative (), + Attribute::OptionalConst, "Heat factor.\n\ By default, use a build in function valid for temperate climates."); - frame.declare ("water_factor", Attribute::Fraction (), Attribute::None (), - Check::non_negative (), - Attribute::OptionalConst, - "Water potential factor for slow pools.\n\ + frame.declare ("water_factor", Attribute::Fraction (), Attribute::None (), + Check::non_negative (), + Attribute::OptionalConst, + "Water potential factor for slow pools.\n\ This is a function of the current water content as a fraction of the\n\ maximal water content."); - PLF water_factor; - water_factor.add (0.7, 0.0); - water_factor.add (1.0, 1.0); - frame.set ("water_factor", water_factor); - frame.declare ("water_factor_fast", - Attribute::Fraction (), Attribute::None (), - Check::non_negative (), - Attribute::OptionalConst, - "Water potential factor for fast pools\n\ + PLF water_factor; + water_factor.add (0.7, 0.0); + water_factor.add (1.0, 1.0); + frame.set ("water_factor", water_factor); + frame.declare ("water_factor_fast", + Attribute::Fraction (), Attribute::None (), + Check::non_negative (), + Attribute::OptionalConst, + "Water potential factor for fast pools\n\ By default, this is identical to the 'water_factor' parameter."); - frame.declare ("redox_height", "cm", Check::non_positive (), - Attribute::OptionalConst, "\ + frame.declare ("redox_height", "cm", Check::non_positive (), + Attribute::OptionalConst, "\ Height (a negative number) blow which redox processes start.\n \ All NO3 below this height will be denitrified immediately.\n\ By default no redox denitrification occurs."); - } -} ReactionDenit_syntax; + } + } ReactionDenit_syntax; +} // reaction_denit.C ends here. diff --git a/src/daisy/chemicals/reaction_dom.C b/src/daisy/chemicals/reaction_dom.C index 256e01a76..3acc95b27 100644 --- a/src/daisy/chemicals/reaction_dom.C +++ b/src/daisy/chemicals/reaction_dom.C @@ -289,74 +289,78 @@ ReactionDOM::ReactionDOM (const BlockModel& al) C_per_N_goal (al.number ("C_per_N_goal")) { } -static struct ReactionDOMSyntax : public DeclareModel +void +register_reaction_dom_models () { - Model* make (const BlockModel& al) const - { return new ReactionDOM (al); } - ReactionDOMSyntax () - : DeclareModel (Reaction::component, "DOM_turnover", "\ -Turnover of dissolved organic matter.") - { } - void load_frame (Frame& frame) const + static struct ReactionDOMSyntax : public DeclareModel { - frame.set_strings ("cite", "garnier2003modelling"); - frame.declare_string ("DOC_name", Attribute::Const, "\ + Model* make (const BlockModel& al) const + { return new ReactionDOM (al); } + ReactionDOMSyntax () + : DeclareModel (Reaction::component, "DOM_turnover", "\ +Turnover of dissolved organic matter.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "garnier2003modelling"); + frame.declare_string ("DOC_name", Attribute::Const, "\ Name of compound representing dissolved organic carbon."); - frame.set ("DOC_name", Chemical::DOC ()); - frame.declare_string ("DON_name", Attribute::Const, "\ + frame.set ("DOC_name", Chemical::DOC ()); + frame.declare_string ("DON_name", Attribute::Const, "\ Name of compound representing dissolved organic nitrogen."); - frame.set ("DON_name", Chemical::DON ()); - Rate::declare (frame, "turnover", "Turnover of DOM.\n\ + frame.set ("DON_name", Chemical::DON ()); + Rate::declare (frame, "turnover", "Turnover of DOM.\n\ Garnier et al. (2003) table 1 (T=15 degC) 1.49*10/15) = 0.99 [d^-1]"); - Rate::set_rate (frame, "turnover", 0.04125 /* [h^-1] */); - Rate::declare (frame, "max_N_depletion", "Max depeletion of N."); - Rate::set_rate (frame, "max_N_depletion", 0.1 /* [h^-1] */); - frame.declare_integer ("where", Attribute::Const, "\ + Rate::set_rate (frame, "turnover", 0.04125 /* [h^-1] */); + Rate::declare (frame, "max_N_depletion", "Max depeletion of N."); + Rate::set_rate (frame, "max_N_depletion", 0.1 /* [h^-1] */); + frame.declare_integer ("where", Attribute::Const, "\ Target for DOM turnover.\n\ Should be a number between 0 and the number of SMB pools.\n\ 0 means the SMB1, 1 means SMB2.\n\ If there are 2 SMB pools, 2 will mean soil buffer."); - frame.set ("where", 1); - frame.declare_fraction ("efficiency", Attribute::Const, "\ + frame.set ("where", 1); + frame.declare_fraction ("efficiency", Attribute::Const, "\ Fraction of carbon not lost as CO2 during turnover."); - frame.set_cited ("efficiency", 0.62, "Table 1", "garnier2003modelling"); - frame.declare ("C_per_N_goal", "g C/g N", Check::non_negative (), - Attribute::Const, "\ + frame.set_cited ("efficiency", 0.62, "Table 1", "garnier2003modelling"); + frame.declare ("C_per_N_goal", "g C/g N", Check::non_negative (), + Attribute::Const, "\ Target C/N for DOM turnover.\n\ If non-negative, mineral N will be added or removed to achieve the goal."); - frame.set_cited ("C_per_N_goal", 10.0, "Table 2", "garnier2003modelling"); + frame.set_cited ("C_per_N_goal", 10.0, "Table 2", "garnier2003modelling"); - frame.declare ("NH4", "g N/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, - "Rate of ammonium generated."); - frame.declare ("NO3", "g N/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, - "Rate of nitrate generated."); - frame.declare ("CO2", "g C/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, - "Rate of carbon dioxide generated."); - frame.declare ("DOC", "g C/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, - "Rate of dissolved organic C consumed."); - frame.declare ("DON", "g N/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, - "Rate of dissolved organic N consumed."); - frame.declare ("SOC", "g C/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, - "Rate of dissolved organic C immobilized."); - frame.declare ("SON", "g N/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, - "Rate of dissolved organic N immobilized."); - frame.declare ("h_factor", Attribute::None (), - Attribute::LogOnly, Attribute::SoilCells, - "Soil water potential effect on turnover rate."); - frame.declare ("T_factor", Attribute::None (), - Attribute::LogOnly, Attribute::SoilCells, - "Soil temperature effect on turnover rate."); - frame.declare ("N_factor", Attribute::None (), - Attribute::LogOnly, Attribute::SoilCells, - "Soil nitrogen effect on turnover rate."); - } -} ReactionDOM_syntax; + frame.declare ("NH4", "g N/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, + "Rate of ammonium generated."); + frame.declare ("NO3", "g N/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, + "Rate of nitrate generated."); + frame.declare ("CO2", "g C/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, + "Rate of carbon dioxide generated."); + frame.declare ("DOC", "g C/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, + "Rate of dissolved organic C consumed."); + frame.declare ("DON", "g N/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, + "Rate of dissolved organic N consumed."); + frame.declare ("SOC", "g C/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, + "Rate of dissolved organic C immobilized."); + frame.declare ("SON", "g N/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, + "Rate of dissolved organic N immobilized."); + frame.declare ("h_factor", Attribute::None (), + Attribute::LogOnly, Attribute::SoilCells, + "Soil water potential effect on turnover rate."); + frame.declare ("T_factor", Attribute::None (), + Attribute::LogOnly, Attribute::SoilCells, + "Soil temperature effect on turnover rate."); + frame.declare ("N_factor", Attribute::None (), + Attribute::LogOnly, Attribute::SoilCells, + "Soil nitrogen effect on turnover rate."); + } + } ReactionDOM_syntax; +} // reaction_dom.C ends here. diff --git a/src/daisy/chemicals/reaction_equil.C b/src/daisy/chemicals/reaction_equil.C index a480052dd..2ba7253d7 100644 --- a/src/daisy/chemicals/reaction_equil.C +++ b/src/daisy/chemicals/reaction_equil.C @@ -295,58 +295,62 @@ struct ReactionEquilibrium : public Reaction const symbol ReactionEquilibrium::k_unit ("h^-1"); -static struct ReactionEquilibriumSyntax : public DeclareModel +void +register_reaction_equil_models () { - Model* make (const BlockModel& al) const - { return new ReactionEquilibrium (al); } - ReactionEquilibriumSyntax () - : DeclareModel (Reaction::component, "equilibrium", - "Equilibrium between two soil chemicals.") - { } - void load_frame (Frame& frame) const + static struct ReactionEquilibriumSyntax : public DeclareModel { - - frame.declare_string ("A", Attribute::Const, - "Name of first soil component in equilibrium."); - frame.declare_string ("B", Attribute::Const, - "Name of second soil component in equilibrium."); - frame.declare_object ("equilibrium", Equilibrium::component, - "Function for calculating equilibrium between A and B."); - frame.declare_object ("k_AB", Number::component, - Attribute::Const, Attribute::Singleton, - "Tranformation rate from soil component 'A' to 'B'."); - frame.declare_object ("k_BA", Number::component, - Attribute::OptionalConst, Attribute::Singleton, - "Tranformation rate from soil component 'B' to 'A'.\n\ + Model* make (const BlockModel& al) const + { return new ReactionEquilibrium (al); } + ReactionEquilibriumSyntax () + : DeclareModel (Reaction::component, "equilibrium", + "Equilibrium between two soil chemicals.") + { } + void load_frame (Frame& frame) const + { + + frame.declare_string ("A", Attribute::Const, + "Name of first soil component in equilibrium."); + frame.declare_string ("B", Attribute::Const, + "Name of second soil component in equilibrium."); + frame.declare_object ("equilibrium", Equilibrium::component, + "Function for calculating equilibrium between A and B."); + frame.declare_object ("k_AB", Number::component, + Attribute::Const, Attribute::Singleton, + "Tranformation rate from soil component 'A' to 'B'."); + frame.declare_object ("k_BA", Number::component, + Attribute::OptionalConst, Attribute::Singleton, + "Tranformation rate from soil component 'B' to 'A'.\n\ By default, this is identical to 'k_AB'."); - frame.declare ("surface_AB", "g/cm^2/h", Attribute::LogOnly, "\ + frame.declare ("surface_AB", "g/cm^2/h", Attribute::LogOnly, "\ Converted from A to B on surface this timestep (may be negative)."); - frame.declare ("S_AB", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, "\ + frame.declare ("S_AB", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, "\ Converted from A to B in soil this timestep (may be negative)."); - frame.declare_string ("colloid", Attribute::OptionalConst, - "Let 'rho_b' denote content of specified chemical.\n\ + frame.declare_string ("colloid", Attribute::OptionalConst, + "Let 'rho_b' denote content of specified chemical.\n\ This might affect the evaluation of the 'k_AB' and 'k_BA' parameter\n\ expressions, as well as the 'equilibrium' model.\n\ By default, 'rho_b' will be the soil dry bulk density."); - frame.declare_boolean ("primary", Attribute::OptionalConst, - "Equilibrium should happen in the primary domain.\n\ + frame.declare_boolean ("primary", Attribute::OptionalConst, + "Equilibrium should happen in the primary domain.\n\ If true, the content of the primary soil domain (soil-bound and\n\ intra-aggregate pores), will be included in the reaction.\n\ By default, this will be true if 'secondary' is false, and be false if\n\ 'secondary' is true."); - frame.declare_boolean ("secondary", Attribute::Const, - "Equilibrium should happen in the secondary domain.\n\ + frame.declare_boolean ("secondary", Attribute::Const, + "Equilibrium should happen in the secondary domain.\n\ There will only be a reaction when there is water in the secondary domain\n\ (inter-aggregate pores), at both the beginning and end of the timestep.\n\ By default, only the content of the primary domain (soil-bound and\n\ intra-aggregate pores), will be included in the reaction.\n\ There is no way to use this model to specify an equilibrium reaction in\n\ the tertiary domain (biopores)."); - frame.set ("secondary", false); - frame.declare_boolean ("surface", Attribute::Const, - "Equilibrium should happen in the surface."); - frame.set ("surface", false); - } -} ReactionEquilibrium_syntax; + frame.set ("secondary", false); + frame.declare_boolean ("surface", Attribute::Const, + "Equilibrium should happen in the surface."); + frame.set ("surface", false); + } + } ReactionEquilibrium_syntax; +} // reaction_equil.C ends here. diff --git a/src/daisy/chemicals/reaction_filter.C b/src/daisy/chemicals/reaction_filter.C index f8536f570..6b298692d 100644 --- a/src/daisy/chemicals/reaction_filter.C +++ b/src/daisy/chemicals/reaction_filter.C @@ -146,38 +146,40 @@ struct ReactionFilter : public Reaction { } }; -static struct ReactionFilterSyntax : public DeclareModel +void +register_reaction_filter_models () { - Model* make (const BlockModel& al) const - { return new ReactionFilter (al); } - ReactionFilterSyntax () - : DeclareModel (Reaction::component, "filter_velocity", - "Filtration of soil colloids.") - { } - void load_frame (Frame& frame) const + static struct ReactionFilterSyntax : public DeclareModel { - - - frame.declare_string ("immobile", Attribute::OptionalConst, - "Immobile colloids in the soil.\n\ + Model* make (const BlockModel& al) const + { return new ReactionFilter (al); } + ReactionFilterSyntax () + : DeclareModel (Reaction::component, "filter_velocity", + "Filtration of soil colloids.") + { } + void load_frame (Frame& frame) const + { + + + frame.declare_string ("immobile", Attribute::OptionalConst, + "Immobile colloids in the soil.\n\ By default, filtered colloids are not tracked."); - frame.declare_string ("mobile", Attribute::Const, - "Mobile colloids dissolved in soil water."); - frame.declare ("F_primary", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Filtration in the primary domain (intra-aggregate pores)."); - frame.declare ("F_secondary", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Filtration in secondary domain (inter-aggregate pores)."); - - frame.declare ("fc_primary", "cm^-1", Check::positive (), Attribute::Const, - "Filter coefficient in the primary domain"); - // frame.set ("fc_primary", 1.0); - - frame.declare ("fc_secondary", "cm^-1", Check::positive (), Attribute::Const, - "Filter coefficient in secondary domain"); - // frame.set ("fc_secondary", 0.5); - - } - -} ReactionFilter_syntax; - - + frame.declare_string ("mobile", Attribute::Const, + "Mobile colloids dissolved in soil water."); + frame.declare ("F_primary", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Filtration in the primary domain (intra-aggregate pores)."); + frame.declare ("F_secondary", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Filtration in secondary domain (inter-aggregate pores)."); + + frame.declare ("fc_primary", "cm^-1", Check::positive (), Attribute::Const, + "Filter coefficient in the primary domain"); + // frame.set ("fc_primary", 1.0); + + frame.declare ("fc_secondary", "cm^-1", Check::positive (), Attribute::Const, + "Filter coefficient in secondary domain"); + // frame.set ("fc_secondary", 0.5); + + } + + } ReactionFilter_syntax; +} diff --git a/src/daisy/chemicals/reaction_nit.C b/src/daisy/chemicals/reaction_nit.C index 12084db13..e15e94568 100644 --- a/src/daisy/chemicals/reaction_nit.C +++ b/src/daisy/chemicals/reaction_nit.C @@ -102,7 +102,6 @@ ReactionNitrification::tick_soil (const Geometry& geo, NH4[i] = N2O[i] = NO3[i] = 0.0; } - soil_NH4.add_to_transform_sink (NH4); soil_NO3.add_to_transform_source (NO3); } @@ -147,27 +146,31 @@ ReactionNitrification::ReactionNitrification (const BlockModel& al) : Reaction (al) { } -static struct ReactionNitrificationSyntax : public DeclareModel +void +register_reaction_nit_models () { - Model* make (const BlockModel& al) const - { return new ReactionNitrification (al); } - ReactionNitrificationSyntax () - : DeclareModel (Reaction::component, "nitrification", "Nitrification.\n\ + static struct ReactionNitrificationSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new ReactionNitrification (al); } + ReactionNitrificationSyntax () + : DeclareModel (Reaction::component, "nitrification", "Nitrification.\n\ The actual nitrification specification is part of the horizon models, this\n\ reaction just applies the models and logs the result. ") - { } - void load_frame (Frame& frame) const - { + { } + void load_frame (Frame& frame) const + { - frame.declare ("NH4", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Amount of ammonium consumed this hour."); - frame.declare ("NO3", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Amount of nitrate generated this hour."); - frame.declare ("N2O", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Amount of nitrous oxide generated this hour."); + frame.declare ("NH4", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Amount of ammonium consumed this hour."); + frame.declare ("NO3", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Amount of nitrate generated this hour."); + frame.declare ("N2O", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Amount of nitrous oxide generated this hour."); - } -} ReactionNitrification_syntax; + } + } ReactionNitrification_syntax; +} // reaction_nit.C ends here. diff --git a/src/daisy/chemicals/reaction_shoot.C b/src/daisy/chemicals/reaction_shoot.C index b4aac8e83..c2ac88eba 100644 --- a/src/daisy/chemicals/reaction_shoot.C +++ b/src/daisy/chemicals/reaction_shoot.C @@ -127,38 +127,6 @@ struct ReactionShoot : public Reaction } }; -static struct ReactionShootSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new ReactionShoot (al); } - ReactionShootSyntax () - : DeclareModel (Reaction::component, "shoot", "Pool based on shoot DM.\n\ -Generate chemical (M) on canopy up to maximum (M_max).\n\ -M_max depends on the shoot DM and DS.\n\ -dM/dt = fill_rate * (M_max - M).") - { } - void load_frame (Frame& frame) const - { - frame.declare_string ("chemical", Attribute::Const, "\ -Chemical to generate."); - static VCheck::InLibrary is_chemical (Chemical::component); - frame.set_check ("chemical", is_chemical); - frame.declare_string ("crop", Attribute::Const, "\ -Crop whose shoot is used as basis.\n\ -Special value 'all' means all crops on the field."); - frame.set ("crop", Vegetation::all_crops ()); - frame.set_check ("crop", Crop::check_all ()); - Rate::declare (frame, "fill", "Pool fill rate."); - frame.declare ("M_max", "g/cm^2", "g/cm^2", Check::non_negative (), - Attribute::Const, "\ -Maximum amount of chemical per shoot DM."); - frame.declare ("DS_factor", "DS", Attribute::None (), - Check::non_negative (), Attribute::Const, "\ -Influence of DS on M_max."); - frame.set ("DS_factor", PLF::always_1 ()); - } -} ReactionShoot_syntax; - // The 'shoot2' reaction model. struct ReactionShoot2 : public Reaction @@ -189,7 +157,6 @@ struct ReactionShoot2 : public Reaction if (M_max_1 < 1e-99 || fill_rate < 1e-99) return; - daisy_assert (std::isfinite (M_max_1)); daisy_assert (M_max_1 > 0.0); Chemical& my_chemical = chemistry.find (chemical); @@ -269,45 +236,81 @@ struct ReactionShoot2 : public Reaction } }; -static struct ReactionShoot2Syntax : public DeclareModel +void +register_reaction_shoot_models () { - Model* make (const BlockModel& al) const - { return new ReactionShoot2 (al); } - ReactionShoot2Syntax () - : DeclareModel (Reaction::component, "shoot2", "Pool based on shoot DM.\n\ + static struct ReactionShootSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new ReactionShoot (al); } + ReactionShootSyntax () + : DeclareModel (Reaction::component, "shoot", "Pool based on shoot DM.\n\ +Generate chemical (M) on canopy up to maximum (M_max).\n\ +M_max depends on the shoot DM and DS.\n\ +dM/dt = fill_rate * (M_max - M).") + { } + void load_frame (Frame& frame) const + { + frame.declare_string ("chemical", Attribute::Const, "\ +Chemical to generate."); + static VCheck::InLibrary is_chemical (Chemical::component); + frame.set_check ("chemical", is_chemical); + frame.declare_string ("crop", Attribute::Const, "\ +Crop whose shoot is used as basis.\n\ +Special value 'all' means all crops on the field."); + frame.set ("crop", Vegetation::all_crops ()); + frame.set_check ("crop", Crop::check_all ()); + Rate::declare (frame, "fill", "Pool fill rate."); + frame.declare ("M_max", "g/cm^2", "g/cm^2", Check::non_negative (), + Attribute::Const, "\ +Maximum amount of chemical per shoot DM."); + frame.declare ("DS_factor", "DS", Attribute::None (), + Check::non_negative (), Attribute::Const, "\ +Influence of DS on M_max."); + frame.set ("DS_factor", PLF::always_1 ()); + } + } ReactionShoot_syntax; + + static struct ReactionShoot2Syntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new ReactionShoot2 (al); } + ReactionShoot2Syntax () + : DeclareModel (Reaction::component, "shoot2", "Pool based on shoot DM.\n\ Generate chemical (M) on canopy up to maximum (M_max).\n\ M_max depends on the shoot DM and DS.\n\ \n\ dM/dt = growth_rate + fill_rate * (M_max - M).\n\ \n\ growth_rate = max (0.0, (M_max (t1) - M_max (t0)) / (t1 - t0))") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "jorgensen2020novel", - "GARCIAJORGENSEN2024170658"); - frame.declare_string ("chemical", Attribute::Const, "\ + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "jorgensen2020novel", + "GARCIAJORGENSEN2024170658"); + frame.declare_string ("chemical", Attribute::Const, "\ Chemical to generate."); - static VCheck::InLibrary is_chemical (Chemical::component); - frame.set_check ("chemical", is_chemical); - frame.declare_string ("crop", Attribute::Const, "\ + static VCheck::InLibrary is_chemical (Chemical::component); + frame.set_check ("chemical", is_chemical); + frame.declare_string ("crop", Attribute::Const, "\ Crop whose shoot is used as basis.\n\ Special value 'all' means all crops on the field."); - frame.set ("crop", Vegetation::all_crops ()); - frame.set_check ("crop", Crop::check_all ()); - Rate::declare (frame, "fill", "Pool fill rate."); - frame.declare ("M_max", "g/cm^2", "g/cm^2", Check::non_negative (), - Attribute::Const, "\ + frame.set ("crop", Vegetation::all_crops ()); + frame.set_check ("crop", Crop::check_all ()); + Rate::declare (frame, "fill", "Pool fill rate."); + frame.declare ("M_max", "g/cm^2", "g/cm^2", Check::non_negative (), + Attribute::Const, "\ Maximum amount of chemical per shoot DM."); - frame.declare ("DS_factor", "DS", Attribute::None (), - Check::non_negative (), Attribute::Const, "\ + frame.declare ("DS_factor", "DS", Attribute::None (), + Check::non_negative (), Attribute::Const, "\ Influence of DS on M_max."); - frame.set ("DS_factor", PLF::always_1 ()); - frame.declare ("M_pot", "g/cm^2", Check::non_negative (), - Attribute::State, - "Potential chemical content."); - frame.set ("M_pot", 0.0); - } -} ReactionShoot2_syntax; + frame.set ("DS_factor", PLF::always_1 ()); + frame.declare ("M_pot", "g/cm^2", Check::non_negative (), + Attribute::State, + "Potential chemical content."); + frame.set ("M_pot", 0.0); + } + } ReactionShoot2_syntax; +} // reaction_shoot.C ends here. diff --git a/src/daisy/chemicals/reaction_sorption.C b/src/daisy/chemicals/reaction_sorption.C index 89d493ed0..23ceae549 100644 --- a/src/daisy/chemicals/reaction_sorption.C +++ b/src/daisy/chemicals/reaction_sorption.C @@ -245,7 +245,6 @@ struct ReactionSorption : public Reaction : k_desorption * (has_solute - want_solute); } - // Create. bool check (const Geometry&, const Soil&, const SoilWater&, @@ -305,87 +304,91 @@ struct ReactionSorption : public Reaction const symbol ReactionSorption::k_unit ("h^-1"); -static struct ReactionSorptionSyntax : public DeclareModel +void +register_reaction_sorption_models () { - Model* make (const BlockModel& al) const - { return new ReactionSorption (al); } - ReactionSorptionSyntax () - : DeclareModel (Reaction::component, "sorption", - "Kinetic linear sorption equilibrium.\n\ + static struct ReactionSorptionSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new ReactionSorption (al); } + ReactionSorptionSyntax () + : DeclareModel (Reaction::component, "sorption", + "Kinetic linear sorption equilibrium.\n\ Faster than the 'equilibrium' reaction model, more flexible than the\n\ 'adsorption' reaction model.") - { } - static bool check_alist (const Metalib&, const Frame& al, Treelog& msg) - { - bool ok = true; + { } + static bool check_alist (const Metalib&, const Frame& al, Treelog& msg) + { + bool ok = true; - const bool has_K_d = al.check ("K_d"); - const bool has_K_clay = al.check ("K_clay"); - const bool has_K_OC = al.check ("K_OC"); - - if (!has_K_d && !has_K_clay && !has_K_OC) - { - msg.error ("You must specify either 'K_d', 'K_clay' or 'K_OC'"); - ok = false; - } - if (has_K_d && (has_K_clay || has_K_OC)) - { - msg.error ("You cannot specify 'K_d' with 'K_clay' or 'K_OC'"); - ok = false; - } - return ok; - } + const bool has_K_d = al.check ("K_d"); + const bool has_K_clay = al.check ("K_clay"); + const bool has_K_OC = al.check ("K_OC"); + + if (!has_K_d && !has_K_clay && !has_K_OC) + { + msg.error ("You must specify either 'K_d', 'K_clay' or 'K_OC'"); + ok = false; + } + if (has_K_d && (has_K_clay || has_K_OC)) + { + msg.error ("You cannot specify 'K_d' with 'K_clay' or 'K_OC'"); + ok = false; + } + return ok; + } - void load_frame (Frame& frame) const - { - frame.add_check (check_alist); - frame.declare_string ("solute", Attribute::Const, - "Name of solute form of chemical.\n\ + void load_frame (Frame& frame) const + { + frame.add_check (check_alist); + frame.declare_string ("solute", Attribute::Const, + "Name of solute form of chemical.\n\ If this chemical has equilibrium sorption, only the colute part is used."); - frame.declare_string ("sorbed", Attribute::Const, - "Name of sorbed form of chemical."); - frame.declare ("K_d", "cm^3/g", Check::non_negative (), - Attribute::OptionalConst, "\ + frame.declare_string ("sorbed", Attribute::Const, + "Name of sorbed form of chemical."); + frame.declare ("K_d", "cm^3/g", Check::non_negative (), + Attribute::OptionalConst, "\ Equillibrium parameter: M = C (K_d rho_b + Theta)\n\ Here M is the total amount, C is solute concentration, K_d is this\n\ parameter, rho_b is the dry bulk density, and Theta is the volumetric\n\ water content. By default, K_d is calculated from K_clay and K_OC."); - frame.declare ("K_clay", "cm^3/g", Check::non_negative (), - Attribute::OptionalConst, - "Clay dependent distribution parameter.\n\ + frame.declare ("K_clay", "cm^3/g", Check::non_negative (), + Attribute::OptionalConst, + "Clay dependent distribution parameter.\n\ It is multiplied with the soil clay fraction to get the clay part of\n\ the 'K_d' factor. If 'K_OC' is specified, 'K_clay' defaults to 0."); - frame.declare ("K_OC", "cm^3/g", Check::non_negative (), - Attribute::OptionalConst, - "Humus dependent distribution parameter.\n\ + frame.declare ("K_OC", "cm^3/g", Check::non_negative (), + Attribute::OptionalConst, + "Humus dependent distribution parameter.\n\ It is multiplied with the soil organic carbon fraction to get the\n\ carbon part of the 'K_d' factor. By default, 'K_OC' is equal to 'K_clay'."); - frame.declare ("k_sorption", "h^-1", - Check::non_negative (), Attribute::Const, "\ + frame.declare ("k_sorption", "h^-1", + Check::non_negative (), Attribute::Const, "\ Sorption rate."); - frame.declare ("k_desorption", "h^-1", - Check::non_negative (), Attribute::OptionalConst, "\ + frame.declare ("k_desorption", "h^-1", + Check::non_negative (), Attribute::OptionalConst, "\ Desorption rate.\n\ By default, this is identical to 'k_sorption'."); - frame.declare ("surface_sorption", "g/cm^2/h", Attribute::LogOnly, "\ + frame.declare ("surface_sorption", "g/cm^2/h", Attribute::LogOnly, "\ Sorption on surface this timestep (may be negative)."); - frame.declare ("S_sorption", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, "\ + frame.declare ("S_sorption", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, "\ Sorption in soil this timestep (may be negative)."); - frame.declare ("S_sorption_primary", "g/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, "\ + frame.declare ("S_sorption_primary", "g/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, "\ Sorption in primary domain this timestep (may be negative)."); - frame.declare ("S_sorption_secondary", "g/cm^3/h", - Attribute::LogOnly, Attribute::SoilCells, "\ + frame.declare ("S_sorption_secondary", "g/cm^3/h", + Attribute::LogOnly, Attribute::SoilCells, "\ Sorption in secondary domain this timestep (may be negative)."); - frame.declare_string ("colloid", Attribute::OptionalConst, "\ + frame.declare_string ("colloid", Attribute::OptionalConst, "\ Sorp to this chemical instead of to the soil matrix."); - frame.declare ("soil_enrichment_factor", - Attribute::None (), Check::positive (), Attribute::Const, "\ + frame.declare ("soil_enrichment_factor", + Attribute::None (), Check::positive (), Attribute::Const, "\ Multiply K_d with this number if 'colloid' is set.\n\ This represents how much more accesible colloids is compared to\n\ the soil matrix."); - frame.set ("soil_enrichment_factor", 1.0); - } -} ReactionSorption_syntax; + frame.set ("soil_enrichment_factor", 1.0); + } + } ReactionSorption_syntax; +} // reaction_sorption.C ends here. diff --git a/src/daisy/chemicals/reaction_std.C b/src/daisy/chemicals/reaction_std.C index 39f39636f..a511b2b98 100644 --- a/src/daisy/chemicals/reaction_std.C +++ b/src/daisy/chemicals/reaction_std.C @@ -111,24 +111,28 @@ struct ReactionStandard : public Reaction { } }; -static struct ReactionStandardSyntax : public DeclareModel +void +register_reaction_std_models () { - Model* make (const BlockModel& al) const - { return new ReactionStandard (al); } - ReactionStandardSyntax () - : DeclareModel (Reaction::component, "default", - "Transformation between two soil chemicals.") - { } - void load_frame (Frame& frame) const + static struct ReactionStandardSyntax : public DeclareModel { - frame.declare_object ("transform", Transform::component, - "Tranformation process between 'A' to 'B'."); - frame.declare_string ("A", Attribute::Const, - "Name of first soil component in equilibrium."); - frame.declare_string ("B", Attribute::Const, - "Name of second soil component in equilibrium."); - frame.declare ("S_AB", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, - "Converted from A to B this timestep (may be negative)."); + Model* make (const BlockModel& al) const + { return new ReactionStandard (al); } + ReactionStandardSyntax () + : DeclareModel (Reaction::component, "default", + "Transformation between two soil chemicals.") + { } + void load_frame (Frame& frame) const + { + frame.declare_object ("transform", Transform::component, + "Tranformation process between 'A' to 'B'."); + frame.declare_string ("A", Attribute::Const, + "Name of first soil component in equilibrium."); + frame.declare_string ("B", Attribute::Const, + "Name of second soil component in equilibrium."); + frame.declare ("S_AB", "g/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, + "Converted from A to B this timestep (may be negative)."); - } -} ReactionStandard_syntax; + } + } ReactionStandard_syntax; +} diff --git a/src/daisy/chemicals/transform.C b/src/daisy/chemicals/transform.C index 7908112b7..ddbb6765b 100644 --- a/src/daisy/chemicals/transform.C +++ b/src/daisy/chemicals/transform.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/chemicals/transform.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" @@ -51,15 +52,21 @@ Transform::Transform (const BlockModel&) Transform::~Transform () { } -static struct TransformInit : public DeclareComponent +void +register_transform_models () { - void load_frame (Frame& frame) const - { - Model::load_model (frame); - } + static struct TransformInit : public DeclareComponent + { + void load_frame (Frame& frame) const + { + Model::load_model (frame); + } - TransformInit () - : DeclareComponent (Transform::component, "\ + TransformInit () + : DeclareComponent (Transform::component, "\ Generic transformations between soil components.") - { } -} Transform_init; + { } + } Transform_init; + + register_transform_equil_models (); +} diff --git a/src/daisy/chemicals/transform_equil.C b/src/daisy/chemicals/transform_equil.C index 5549870e6..bb6623a2e 100644 --- a/src/daisy/chemicals/transform_equil.C +++ b/src/daisy/chemicals/transform_equil.C @@ -158,24 +158,28 @@ TransformEquilibrium::initialize (const Units& units, k_BA_expr->initialize (units, scope, msg); } -static struct TransformEquilibriumSyntax : public DeclareModel +void +register_transform_equil_models () { - Model* make (const BlockModel& al) const - { return new TransformEquilibrium (al); } - TransformEquilibriumSyntax () - : DeclareModel (Transform::component, "equilibrium", - "Two soil components reching for equilibrium.") - { } - void load_frame (Frame& frame) const + static struct TransformEquilibriumSyntax : public DeclareModel { - frame.declare_object ("equilibrium", Equilibrium::component, - "Function for calculating equilibrium between A and B."); - frame.declare_object ("k_AB", Number::component, - Attribute::Const, Attribute::Singleton, "\ + Model* make (const BlockModel& al) const + { return new TransformEquilibrium (al); } + TransformEquilibriumSyntax () + : DeclareModel (Transform::component, "equilibrium", + "Two soil components reching for equilibrium.") + { } + void load_frame (Frame& frame) const + { + frame.declare_object ("equilibrium", Equilibrium::component, + "Function for calculating equilibrium between A and B."); + frame.declare_object ("k_AB", Number::component, + Attribute::Const, Attribute::Singleton, "\ Tranformation rate from soil component 'A' to 'B' [h^-1]."); - frame.declare_object ("k_BA", Number::component, - Attribute::OptionalConst, Attribute::Singleton, "\ + frame.declare_object ("k_BA", Number::component, + Attribute::OptionalConst, Attribute::Singleton, "\ Tranformation rate from soil component 'B' to 'A' [h^-1].\n\ By default, this is identical to 'k_AB'."); - } -} TransformEquilibrium_syntax; + } + } TransformEquilibrium_syntax; +} diff --git a/src/daisy/column.C b/src/daisy/column.C index addcf7009..a5f7176fc 100644 --- a/src/daisy/column.C +++ b/src/daisy/column.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/column.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/output/log.h" #include "object_model/librarian.h" @@ -59,7 +60,7 @@ Column::Column (const BlockModel& al) Column::~Column () { } -static struct ColumnInit : public DeclareComponent +struct ColumnInit : public DeclareComponent { void load_frame (Frame& frame) const { @@ -85,6 +86,13 @@ A 'column' is an one-dimensional vertical description of the\n\ soil/crop/atmosphere system. The column component contains most of\n\ the other processes in Daisy as submodels.") { } -} Column_init; +}; + +void +register_column_models () +{ + static ColumnInit column_init; + register_column_standard_models (); +} // column.C ends here. diff --git a/src/daisy/column_std.C b/src/daisy/column_std.C index 2ffd981fd..7e0bea9cb 100644 --- a/src/daisy/column_std.C +++ b/src/daisy/column_std.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/column.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/library.h" #include "daisy/upper_boundary/surface/surface.h" #include "daisy/soil/soil_heat.h" @@ -1229,7 +1230,7 @@ ColumnStandard::summarize (Treelog& msg) const ColumnStandard::~ColumnStandard () { } -static struct ColumnStandardSyntax : public DeclareModel +struct ColumnStandardSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ColumnStandard (al); } @@ -1360,6 +1361,12 @@ This includes dry matter incorporated directly in the soil."); : DeclareModel (Column::component, "default", "\ Hansen et.al. 1990. with generic movement in soil.") { } -} column_syntax; +}; + +void +register_column_standard_models () +{ + static ColumnStandardSyntax column_standard_syntax; +} // column_std.C ends here. diff --git a/src/daisy/condition.C b/src/daisy/condition.C index 0c749b874..869fd1fca 100644 --- a/src/daisy/condition.C +++ b/src/daisy/condition.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/condition.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" @@ -56,7 +57,7 @@ Condition::Condition (const char *const id) Condition::~Condition () { } -static struct ConditionInit : public DeclareComponent +struct ConditionInit : public DeclareComponent { ConditionInit () : DeclareComponent (Condition::component, "\ @@ -65,6 +66,22 @@ whether the water pressure in a specific depth is above a given\n\ threshold. Logic conditions like 'and' and 'or' can be used for\n\ testing whether multiple conditions are fulfilled simultaneously.") { } -} Condition_init; +}; + +void +register_condition_models () +{ + static ConditionInit condition_init; + register_condition_boolean_models (); + register_condition_BBCH_models (); + register_condition_crop_models (); + register_condition_daisy_state_models (); + register_condition_extern_models (); + register_condition_logic_models (); + register_condition_soil_models (); + register_condition_time_models (); + register_condition_walltime_models (); + register_condition_weather_models (); +} // condition.C ends here. diff --git a/src/daisy/condition_BBCH.C b/src/daisy/condition_BBCH.C index 90ae33e7c..a2b6dd116 100644 --- a/src/daisy/condition_BBCH.C +++ b/src/daisy/condition_BBCH.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/condition.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" #include "object_model/frame.h" @@ -127,7 +128,7 @@ struct ConditionBBCH : public Condition { } }; -static struct ConditionBBCHSyntax : public DeclareModel +struct ConditionBBCHSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionBBCH (al); } @@ -147,6 +148,12 @@ Otherwise, the interval begins when the crop leaves the specified BBCH."); frame.declare_string ("crop", Attribute::Const, "\ Name of crop to use BBCH number for."); } -} ConditionBBCH_syntax; +}; + +void +register_condition_BBCH_models () +{ + static ConditionBBCHSyntax condition_bbch_syntax; +} // condition_BBCH.C ends here. diff --git a/src/daisy/condition_boolean.C b/src/daisy/condition_boolean.C index c6ba8d31d..dc3f9eb08 100644 --- a/src/daisy/condition_boolean.C +++ b/src/daisy/condition_boolean.C @@ -23,6 +23,7 @@ #define BUILD_DLL #include "daisy/condition.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/parameter_types/boolean.h" #include "util/scope.h" #include "object_model/librarian.h" @@ -93,7 +94,7 @@ struct ConditionBoolean : public Condition { } }; -static struct ConditionBooleanSyntax : public DeclareModel +struct ConditionBooleanSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionBoolean (al); } @@ -108,4 +109,10 @@ Test if a boolean expression is true.") Expression to evaluate."); frame.order ("expr"); } -} ConditionBoolean_syntax; +}; + +void +register_condition_boolean_models () +{ + static ConditionBooleanSyntax condition_boolean_syntax; +} diff --git a/src/daisy/condition_crop.C b/src/daisy/condition_crop.C index 7d3b39809..2578f0ddc 100644 --- a/src/daisy/condition_crop.C +++ b/src/daisy/condition_crop.C @@ -24,6 +24,7 @@ #define BUILD_DLL #include "daisy/condition.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/crop/crop.h" #include "daisy/field.h" @@ -90,7 +91,7 @@ struct ConditionWith : public Condition { } }; -static struct ConditionWithSyntax : public DeclareModel +struct ConditionWithSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionWith (al); } @@ -107,7 +108,7 @@ Test condition for specific column.") "Condition to test on the specified column."); frame.order ("where", "condition"); } -} ConditionWith_syntax; +}; // The 'crop_ds_after' condition. @@ -142,7 +143,7 @@ struct ConditionDSAfter : public Condition { } }; -static struct ConditionCropDSSyntax : public DeclareModel +struct ConditionCropDSSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionDSAfter (al); } @@ -162,7 +163,7 @@ Specify \"all\" to use combined weight of all crops on the field in test."); "Development stage [-1.0:2.0]."); frame.order ("crop", "ds"); } -} ConditionCropDS_syntax; +}; // The 'crop_stage_after' condition. @@ -197,7 +198,7 @@ struct ConditionStageAfter : public Condition { } }; -static struct ConditionCropStageSyntax : public DeclareModel +struct ConditionCropStageSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionStageAfter (al); } @@ -216,7 +217,7 @@ Specify \"all\" to use combined weight of all crops on the field in test."); "Crop specific phenological stage."); frame.order ("crop", "stage"); } -} ConditionCropStage_syntax; +}; // The 'crop_dm_over' condition. @@ -249,7 +250,7 @@ struct ConditionDMOver : public Condition { } }; -static struct ConditionCropDMSyntax : public DeclareModel +struct ConditionCropDMSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionDMOver (al); } @@ -272,7 +273,7 @@ Height above which we measure the DM weight."); frame.set ("height", 0.0); frame.order ("crop", "weight"); } -} ConditionCropDM_syntax; +}; // The 'crop_dm_sorg_over' condition. @@ -303,7 +304,7 @@ struct ConditionDMSOrgOver : public Condition { } }; -static struct ConditionCropDMSorgSyntax : public DeclareModel +struct ConditionCropDMSorgSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionDMSOrgOver (al); } @@ -322,6 +323,16 @@ True iff the storage organ has reached the specified amount of dry matter.") Amount of non-root dry-matter required for the condition to be true."); frame.order ("crop", "weight"); } -} ConditionCropDMSorg_syntax; +}; + +void +register_condition_crop_models () +{ + static ConditionWithSyntax condition_with_syntax; + static ConditionCropDSSyntax condition_crop_ds_syntax; + static ConditionCropStageSyntax condition_crop_stage_syntax; + static ConditionCropDMSyntax condition_crop_dm_syntax; + static ConditionCropDMSorgSyntax condition_crop_dmsorg_syntax; +} // condition_crop.C ends here. diff --git a/src/daisy/condition_daisy.C b/src/daisy/condition_daisy.C index 1ec0b3972..ba9c05a62 100644 --- a/src/daisy/condition_daisy.C +++ b/src/daisy/condition_daisy.C @@ -24,6 +24,7 @@ #define BUILD_DLL #include "daisy/condition.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/daisy.h" #include "object_model/librarian.h" @@ -67,7 +68,7 @@ struct ConditionFinished : public Condition { } }; -static struct ConditionRunningSyntax : public DeclareModel +struct ConditionRunningSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionRunning (al); } @@ -78,9 +79,9 @@ static struct ConditionRunningSyntax : public DeclareModel { } void load_frame (Frame&) const { } -} ConditionRunning_syntax; +}; -static struct ConditionFinishedSyntax : public DeclareModel +struct ConditionFinishedSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionFinished (al); } @@ -91,4 +92,11 @@ static struct ConditionFinishedSyntax : public DeclareModel { } void load_frame (Frame&) const { } -} ConditionFinished_syntax; +}; + +void +register_condition_daisy_state_models () +{ + static ConditionRunningSyntax condition_running_syntax; + static ConditionFinishedSyntax condition_finished_syntax; +} diff --git a/src/daisy/condition_extern.C b/src/daisy/condition_extern.C index 4539a9422..af6de9214 100644 --- a/src/daisy/condition_extern.C +++ b/src/daisy/condition_extern.C @@ -23,6 +23,7 @@ #define BUILD_DLL #include "daisy/condition.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/daisy.h" #include "object_model/block_model.h" #include "object_model/parameter_types/boolean.h" @@ -106,7 +107,7 @@ struct ConditionExtern : public Condition { } }; -static struct ConditionExternSyntax : public DeclareModel +struct ConditionExternSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionExtern (al); } @@ -124,6 +125,12 @@ Scope to evaluate expession in."); Expression to evaluate."); frame.order ("scope", "expr"); } -} ConditionExtern_syntax; +}; + +void +register_condition_extern_models () +{ + static ConditionExternSyntax condition_extern_syntax; +} // condition_extern.C ends here. diff --git a/src/daisy/condition_logic.C b/src/daisy/condition_logic.C index e37de6390..8edd0d357 100644 --- a/src/daisy/condition_logic.C +++ b/src/daisy/condition_logic.C @@ -24,6 +24,7 @@ #define BUILD_DLL #include "daisy/condition.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/output/log.h" #include "object_model/frame.h" #include "util/memutils.h" @@ -261,7 +262,7 @@ struct ConditionIf : public Condition { } }; -static struct ConditionFalseSyntax : public DeclareModel +struct ConditionFalseSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionFalse (al); } @@ -270,9 +271,9 @@ static struct ConditionFalseSyntax : public DeclareModel { } void load_frame (Frame&) const { } -} ConditionFalse_syntax; +}; -static struct ConditionTrueSyntax : public DeclareModel +struct ConditionTrueSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionTrue (al); } @@ -281,9 +282,9 @@ static struct ConditionTrueSyntax : public DeclareModel { } void load_frame (Frame&) const { } -} ConditionTrue_syntax; +}; -static struct ConditionOrSyntax : public DeclareModel +struct ConditionOrSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionOr (al); } @@ -299,9 +300,9 @@ or the end of the list is reached.") Attribute::State, Attribute::Variable, "Conditions to test."); frame.order ("operands"); } -} ConditionOr_syntax; +}; -static struct ConditionAndSyntax : public DeclareModel +struct ConditionAndSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionAnd (al); } @@ -317,9 +318,9 @@ or the end of the list is reached.") Attribute::State, Attribute::Variable, "Conditions to test."); frame.order ("operands"); } -} ConditionAnd_syntax; +}; -static struct ConditionNotSyntax : public DeclareModel +struct ConditionNotSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionNot (al); } @@ -333,9 +334,9 @@ True iff the operand is not true.") "Condition to test."); frame.order ("operand"); } -} ConditionNot_syntax; +}; -static struct ConditionIfSyntax : public DeclareModel +struct ConditionIfSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionIf (al); } @@ -354,6 +355,17 @@ else return the value of the third condition.") "Condition to use if the 'if' test was false."); frame.order ("if", "then", "else"); } -} ConditionIf_syntax; +}; + +void +register_condition_logic_models () +{ + static ConditionFalseSyntax condition_false_syntax; + static ConditionTrueSyntax condition_true_syntax; + static ConditionOrSyntax condition_or_syntax; + static ConditionAndSyntax condition_and_syntax; + static ConditionNotSyntax condition_not_syntax; + static ConditionIfSyntax condition_if_syntax; +} // condition_logic.C ends here. diff --git a/src/daisy/condition_soil.C b/src/daisy/condition_soil.C index f700b17fc..43d2ffba8 100644 --- a/src/daisy/condition_soil.C +++ b/src/daisy/condition_soil.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/condition.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/frame.h" #include "daisy/field.h" @@ -141,7 +142,7 @@ struct ConditionSoilN_min : public Condition { } }; -static struct ConditionSoilTemperatureSyntax : public DeclareModel +struct ConditionSoilTemperatureSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionSoilTemperature (al); } @@ -156,9 +157,9 @@ Lowest soil temperature for which the condition is true."); frame.declare ("height", "cm", Check::non_positive (), Attribute::Const, "\ Soil depth in which to test the temperature."); } -} ConditionSoilTemperature_syntax; +}; -static struct ConditionSoilPotentialSyntax : public DeclareModel +struct ConditionSoilPotentialSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionSoilPotential (al); } @@ -173,7 +174,7 @@ The soil should be wetter than this for the condition to be true."); frame.declare ("height", "cm", Check::non_positive (), Attribute::Const, "\ Depth at which to example the pressure potential."); } -} ConditionSoilPotential_syntax; +}; static bool check_water_content (const Metalib&, const Frame& al, Treelog& err) { @@ -190,7 +191,7 @@ static bool check_water_content (const Metalib&, const Frame& al, Treelog& err) return ok; } -static struct ConditionSoilWaterSyntax : public DeclareModel +struct ConditionSoilWaterSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionSoilWater (al); } @@ -210,9 +211,9 @@ Top of interval to measure soil water content in."); Bottom of interval to measure soil water content in."); frame.order ("water"); } -} ConditionSoilWater_syntax; +}; -static struct ConditionSoilN_minSyntax : public DeclareModel +struct ConditionSoilN_minSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionSoilN_min (al); } @@ -234,6 +235,15 @@ Top of interval to measure soil content in."); Bottom of interval to measure soil content in."); frame.order ("amount"); } -} ConditionSoilN_min_syntax; +}; + +void +register_condition_soil_models () +{ + static ConditionSoilTemperatureSyntax condition_soil_temperature_syntax; + static ConditionSoilPotentialSyntax condition_soil_potential_syntax; + static ConditionSoilWaterSyntax condition_soil_water_syntax; + static ConditionSoilN_minSyntax condition_soil_n_min_syntax; +} // condition_soil.C ends here. diff --git a/src/daisy/condition_time.C b/src/daisy/condition_time.C index 6d7649c2f..a4a48947a 100644 --- a/src/daisy/condition_time.C +++ b/src/daisy/condition_time.C @@ -23,6 +23,7 @@ #define BUILD_DLL #include "daisy/condition.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/daisy_time.h" #include "daisy/daisy.h" @@ -517,7 +518,7 @@ struct ConditionTimestep : public Condition { return *new ConditionTimestep (al); } }; -static struct ConditionMM_DDBase : public DeclareBase +struct ConditionMM_DDBase : public DeclareBase { ConditionMM_DDBase () : DeclareBase (Condition::component, "mm_dd_base", "\ @@ -562,9 +563,9 @@ Conditions based on month and day.") frame.set ("second", 0); frame.order ("month", "day"); } -} ConditionMM_DD_base; +}; -static struct ConditionMMDDSyntax : public DeclareModel +struct ConditionMMDDSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionMMDD (al); } @@ -574,9 +575,9 @@ True a specific month, day and hour in the year.") { } void load_frame (Frame&) const { } -} ConditionMMDD_syntax; +}; -static struct ConditionBeforeMMDDSyntax : public DeclareModel +struct ConditionBeforeMMDDSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionBeforeMMDD (al); } @@ -586,9 +587,9 @@ True before specific month, day and hour in the year.") { } void load_frame (Frame&) const { } -} ConditionBeforeMMDD_syntax; +}; -static struct ConditionAfterMMDDSyntax : public DeclareModel +struct ConditionAfterMMDDSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionAfterMMDD (al); } @@ -598,9 +599,9 @@ True after specific month, day and hour in the year.") { } void load_frame (Frame&) const { } -} ConditionAfterMMDD_syntax; +}; -static struct ConditionTimeBase : public DeclareBase +struct ConditionTimeBase : public DeclareBase { ConditionTimeBase () : DeclareBase (Condition::component, "time", "\ @@ -612,9 +613,9 @@ Conditions based on a specific time.") "Fixed time to test for.", Time::load_syntax); frame.order ("time"); } -} ConditionTime_base; +}; -static struct ConditionAtSyntax : public DeclareModel +struct ConditionAtSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionAt (al); } @@ -624,9 +625,9 @@ True, iff the simulation time is at the specified time.") { } void load_frame (Frame&) const { } -} ConditionAt_syntax; +}; -static struct ConditionBeforeSyntax : public DeclareModel +struct ConditionBeforeSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionBefore (al); } @@ -636,9 +637,9 @@ True, iff the simulation time is before the specified time.") { } void load_frame (Frame&) const { } -} ConditionBefore_syntax; +}; -static struct ConditionAfterSyntax : public DeclareModel +struct ConditionAfterSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionAfter (al); } @@ -648,9 +649,9 @@ True, iff the simulation time is after the specified time.") { } void load_frame (Frame&) const { } -} ConditionAfter_syntax; +}; -static struct ConditionMicrosecondSyntax : public DeclareModel +struct ConditionMicrosecondSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionMicrosecond (al); } @@ -664,9 +665,9 @@ True, at the specified microsecond.") "Microsecond when the condition is true [0-999999]."); frame.order ("at"); } -} ConditionMicrosecond_syntax; +}; -static struct ConditionSecondSyntax : public DeclareModel +struct ConditionSecondSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionSecond (al); } @@ -681,9 +682,9 @@ True, at the specified second.") frame.set_check ("at", VCheck::valid_second ()); frame.order ("at"); } -} ConditionSecond_syntax; +}; -static struct ConditionMinuteSyntax : public DeclareModel +struct ConditionMinuteSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionMinute (al); } @@ -698,9 +699,9 @@ True, at the specified minute.") frame.set_check ("at", VCheck::valid_minute ()); frame.order ("at"); } -} ConditionMinute_syntax; +}; -static struct ConditionHourSyntax : public DeclareModel +struct ConditionHourSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionHour (al); } @@ -715,9 +716,9 @@ True, at the specified hour.") frame.set_check ("at", VCheck::valid_hour ()); frame.order ("at"); } -} ConditionHour_syntax; +}; -static struct ConditionMDaySyntax : public DeclareModel +struct ConditionMDaySyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionMDay (al); } @@ -732,9 +733,9 @@ True, at the specified day in the month.") frame.set_check ("at", VCheck::valid_mday ()); frame.order ("at"); } -} ConditionMDay_syntax; +}; -static struct ConditionYDaySyntax : public DeclareModel +struct ConditionYDaySyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionYDay (al); } @@ -750,9 +751,9 @@ True, at the specified julian day.") frame.set_check ("at", valid_jday); frame.order ("at"); } -} ConditionYDay_syntax; +}; -static struct ConditionMonthSyntax : public DeclareModel +struct ConditionMonthSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionMonth (al); } @@ -767,9 +768,9 @@ True, at the specified month.") frame.set_check ("at", VCheck::valid_month ()); frame.order ("at"); } -} ConditionMonth_syntax; +}; -static struct ConditionYearSyntax : public DeclareModel +struct ConditionYearSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionYear (al); } @@ -784,9 +785,9 @@ True, at the specified year.") frame.set_check ("at", VCheck::valid_year ()); frame.order ("at"); } -} ConditionYear_syntax; +}; -static struct ConditionTimestepSyntax : public DeclareModel +struct ConditionTimestepSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionTimestep (al); } @@ -805,7 +806,7 @@ in log files.") Timestep to use."); frame.order ("operand", "timestep"); } -} ConditionTimestep_syntax; +}; // The 'end' base model. @@ -841,7 +842,7 @@ struct ConditionEnd : public Condition // The 'hourly' model. -static struct ConditionHourlySyntax : public DeclareModel +struct ConditionHourlySyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionEnd (al, "h", &Time::hour); } @@ -852,11 +853,11 @@ static struct ConditionHourlySyntax : public DeclareModel void load_frame (Frame& frame) const { } -} ConditionHourly_syntax; +}; // The 'secondly' model. -static struct ConditionSecondlySyntax : public DeclareModel +struct ConditionSecondlySyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionEnd (al, "s", &Time::second); } @@ -867,11 +868,11 @@ static struct ConditionSecondlySyntax : public DeclareModel void load_frame (Frame& frame) const { } -} ConditionSecondly_syntax; +}; // The 'minutely' model. -static struct ConditionMinutelySyntax : public DeclareModel +struct ConditionMinutelySyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionEnd (al, "min", &Time::minute); } @@ -882,11 +883,11 @@ static struct ConditionMinutelySyntax : public DeclareModel void load_frame (Frame& frame) const { } -} ConditionMinutely_syntax; +}; // The 'daily' model. -static struct ConditionDailySyntax : public DeclareModel +struct ConditionDailySyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionEnd (al, "d", &Time::mday); } @@ -897,11 +898,11 @@ static struct ConditionDailySyntax : public DeclareModel void load_frame (Frame& frame) const { } -} ConditionDaily_syntax; +}; // The 'weekly' model. -static struct ConditionWeeklySyntax : public DeclareModel +struct ConditionWeeklySyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionEnd (al, "w", &Time::week); } @@ -912,11 +913,11 @@ static struct ConditionWeeklySyntax : public DeclareModel void load_frame (Frame& frame) const { } -} ConditionWeekly_syntax; +}; // The 'monthly' model. -static struct ConditionMonthlySyntax : public DeclareModel +struct ConditionMonthlySyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionEnd (al, "m", &Time::month); } @@ -927,11 +928,11 @@ static struct ConditionMonthlySyntax : public DeclareModel void load_frame (Frame& frame) const { } -} ConditionMonthly_syntax; +}; // The 'yearly' model. -static struct ConditionYearlySyntax : public DeclareModel +struct ConditionYearlySyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionEnd (al, "y", &Time::year); } @@ -942,7 +943,7 @@ static struct ConditionYearlySyntax : public DeclareModel void load_frame (Frame& frame) const { } -} ConditionYearly_syntax; +}; // The 'interval' base model. @@ -1012,7 +1013,7 @@ public: // The 'every' model. -static struct ConditionEverySyntax : public DeclareModel +struct ConditionEverySyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionInterval (al, submodel_value_block (al)); } @@ -1027,6 +1028,36 @@ static struct ConditionEverySyntax : public DeclareModel "Time for next match.", Time::load_syntax); } -} ConditionEvery_syntax; +}; + +void +register_condition_time_models () +{ + static ConditionMM_DDBase condition_mm_dd_base; + static ConditionMMDDSyntax condition_mmdd_syntax; + static ConditionBeforeMMDDSyntax condition_before_mmdd_syntax; + static ConditionAfterMMDDSyntax condition_after_mmdd_syntax; + static ConditionTimeBase condition_time_base; + static ConditionAtSyntax condition_at_syntax; + static ConditionBeforeSyntax condition_before_syntax; + static ConditionAfterSyntax condition_after_syntax; + static ConditionMicrosecondSyntax condition_microsecond_syntax; + static ConditionSecondSyntax condition_second_syntax; + static ConditionMinuteSyntax condition_minute_syntax; + static ConditionHourSyntax condition_hour_syntax; + static ConditionMDaySyntax condition_mday_syntax; + static ConditionYDaySyntax condition_yday_syntax; + static ConditionMonthSyntax condition_month_syntax; + static ConditionYearSyntax condition_year_syntax; + static ConditionTimestepSyntax condition_timestep_syntax; + static ConditionHourlySyntax condition_hourly_syntax; + static ConditionSecondlySyntax condition_secondly_syntax; + static ConditionMinutelySyntax condition_minutely_syntax; + static ConditionDailySyntax condition_daily_syntax; + static ConditionWeeklySyntax condition_weekly_syntax; + static ConditionMonthlySyntax condition_monthly_syntax; + static ConditionYearlySyntax condition_yearly_syntax; + static ConditionEverySyntax condition_every_syntax; +} // condition_time.C ends here. diff --git a/src/daisy/condition_walltime.C b/src/daisy/condition_walltime.C index b219340b6..ce7ea8fa3 100644 --- a/src/daisy/condition_walltime.C +++ b/src/daisy/condition_walltime.C @@ -21,7 +21,9 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #define BUILD_DLL + #include "daisy/condition.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" #include "object_model/frame.h" @@ -61,7 +63,7 @@ public: { } }; -static struct ConditionPeriodicSyntax : public DeclareModel +struct ConditionPeriodicSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionPeriodic (al); } @@ -77,7 +79,7 @@ it was true.") frame.set ("period", 1); frame.order ("period"); } -} ConditionPeriodic_syntax; +}; // The 'period' condition. @@ -116,7 +118,7 @@ public: { } }; -static struct ConditionWalltimeSyntax : public DeclareModel +struct ConditionWalltimeSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionWalltime (al); } @@ -129,6 +131,13 @@ it was true.") { Timestep::load_syntax (frame); } -} ConditionWalltime_syntax; +}; + +void +register_condition_walltime_models () +{ + static ConditionPeriodicSyntax condition_periodic_syntax; + static ConditionWalltimeSyntax condition_walltime_syntax; +} // condition_walltime.C ends here. diff --git a/src/daisy/condition_weather.C b/src/daisy/condition_weather.C index d5c439618..9d0a87130 100644 --- a/src/daisy/condition_weather.C +++ b/src/daisy/condition_weather.C @@ -24,6 +24,7 @@ #define BUILD_DLL #include "daisy/condition.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/field.h" #include "daisy/daisy.h" @@ -81,7 +82,7 @@ struct ConditionTSum : public Condition { } }; -static struct ConditionTSumAboveSyntax : public DeclareModel +struct ConditionTSumAboveSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionTSum (al); } @@ -133,7 +134,7 @@ Temeperature sum above which the condition becomes true."); Current temeprature sum since last reset."); frame.order ("TSum_limit"); } -} ConditionTSumAbove_syntax; +}; // The 'daily_air_temperature' Model. @@ -161,7 +162,7 @@ struct ConditionDailyAirTemperature : public Condition { } }; -static struct ConditionDailyAirTemperatureSyntax : public DeclareModel +struct ConditionDailyAirTemperatureSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionDailyAirTemperature (al); } @@ -175,7 +176,7 @@ Test if the daily air is warmer than the specified temperature.") Lowest air temperature for which the condition is true."); frame.order ("temperature"); } -} ConditionDailyAirTemperature_syntax; +}; // The 'daily_precipitation' Model. @@ -203,7 +204,7 @@ struct ConditionDailyPrecipitation : public Condition { } }; -static struct ConditionDailyPrecipitationSyntax : public DeclareModel +struct ConditionDailyPrecipitationSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ConditionDailyPrecipitation (al); } @@ -217,6 +218,14 @@ Test if the daily precipitation is warmer than the specified value.") Lowest precipitation for which the condition is true."); frame.order ("precipitation"); } -} ConditionDailyPrecipitation_syntax; +}; + +void +register_condition_weather_models () +{ + static ConditionTSumAboveSyntax condition_tsum_above_syntax; + static ConditionDailyAirTemperatureSyntax condition_daily_air_temperature_syntax; + static ConditionDailyPrecipitationSyntax condition_daily_precipitation_syntax; +} // condition_weather.C ends here. diff --git a/src/daisy/crop/canopy_simple.C b/src/daisy/crop/canopy_simple.C index a69b47b3c..691f60767 100644 --- a/src/daisy/crop/canopy_simple.C +++ b/src/daisy/crop/canopy_simple.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/canopy_simple.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/output/log.h" #include "object_model/block_submodel.h" #include "object_model/librarian.h" @@ -118,8 +119,13 @@ CanopySimple::CanopySimple (const BlockSubmodel& vl) CanopySimple::~CanopySimple () { } -static DeclareSubmodel -canopy_simple_submodel (CanopySimple::load_syntax, "CanopySimple", "\ +void +register_canopy_simple_models () +{ + static DeclareSubmodel + canopy_simple_submodel (CanopySimple::load_syntax, "CanopySimple", "\ Simple canopy model."); +} // canopy_simple.C ends here. + diff --git a/src/daisy/crop/canopy_std.C b/src/daisy/crop/canopy_std.C index e8771201a..2d57e7e9b 100644 --- a/src/daisy/crop/canopy_std.C +++ b/src/daisy/crop/canopy_std.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/canopy_std.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/output/log.h" #include "object_model/block_submodel.h" #include "util/mathlib.h" @@ -333,6 +334,10 @@ CanopyStandard::CanopyStandard (const BlockSubmodel& vl) CanopyStandard::~CanopyStandard () { } -static DeclareSubmodel -canopy_standard_submodel (CanopyStandard::load_syntax, "CanopyStandard", "\ +void +register_canopy_std_models () +{ + static DeclareSubmodel + canopy_standard_submodel (CanopyStandard::load_syntax, "CanopyStandard", "\ Standard canopy model."); +} diff --git a/src/daisy/crop/crop.C b/src/daisy/crop/crop.C index 458b0eac8..fbc198fb3 100644 --- a/src/daisy/crop/crop.C +++ b/src/daisy/crop/crop.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/crop/crop.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/organic_matter/om.h" #include "object_model/block_model.h" #include "util/mathlib.h" @@ -144,18 +145,40 @@ Crop::Crop (const BlockModel& al) Crop::~Crop () { } -static struct CropInit : public DeclareComponent +void +register_crop_models () { - CropInit () - : DeclareComponent (Crop::component, "\ + static struct CropInit : public DeclareComponent + { + CropInit () + : DeclareComponent (Crop::component, "\ The 'crop' component simulates a specific crop on the field, typically\n\ averaged over one square meter, not individual plants. Of particular\n\ interest is water and nitrogen uptake at different depths, and the\n\ vertical leaf area distribution, which are used for competition with\n\ other crops.") - { } - void load_frame (Frame& frame) const - { Model::load_model (frame); } -} Crop_init; + { } + void load_frame (Frame& frame) const + { Model::load_model (frame); } + } Crop_init; + + register_canopy_simple_models (); + register_canopy_std_models (); + register_crpn_models (); + register_harvesting_models (); + register_partition_models (); + register_production_models (); + register_phenology_models (); + register_photo_models (); + register_seed_models (); + register_stomatacon_models (); + register_vernalization_models (); + register_wse_models (); + register_cstage_models (); + register_crop_root_models (); + register_crop_simple_models (); + register_crop_standard_models (); +} // crop.C ends here. + diff --git a/src/daisy/crop/crop_simple.C b/src/daisy/crop/crop_simple.C index 31fb43fbb..a9443877e 100644 --- a/src/daisy/crop/crop_simple.C +++ b/src/daisy/crop/crop_simple.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/crop.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/crop/root/root_system.h" #include "daisy/crop/canopy_simple.h" #include "daisy/output/log.h" @@ -476,107 +477,112 @@ CropSimple::CropSimple (const BlockModel& al) CropSimple::~CropSimple () { } -static struct CropSimpleSyntax : public DeclareModel +void +register_crop_simple_models () { - Model* make (const BlockModel& al) const - { return new CropSimple (al); } - - static bool check_alist (const Metalib&, const Frame& al, Treelog& err) - { - bool ok = true; - if (!al.check ("LAIvsTS") && !al.check ("LAIvsDay")) - { - err.entry ("Must specify either 'LAIvsTS' or 'LAIvsDay'"); - ok = false; - } - else if (al.check ("LAIvsTS") && al.check ("LAIvsDay")) - { - err.entry ("Cannot specify both 'LAIvsTS' or 'LAIvsDay'"); - ok = false; - } - else - { - const PLF& plf = al.check ("LAIvsTS") - ? al.plf ("LAIvsTS") : al.plf ("LAIvsDay"); - try - { - plf.first_interesting (); - plf.last_interesting (); - plf.max_at (); - } - catch (...) - { - err.entry (std::string ("'") - + (al.check ("LAIvsTS") ? "LAIvsTS" : "LAIvsDay") - + "' has bogus value"); - ok = false; - } - } - - return ok; - } - - CropSimpleSyntax () - : DeclareModel (Crop::component, "simple", "Forced growth crop model.") - { } - void load_frame (Frame& frame) const + static struct CropSimpleSyntax : public DeclareModel { - frame.add_check (check_alist); - frame.declare ("LAIvsTS", "dg C d", "m^2/m^2", Attribute::OptionalConst, - "LAI as a function of T_sum"); - frame.declare ("LAIvsDay", "d", "m^2/m^2", Attribute::OptionalConst, - "LAI as a function of number of days since sowing."); - frame.declare ("forced_LAI", "m^2/m^2", Check::non_negative (), - Attribute::State, "\ + Model* make (const BlockModel& al) const + { return new CropSimple (al); } + + static bool check_alist (const Metalib&, const Frame& al, Treelog& err) + { + bool ok = true; + if (!al.check ("LAIvsTS") && !al.check ("LAIvsDay")) + { + err.entry ("Must specify either 'LAIvsTS' or 'LAIvsDay'"); + ok = false; + } + else if (al.check ("LAIvsTS") && al.check ("LAIvsDay")) + { + err.entry ("Cannot specify both 'LAIvsTS' or 'LAIvsDay'"); + ok = false; + } + else + { + const PLF& plf = al.check ("LAIvsTS") + ? al.plf ("LAIvsTS") : al.plf ("LAIvsDay"); + try + { + plf.first_interesting (); + plf.last_interesting (); + plf.max_at (); + } + catch (...) + { + err.entry (std::string ("'") + + (al.check ("LAIvsTS") ? "LAIvsTS" : "LAIvsDay") + + "' has bogus value"); + ok = false; + } + } + + return ok; + } + + CropSimpleSyntax () + : DeclareModel (Crop::component, "simple", "Forced growth crop model.") + { } + void load_frame (Frame& frame) const + { + frame.add_check (check_alist); + frame.declare ("LAIvsTS", "dg C d", "m^2/m^2", Attribute::OptionalConst, + "LAI as a function of T_sum"); + frame.declare ("LAIvsDay", "d", "m^2/m^2", Attribute::OptionalConst, + "LAI as a function of number of days since sowing."); + frame.declare ("forced_LAI", "m^2/m^2", Check::non_negative (), + Attribute::State, "\ Minimum LAI, automatically cleared when exceeded by 'LAIvsTS'."); - frame.set ("forced_LAI", 0.0); - frame.declare_submodule("Canopy", Attribute::State, "Canopy.", - CanopySimple::load_syntax); - frame.declare ("height_max", "cm", Check::non_negative (), Attribute::Const, - "Maximum height of plant, reached when flowering."); - frame.set ("height_max", 80.0); - frame.declare ("T_sum", "dg C d", Check::non_negative (), Attribute::State, - "Temperature sum since sowing (or spring)."); - frame.set ("T_sum", 0.0); - frame.declare ("day", "d", Check::non_negative (), Attribute::State, - "Number of days since sowing (or spring)."); - frame.set ("day", 0.0); - frame.declare_integer ("spring", Attribute::Const, 2, - "Zero 'T_sum' at this month and day."); - std::vector spring_time; - spring_time.push_back (3); - spring_time.push_back (1); - frame.set ("spring", spring_time); - frame.declare ("spring_LAI", "m^2/m^2", Check::non_negative (), Attribute::Const, - "Set 'forced_LAI' to this after spring clearence of 'T_sum'."); - frame.set ("spring_LAI", 0.1); - frame.declare_object ("Root", RootSystem::component, "Root system."); - frame.set ("Root", "classic"); - frame.declare ("root_DM", "Mg DM/ha", Check::non_negative (), Attribute::Const, - "Fully developed root drymatter."); - frame.set ("root_DM", 2.0); - frame.declare ("root_N", "kg N/ha", Check::non_negative (), Attribute::Const, - "Fully developed root N content."); - frame.set ("root_N", 20.0); - frame.declare_object ("root_am", AOM::component, - Attribute::Const, Attribute::Variable, "\ + frame.set ("forced_LAI", 0.0); + frame.declare_submodule("Canopy", Attribute::State, "Canopy.", + CanopySimple::load_syntax); + frame.declare ("height_max", "cm", Check::non_negative (), Attribute::Const, + "Maximum height of plant, reached when flowering."); + frame.set ("height_max", 80.0); + frame.declare ("T_sum", "dg C d", Check::non_negative (), Attribute::State, + "Temperature sum since sowing (or spring)."); + frame.set ("T_sum", 0.0); + frame.declare ("day", "d", Check::non_negative (), Attribute::State, + "Number of days since sowing (or spring)."); + frame.set ("day", 0.0); + frame.declare_integer ("spring", Attribute::Const, 2, + "Zero 'T_sum' at this month and day."); + std::vector spring_time; + spring_time.push_back (3); + spring_time.push_back (1); + frame.set ("spring", spring_time); + frame.declare ("spring_LAI", "m^2/m^2", Check::non_negative (), Attribute::Const, + "Set 'forced_LAI' to this after spring clearence of 'T_sum'."); + frame.set ("spring_LAI", 0.1); + frame.declare_object ("Root", RootSystem::component, "Root system."); + frame.set ("Root", "classic"); + frame.declare ("root_DM", "Mg DM/ha", Check::non_negative (), Attribute::Const, + "Fully developed root drymatter."); + frame.set ("root_DM", 2.0); + frame.declare ("root_N", "kg N/ha", Check::non_negative (), Attribute::Const, + "Fully developed root N content."); + frame.set ("root_N", 20.0); + frame.declare_object ("root_am", AOM::component, + Attribute::Const, Attribute::Variable, "\ Root AM parameters."); - frame.set_check ("root_am", AM::check_om_pools ()); - frame.set ("root_am", AM::default_AM ()); - frame.declare ("potential_N", "kg N/ha", Check::non_negative (), Attribute::Const, - "Potential N content at harvest."); - frame.declare ("N_demand", "g N/m^2", Attribute::LogOnly, - "Current potential N content."); - frame.declare ("N_actual", "g N/m^2", Check::non_negative (), Attribute::State, - "N uptake until now."); - frame.set ("N_actual", 0.0); - frame.declare ("N_b", "kg N/ha", Check::non_negative (), Attribute::Const, - "N uptake form parameter."); - frame.set ("N_b", 10.0); - frame.declare_fraction ("N_flowering", Attribute::Const, "\ + frame.set_check ("root_am", AM::check_om_pools ()); + frame.set ("root_am", AM::default_AM ()); + frame.declare ("potential_N", "kg N/ha", Check::non_negative (), Attribute::Const, + "Potential N content at harvest."); + frame.declare ("N_demand", "g N/m^2", Attribute::LogOnly, + "Current potential N content."); + frame.declare ("N_actual", "g N/m^2", Check::non_negative (), Attribute::State, + "N uptake until now."); + frame.set ("N_actual", 0.0); + frame.declare ("N_b", "kg N/ha", Check::non_negative (), Attribute::Const, + "N uptake form parameter."); + frame.set ("N_b", 10.0); + frame.declare_fraction ("N_flowering", Attribute::Const, "\ Fraction of potential N uptake reached at flowering."); - frame.set ("N_flowering", 0.9); - } -} simple_crop_syntax; + frame.set ("N_flowering", 0.9); + } + } simple_crop_syntax; +} // crop_simple.C ends here. + diff --git a/src/daisy/crop/crop_std.C b/src/daisy/crop/crop_std.C index 4f328b8cb..4c2d0faf6 100644 --- a/src/daisy/crop/crop_std.C +++ b/src/daisy/crop/crop_std.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/crop/crop.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/chemicals/chemistry.h" #include "daisy/crop/seed.h" #include "daisy/crop/root/root_system.h" @@ -925,100 +926,104 @@ CropStandard::CropStandard (const BlockModel& al) CropStandard::~CropStandard () { } -static struct CropStandardSyntax : public DeclareModel +void +register_crop_standard_models () { - Model* make (const BlockModel& al) const - { return new CropStandard (al); } - CropStandardSyntax () - : DeclareModel (Crop::component, "default", - "Standard Daisy crop model. Hansen, 1999.") - { } - void load_frame (Frame& frame) const + static struct CropStandardSyntax : public DeclareModel { - frame.declare_object ("Seed", Seed::component, - "Initial crop growth."); - frame.set ("Seed", "LAI"); - frame.declare_object ("Root", RootSystem::component, "Root system."); - frame.set ("Root", "classic"); - frame.declare_submodule ("Canopy", Attribute::State, - "Canopy.", CanopyStandard::load_syntax); - frame.declare_submodule ("Harvest", Attribute::State, - "Harvest parameters.", Harvesting::load_syntax); - frame.declare_submodule ("Prod", Attribute::State, - "Production.", Production::load_syntax); - frame.declare_submodule ("last_time", Attribute::OptionalState, - "The time of the previous timestep.\n\ + Model* make (const BlockModel& al) const + { return new CropStandard (al); } + CropStandardSyntax () + : DeclareModel (Crop::component, "default", + "Standard Daisy crop model. Hansen, 1999.") + { } + void load_frame (Frame& frame) const + { + frame.declare_object ("Seed", Seed::component, + "Initial crop growth."); + frame.set ("Seed", "LAI"); + frame.declare_object ("Root", RootSystem::component, "Root system."); + frame.set ("Root", "classic"); + frame.declare_submodule ("Canopy", Attribute::State, + "Canopy.", CanopyStandard::load_syntax); + frame.declare_submodule ("Harvest", Attribute::State, + "Harvest parameters.", Harvesting::load_syntax); + frame.declare_submodule ("Prod", Attribute::State, + "Production.", Production::load_syntax); + frame.declare_submodule ("last_time", Attribute::OptionalState, + "The time of the previous timestep.\n\ Don't set, calculated by Daisy.", - Time::load_syntax); - frame.declare_submodule ("sow_time", Attribute::OptionalState, - "The time the crop was sown.\n\ + Time::load_syntax); + frame.declare_submodule ("sow_time", Attribute::OptionalState, + "The time the crop was sown.\n\ Don't set, calculated by Daisy.", - Time::load_syntax); - frame.declare_submodule ("emerge_time", Attribute::OptionalState, - "The time the crop emerged.\n\ + Time::load_syntax); + frame.declare_submodule ("emerge_time", Attribute::OptionalState, + "The time the crop emerged.\n\ Don't set, calculated by Daisy.", - Time::load_syntax); - frame.declare_submodule ("flowering_time", Attribute::OptionalState, - "The time the crop flowered.\n\ + Time::load_syntax); + frame.declare_submodule ("flowering_time", Attribute::OptionalState, + "The time the crop flowered.\n\ Don't set, calculated by Daisy.", - Time::load_syntax); - frame.declare_submodule ("ripe_time", Attribute::OptionalState, - "The time the crop became ripe.\n\ + Time::load_syntax); + frame.declare_submodule ("ripe_time", Attribute::OptionalState, + "The time the crop became ripe.\n\ Don't set, calculated by Daisy.", - Time::load_syntax); - frame.declare_object ("Devel", Phenology::component, - "Development and phenology."); - frame.declare_object ("CStage", CStage::component, - "Phenological messages."); - frame.set ("CStage", "Daisy"); - frame.declare_submodule ("Partit", Attribute::State, - "Assimilate partitioning.", Partition::load_syntax); - frame.declare_object ("Vernal", Vernalization::component, - Attribute::State, Attribute::Singleton, "\ + Time::load_syntax); + frame.declare_object ("Devel", Phenology::component, + "Development and phenology."); + frame.declare_object ("CStage", CStage::component, + "Phenological messages."); + frame.set ("CStage", "Daisy"); + frame.declare_submodule ("Partit", Attribute::State, + "Assimilate partitioning.", Partition::load_syntax); + frame.declare_object ("Vernal", Vernalization::component, + Attribute::State, Attribute::Singleton, "\ Vernalization."); - frame.set ("Vernal", "none"); - frame.declare_object ("LeafPhot", Photo::component, - Attribute::Const, Attribute::Singleton, - "Leaf photosynthesis.\n\ + frame.set ("Vernal", "none"); + frame.declare_object ("LeafPhot", Photo::component, + Attribute::Const, Attribute::Singleton, + "Leaf photosynthesis.\n\ Note that if the selected radiation distribution model distinguishes\n\ between sunlit and shadow leaves, only the shadow leaves will be "); - frame.set ("LeafPhot", "GL"); - frame.declare_object ("sunlit", Photo::component, - Attribute::LogOnly, Attribute::Singleton, - "Leaf photosynthesis for sunlit leaves.\n\ + frame.set ("LeafPhot", "GL"); + frame.declare_object ("sunlit", Photo::component, + Attribute::LogOnly, Attribute::Singleton, + "Leaf photosynthesis for sunlit leaves.\n\ This will be zero if the selected radiation distribution model does not\n\ distinguish between sunlit and shadow leafs."); - frame.declare_object ("reserved", Photo::component, - Attribute::LogOnly, Attribute::Singleton, - "Leaf photosynthesis for reserved leaves.\n\ + frame.declare_object ("reserved", Photo::component, + Attribute::LogOnly, Attribute::Singleton, + "Leaf photosynthesis for reserved leaves.\n\ This is used for simulating \"patches\" in multi-crop systems, such as\n\ a clover-grass mixture. This is controled by the 'min_light_fraction'\n\ parameter."); - frame.declare_submodule ("CrpN", Attribute::State, - "Nitrogen parameters.", CrpN::load_syntax); - - frame.declare_object ("water_stress_effect", WSE::component, - Attribute::OptionalConst, Attribute::Singleton, - "Effect of water stress on production.\n\ + frame.declare_submodule ("CrpN", Attribute::State, + "Nitrogen parameters.", CrpN::load_syntax); + + frame.declare_object ("water_stress_effect", WSE::component, + Attribute::OptionalConst, Attribute::Singleton, + "Effect of water stress on production.\n\ By default, this will be 'none' iff the selected photosynthesis model\n\ does handle water stress implicitly, and 'full' otherwise."); - frame.declare_boolean ("enable_N_stress", Attribute::OptionalConst, - "Set this true to let nitrogen stress limit production.\n\ + frame.declare_boolean ("enable_N_stress", Attribute::OptionalConst, + "Set this true to let nitrogen stress limit production.\n\ By default, it will be true iff the selected photosynthesis model does\n \ handle nitrogen stress implicitly."); - frame.declare_fraction ("min_light_fraction", Attribute::Const, "\n\ + frame.declare_fraction ("min_light_fraction", Attribute::Const, "\n\ When multiple crops are competing for light, this parameter specifies\n\ a minumum amount of the light this crop will receive. The idea is\n\ that the field has patches where one crop is dominating, as specified\n\ by this parameter, and in these patches the crop will not have to\n\ compete for light. The crop still needs LAI in order to catch the\n\ light though. Competition for water and nutrients are unaffected."); - frame.set ("min_light_fraction", 0.0); - frame.declare_object ("RubiscoN", RubiscoN::component, "\ + frame.set ("min_light_fraction", 0.0); + frame.declare_object ("RubiscoN", RubiscoN::component, "\ Fraction of N in leaves that is photosynthetically active."); - frame.set ("RubiscoN", "default"); - } -} standard_crop_syntax; - + frame.set ("RubiscoN", "default"); + } + } standard_crop_syntax; +} // crop_std.C ends here. + diff --git a/src/daisy/crop/crpn.C b/src/daisy/crop/crpn.C index df4bae280..77ad1f459 100644 --- a/src/daisy/crop/crpn.C +++ b/src/daisy/crop/crpn.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/crpn.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/crop/production.h" #include "daisy/crop/root/root_system.h" #include "object_model/block_submodel.h" @@ -331,7 +332,6 @@ Actual nitrogen content of shoot divided by critical nitrogen content.\n\ Will be less than one for a stressed plant.\n\ For now, the storage organ is counted as part of the shoot."); - // Fixation. frame.declare ("DS_fixate", Attribute::None (), Attribute::Const, "DS at which to start fixation of atmospheric N."); @@ -390,8 +390,13 @@ CrpN::CrpN (const BlockSubmodel& al) CrpN::~CrpN () { } -static DeclareSubmodel -crpn_submodel (CrpN::load_syntax, "CrpN", "\ +void +register_crpn_models () +{ + static DeclareSubmodel + crpn_submodel (CrpN::load_syntax, "CrpN", "\ Default crop nitrogen parameters."); +} // crpn.C ends here. + diff --git a/src/daisy/crop/cstage.C b/src/daisy/crop/cstage.C index f1c75810d..511748b71 100644 --- a/src/daisy/crop/cstage.C +++ b/src/daisy/crop/cstage.C @@ -23,6 +23,7 @@ #define BUILD_DLL #include "daisy/crop/cstage.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "util/mathlib.h" #include "object_model/librarian.h" @@ -49,18 +50,6 @@ CStage::CStage (const BlockModel& al) CStage::~CStage () { } -static struct CStageInit : public DeclareComponent -{ - CStageInit () - : DeclareComponent (CStage::component, "\ -Crop phenological stage.\n\ -The 'default' crop model uses a continius development stage [-1:2]\n \ -in order to track the phenological age of a crop.\n\ -The 'cstage' library allows translation of the internal model to\n\ -other phenological models.") - { } -} CStage_init; - // The 'table' model. struct CStageTable : public CStage @@ -130,75 +119,89 @@ Message to display when entering this stage."); { } }; -static struct CStageTableSyntax : DeclareModel +// The 'Daisy' parameterization. + +// The 'BBCH' base parameterization. + +void +register_cstage_models () { - Model* make (const BlockModel& al) const - { return new CStageTable (al); } - CStageTableSyntax () - : DeclareModel (CStage::component, "table", "\ -A table mapping Daisy DS to other model.") - { } - void load_frame (Frame& frame) const + static struct CStageInit : public DeclareComponent + { + CStageInit () + : DeclareComponent (CStage::component, "\ +Crop phenological stage.\n\ +The 'default' crop model uses a continius development stage [-1:2]\n \ +in order to track the phenological age of a crop.\n\ +The 'cstage' library allows translation of the internal model to\n\ +other phenological models.") + { } + } CStage_init; + static struct CStageTableSyntax : DeclareModel { - frame.declare ("DS", "DS", Check::DS (), Attribute::State, "\ + Model* make (const BlockModel& al) const + { return new CStageTable (al); } + CStageTableSyntax () + : DeclareModel (CStage::component, "table", "\ +A table mapping Daisy DS to other model.") + { } + void load_frame (Frame& frame) const + { + frame.declare ("DS", "DS", Check::DS (), Attribute::State, "\ Last Daisy development stage."); - frame.set ("DS", -1.0); - frame.declare ("value", Attribute::Unknown (), Check::none (), - Attribute::State, "\ + frame.set ("DS", -1.0); + frame.declare ("value", Attribute::Unknown (), Check::none (), + Attribute::State, "\ Current stage in this phenological model."); - frame.declare_submodule_sequence ("table", Attribute::Const, "\ + frame.declare_submodule_sequence ("table", Attribute::Const, "\ List of Daisy and other model stages", CStageTable::Entry::load_syntax); - } -} CStageTable_syntax; - -// The 'Daisy' parameterization. - -static struct CStageDaisySyntax : public DeclareParam -{ - CStageDaisySyntax () - : DeclareParam (CStage::component, "Daisy", "table", "\ + } + } CStageTable_syntax; + static struct CStageDaisySyntax : public DeclareParam + { + CStageDaisySyntax () + : DeclareParam (CStage::component, "Daisy", "table", "\ DS 0, 1, and 2 have meaning.") - { } - void load_frame (Frame& frame) const + { } + void load_frame (Frame& frame) const + { + frame.set ("value", -1.0); + const FrameSubmodel& default_frame = *frame.default_frame ("table"); + boost::shared_ptr DS0 + (new FrameSubmodelValue (default_frame, Frame::parent_link)); + DS0->set ("DS", 0.0); + DS0->set ("value", 0.0); + DS0->set ("message", "Emerging"); + boost::shared_ptr DS1 + (new FrameSubmodelValue (default_frame, Frame::parent_link)); + DS1->set ("DS", 1.0); + DS1->set ("value", 1.0); + DS1->set ("message", "Flowering"); + boost::shared_ptr DS2 + (new FrameSubmodelValue (default_frame, Frame::parent_link)); + DS2->set ("DS", 2.0); + DS2->set ("value", 2.0); + DS2->set ("message", "Ripe"); + std::vector/**/> + sequence; + sequence.push_back (DS0); + sequence.push_back (DS1); + sequence.push_back (DS2); + frame.set ("table", sequence); + } + } CStageDaisy_syntax; + static struct CStageBBCHSyntax : public DeclareParam { - frame.set ("value", -1.0); - const FrameSubmodel& default_frame = *frame.default_frame ("table"); - boost::shared_ptr DS0 - (new FrameSubmodelValue (default_frame, Frame::parent_link)); - DS0->set ("DS", 0.0); - DS0->set ("value", 0.0); - DS0->set ("message", "Emerging"); - boost::shared_ptr DS1 - (new FrameSubmodelValue (default_frame, Frame::parent_link)); - DS1->set ("DS", 1.0); - DS1->set ("value", 1.0); - DS1->set ("message", "Flowering"); - boost::shared_ptr DS2 - (new FrameSubmodelValue (default_frame, Frame::parent_link)); - DS2->set ("DS", 2.0); - DS2->set ("value", 2.0); - DS2->set ("message", "Ripe"); - std::vector/**/> - sequence; - sequence.push_back (DS0); - sequence.push_back (DS1); - sequence.push_back (DS2); - frame.set ("table", sequence); - } -} CStageDaisy_syntax; - -// The 'BBCH' base parameterization. - -static struct CStageBBCHSyntax : public DeclareParam -{ - CStageBBCHSyntax () - : DeclareParam (CStage::component, "BBCH", "table", "\ + CStageBBCHSyntax () + : DeclareParam (CStage::component, "BBCH", "table", "\ Parent paramterization for all BBCH derived cropstage definitions.") - { } - void load_frame (Frame& frame) const - { - frame.set ("value", 0.0); - } -} CStageBBCH_syntax; + { } + void load_frame (Frame& frame) const + { + frame.set ("value", 0.0); + } + } CStageBBCH_syntax; +} // cstage.C ends here. + diff --git a/src/daisy/crop/harvesting.C b/src/daisy/crop/harvesting.C index e42290489..4b503c950 100644 --- a/src/daisy/crop/harvesting.C +++ b/src/daisy/crop/harvesting.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/harvesting.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/crop/production.h" #include "daisy/organic_matter/am.h" #include "daisy/organic_matter/aom.h" @@ -342,7 +343,6 @@ Harvesting::harvest (const symbol column_name, crop_name, root_symbol, AM::Unlocked /* inorganic */, msg); - // Add crop to residuals. double extra_C = production.CH2OPool * (12./30.); double extra_N = 0.0; @@ -439,7 +439,6 @@ Harvesting::harvest (const symbol column_name, daisy_assert (approximate (total_old_N, total_new_N + Crop_N_Yield + Crop_N_Loss)); - // Unlock and remove locked AM's. if (production.AM_root->locked ()) production.AM_root->unlock (); // Stored in organic matter. @@ -632,8 +631,13 @@ Harvesting::Harvesting (const Block& al) Harvesting::~Harvesting () { } -static DeclareSubmodel -soil_submodel (Harvesting::load_syntax, "Harvesting", "\ +void +register_harvesting_models () +{ + static DeclareSubmodel + soil_submodel (Harvesting::load_syntax, "Harvesting", "\ Information about what happens to the crop at harvest and cut."); +} // harvesting.C ends here. + diff --git a/src/daisy/crop/partition.C b/src/daisy/crop/partition.C index bab870300..2c858fcb7 100644 --- a/src/daisy/crop/partition.C +++ b/src/daisy/crop/partition.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/partition.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/plf.h" #include "object_model/librarian.h" #include "object_model/frame_submodel.h" @@ -178,13 +179,18 @@ Partition::Partition (const FrameSubmodel& al) Partition::~Partition () { } -static DeclareSubmodel -partition_submodel (Partition::load_syntax, "Partition", "\ +void +register_partition_models () +{ + static DeclareSubmodel + partition_submodel (Partition::load_syntax, "Partition", "\ Assimilate partitioning in the default crop model.\n\ The 'Root' parameter determine what fraction of the assimilate for growth\n\ goes to roots at a given development stage. The remaining assimilate goes\n\ to the shoot. The 'Leaf' and 'Stem' parameters determine what fraction of\n\ the shoot assimilate goes to the leaf and stem respectively. The remaining\n\ shoot assimilate will go to the storage organ."); +} // partition.C ends here. + diff --git a/src/daisy/crop/phenology.C b/src/daisy/crop/phenology.C index 793521a9f..3a28606ae 100644 --- a/src/daisy/crop/phenology.C +++ b/src/daisy/crop/phenology.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/phenology.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/output/log.h" #include "object_model/frame.h" @@ -85,26 +86,32 @@ Phenology::Phenology (const BlockModel& al) Phenology::~Phenology () { } -static struct PhenologyInit : public DeclareComponent +void +register_phenology_models () { - PhenologyInit () - : DeclareComponent (Phenology::component, "\ -The development process.") - { } - void load_frame (Frame& frame) const + static struct PhenologyInit : public DeclareComponent { - // Variables. - frame.declare ("DAP", "d", Attribute::State, "Days after planting."); - frame.set ("DAP", 0.0); - frame.declare ("DS", "DS", Attribute::State, - "Development stage [-1:2], 0 is emergence, 1 is flowering."); - frame.set ("DS", -1.0); - frame.declare ("partial_day_length", "h", Attribute::State, - "Number of light hours this day, so far."); - frame.set ("partial_day_length", 0.0); - frame.declare ("day_length", "h", Attribute::State, - "Number of light hours yesterday."); - frame.set ("day_length", 0.0); - } -} Phenology_init; + PhenologyInit () + : DeclareComponent (Phenology::component, "\ +The development process.") + { } + void load_frame (Frame& frame) const + { + // Variables. + frame.declare ("DAP", "d", Attribute::State, "Days after planting."); + frame.set ("DAP", 0.0); + frame.declare ("DS", "DS", Attribute::State, + "Development stage [-1:2], 0 is emergence, 1 is flowering."); + frame.set ("DS", -1.0); + frame.declare ("partial_day_length", "h", Attribute::State, + "Number of light hours this day, so far."); + frame.set ("partial_day_length", 0.0); + frame.declare ("day_length", "h", Attribute::State, + "Number of light hours yesterday."); + frame.set ("day_length", 0.0); + } + } Phenology_init; + register_phenology_standard_models (); + register_phenology_TSum_models (); +} diff --git a/src/daisy/crop/phenology_TSum.C b/src/daisy/crop/phenology_TSum.C index ffd03b2b8..c5e02d1e4 100644 --- a/src/daisy/crop/phenology_TSum.C +++ b/src/daisy/crop/phenology_TSum.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/phenology.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/crop/production.h" #include "daisy/crop/vernalization.h" @@ -112,40 +113,44 @@ PhenologyTSum::PhenologyTSum (const BlockModel& al) RepThrs (al.number ("RepThrs")) { } -static struct PhenologyTSumSyntax : public DeclareModel +void +register_phenology_TSum_models () { - Model* make (const BlockModel& al) const - { return new PhenologyTSum (al); } - - PhenologyTSumSyntax () - : DeclareModel (Phenology::component, "TSum", - "Crop phenology model purely based on temperature sums.\n\ + static struct PhenologyTSumSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new PhenologyTSum (al); } + + PhenologyTSumSyntax () + : DeclareModel (Phenology::component, "TSum", + "Crop phenology model purely based on temperature sums.\n\ The length of emergence, and the vegetative and reproductive fase are all\n\ based on the specified temperature sums. Temperatures below the specified\n\ thresholds do not contribute to the temeprature sum.\n\ Cut stress and leaf respiration does not affect this phenology model.") - { } - void load_frame (Frame& frame) const - { - // Parameters. - frame.declare ("EmrTSum", "dg C d", Attribute::Const, - "Soil temperature sum at emergence."); - frame.declare ("EmrThrs", "dg C", Attribute::Const, - "Minimum soil temperature for emergence.\n\ + { } + void load_frame (Frame& frame) const + { + // Parameters. + frame.declare ("EmrTSum", "dg C d", Attribute::Const, + "Soil temperature sum at emergence."); + frame.declare ("EmrThrs", "dg C", Attribute::Const, + "Minimum soil temperature for emergence.\n\ Temperature below this will not count in the sum."); - frame.set ("EmrThrs", 0.0); - frame.declare ("VegTSum", "dg C d", Attribute::Const, - "Air temperature sum for vegetative fase."); - frame.declare ("VegThrs", "dg C", Attribute::Const, - "Minimum air temperature for development in vegetative fase.\n\ + frame.set ("EmrThrs", 0.0); + frame.declare ("VegTSum", "dg C d", Attribute::Const, + "Air temperature sum for vegetative fase."); + frame.declare ("VegThrs", "dg C", Attribute::Const, + "Minimum air temperature for development in vegetative fase.\n\ Temperature below this will not count in the sum."); - frame.set ("VegThrs", 0.0); - frame.declare ("RepTSum", "dg C d", Attribute::Const, - "Air temperature sum for vegetative fase."); - frame.declare ("RepThrs", "dg C", Attribute::Const, - "Minimum air temperature for development in vegetative fase.\n\ + frame.set ("VegThrs", 0.0); + frame.declare ("RepTSum", "dg C d", Attribute::Const, + "Air temperature sum for vegetative fase."); + frame.declare ("RepThrs", "dg C", Attribute::Const, + "Minimum air temperature for development in vegetative fase.\n\ Temperature below this will not count in the sum."); - frame.set ("RepThrs", 0.0); - - } -} PhenologyTSum_syntax; + frame.set ("RepThrs", 0.0); + + } + } PhenologyTSum_syntax; +} diff --git a/src/daisy/crop/phenology_std.C b/src/daisy/crop/phenology_std.C index a499696b5..b538c8bc0 100644 --- a/src/daisy/crop/phenology_std.C +++ b/src/daisy/crop/phenology_std.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/phenology.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/crop/production.h" #include "daisy/crop/vernalization.h" @@ -212,57 +213,61 @@ PhenologyStandard::PhenologyStandard (const BlockModel& al) defined_until_ds (al.number ("defined_until_ds")) { } -static struct PhenologyStandardSyntax : public DeclareModel +void +register_phenology_standard_models () { - Model* make (const BlockModel& al) const - { return new PhenologyStandard (al); } - - PhenologyStandardSyntax () - : DeclareModel (Phenology::component, "default", - "Default crop phenology model.") - { } - void load_frame (Frame& frame) const + static struct PhenologyStandardSyntax : public DeclareModel { - // Parameters. - frame.declare_object ("modify_DS", Number::component, - Attribute::OptionalConst, Attribute::Singleton, "\ + Model* make (const BlockModel& al) const + { return new PhenologyStandard (al); } + + PhenologyStandardSyntax () + : DeclareModel (Phenology::component, "default", + "Default crop phenology model.") + { } + void load_frame (Frame& frame) const + { + // Parameters. + frame.declare_object ("modify_DS", Number::component, + Attribute::OptionalConst, Attribute::Singleton, "\ Expression for modifying DS.\n\ The original value is available as a free varible named 'x'.\n\ The expression will be used as a new value for DS."); - frame.declare ("EmrTSum", "dg C d", Attribute::Const, - "Soil temperature sum at emergence."); - frame.declare ("EmrSMF", "cm", Attribute::None (), Attribute::Const, - "Soil moisture (h-function) effect on emergence."); - PLF SMF; - SMF.add (-1000.0, 1.00); - SMF.add (-150.0, 1.00); - SMF.add (-50.00, 1.00); - SMF.add (-30.00, 1.00); - frame.set ("EmrSMF",SMF); - frame.declare ("DS_Emr", "DS", Attribute::Const, - "Development stage at emergence."); - frame.set ("DS_Emr", 0.01); - frame.declare ("DSRate1", "DS/d", Attribute::Const, - "Development rate in the vegetative stage."); - frame.declare ("DSRate2", "DS/d", Attribute::Const, - "Development rate in the reproductive stage."); - frame.declare ("TempEff1", "dg C", Attribute::None (), Attribute::Const, - "Temperature effect, vegetative stage."); - frame.declare ("TempEff2", "dg C", Attribute::None (), Attribute::Const, - "Temperature effect, reproductive stage."); - frame.declare ("PhotEff1", "h", Attribute::None (), Attribute::Const, - "Photoperiode effect, vegetative stage."); - frame.declare ("DSMature", "DS", Attribute::Const, - "Development stage at maturation."); - frame.set ("DSMature", 2.0); - frame.declare ("DSRepeat", "DS", Attribute::Const, - "Development stage when DS set back is activated."); - frame.set ("DSRepeat", 4.0); - frame.declare ("DSSetBack", "DS", Attribute::Const, - "Development stage set back at DSRepeat."); - frame.set ("DSSetBack", 1.7); - frame.declare ("defined_until_ds", "DS", Attribute::Const, "\ + frame.declare ("EmrTSum", "dg C d", Attribute::Const, + "Soil temperature sum at emergence."); + frame.declare ("EmrSMF", "cm", Attribute::None (), Attribute::Const, + "Soil moisture (h-function) effect on emergence."); + PLF SMF; + SMF.add (-1000.0, 1.00); + SMF.add (-150.0, 1.00); + SMF.add (-50.00, 1.00); + SMF.add (-30.00, 1.00); + frame.set ("EmrSMF",SMF); + frame.declare ("DS_Emr", "DS", Attribute::Const, + "Development stage at emergence."); + frame.set ("DS_Emr", 0.01); + frame.declare ("DSRate1", "DS/d", Attribute::Const, + "Development rate in the vegetative stage."); + frame.declare ("DSRate2", "DS/d", Attribute::Const, + "Development rate in the reproductive stage."); + frame.declare ("TempEff1", "dg C", Attribute::None (), Attribute::Const, + "Temperature effect, vegetative stage."); + frame.declare ("TempEff2", "dg C", Attribute::None (), Attribute::Const, + "Temperature effect, reproductive stage."); + frame.declare ("PhotEff1", "h", Attribute::None (), Attribute::Const, + "Photoperiode effect, vegetative stage."); + frame.declare ("DSMature", "DS", Attribute::Const, + "Development stage at maturation."); + frame.set ("DSMature", 2.0); + frame.declare ("DSRepeat", "DS", Attribute::Const, + "Development stage when DS set back is activated."); + frame.set ("DSRepeat", 4.0); + frame.declare ("DSSetBack", "DS", Attribute::Const, + "Development stage set back at DSRepeat."); + frame.set ("DSSetBack", 1.7); + frame.declare ("defined_until_ds", "DS", Attribute::Const, "\ This parameterization is only valid until the specified development state."); - frame.set ("defined_until_ds", 2.0); - } -} PhenologyStandard_syntax; + frame.set ("defined_until_ds", 2.0); + } + } PhenologyStandard_syntax; +} diff --git a/src/daisy/crop/photo.C b/src/daisy/crop/photo.C index 689c1590d..85f8971d3 100644 --- a/src/daisy/crop/photo.C +++ b/src/daisy/crop/photo.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/crop/photo.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" #include "object_model/check.h" @@ -51,20 +52,30 @@ Photo::Photo (const BlockModel& al) Photo::~Photo () { } -static struct PhotoInit : public DeclareComponent +void +register_photo_models () { - void load_frame (Frame& frame) const - { - Model::load_model (frame); - frame.declare ("min_PAR", "W/m^2", Check::non_negative (), Attribute::Const, - "Minimum PAR at top of canopy for photosynthesis.\n\ + static struct PhotoInit : public DeclareComponent + { + void load_frame (Frame& frame) const + { + Model::load_model (frame); + frame.declare ("min_PAR", "W/m^2", Check::non_negative (), Attribute::Const, + "Minimum PAR at top of canopy for photosynthesis.\n\ If radiation is below this amount, photosynthesis will be disabled."); - frame.set ("min_PAR", 0.1); - } - PhotoInit () - : DeclareComponent (Photo::component, "\ + frame.set ("min_PAR", 0.1); + } + PhotoInit () + : DeclareComponent (Photo::component, "\ Leaf photosynthesis.") - { } -} Photo_init; + { } + } Photo_init; + + register_photo_Farquhar_models (); + register_photo_FCC3_models (); + register_photo_FCC4_models (); + register_photo_GL_models (); +} // photo.C ends here. + diff --git a/src/daisy/crop/photo_FCC3.C b/src/daisy/crop/photo_FCC3.C index 052a4a82e..4106888f6 100644 --- a/src/daisy/crop/photo_FCC3.C +++ b/src/daisy/crop/photo_FCC3.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/photo_Farquhar.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/crop/root/rubiscoNdist.h" #include "daisy/upper_boundary/bioclimate/bioclimate.h" @@ -290,87 +291,92 @@ PhotoFCC3::respiration_rate (const double Vm_25, const double Tl) const return rd; } -static struct Photo_FCC3Syntax : public DeclareModel +void +register_photo_FCC3_models () { - Model* make (const BlockModel& al) const - { return new PhotoFCC3 (al); } - Photo_FCC3Syntax () - : DeclareModel (Photo::component, "FC_C3", "Farquhar", "\ -Photosynthesis for C3 crops described by Faquhar et al. (1980).") - { } - void load_frame (Frame& frame) const + static struct Photo_FCC3Syntax : public DeclareModel { - frame.set_strings ("cite", "pf1997simple"); - frame.declare ("TempEff", "dg C", Attribute::None (), - Check::non_negative (), Attribute::Const, - "Temperature factor for assimilate production."); - - frame.declare ("Kc25", "Pa", Check::positive (), Attribute::Const, - "Micahyaelis-Menten constant of Rubisco for CO2. Kc25 = 40.4 Pa for wheat (Collatz et al.,1991) "); - - frame.set ("Kc25", 40.4); - - frame.declare ("Ko25", "Pa", Check::positive (), Attribute::Const, - "Micahaelis-Menten constant of Rubisco for O2 at 25 degrees. Ko25 = 24800 Pa for wheat (Collatz et al., 1991)"); - frame.set ("Ko25", 24800.); - - frame.declare ("S", "J/mol/K", Check::positive (), Attribute::Const, - "Electron transport temperature response parameter,(De Pury & Farquhar, 1997)"); - frame.set ("S", 710.); - - frame.declare ("H", "J/mol", Check::positive (), Attribute::Const, - "Curvature parameter of Jm, (De Pury & Farquhar, 1997)"); - frame.set ("H", 220000.); - - frame.declare ("c_Vm", Attribute::Unknown (), Check::positive (), Attribute::Const, - "Temperature scaling constant for Vmax. c_Vm, = 26.35 (Bernacchi et al., 2001)"); - frame.set ("c_Vm", 26.35); - - frame.declare ("Ea_Vm", "J/mol", Check::positive (), Attribute::Const, - "Activation energy for Vmax. Ea_Vm = 65330 J/mol (Ball, 1988)"); - frame.set ("Ea_Vm", 65330.); - - frame.declare ("Eda_Vm", "J/mol", Check::positive (), Attribute::Const, - "Deactimation energy for Vmax. Eda_Vm = 202900 J/mol"); - frame.set ("Eda_Vm", 202900.); - - frame.declare ("Ea_Jm", "J/mol", Check::positive (), Attribute::Const, - "Actimation energy for Jm. Ea_Jm = 37000 J/mol (Farquhar et al., 1980)."); - frame.set ("Ea_Jm", 37000.); - - frame.declare ("Ea_ko", "J/mol", Check::positive (), Attribute::Const, - "Actimation energy for ko. Ea_ko 0 36000 J/mol (Badger & Collatz, 1977)."); - frame.set ("Ea_ko", 36000.); - - frame.declare ("Ea_kc", "J/mol", Check::positive (), Attribute::Const, - "Actimation energy for kc. Ea_kc = 59400 J/mol (Badger & Collatz, 1977)"); - frame.set ("Ea_kc", 59400.); - - frame.declare ("Ea_rd", "J/mol", Check::positive (), Attribute::Const, - "Actimation energy for rd. Ea_rd = 66400 J/mol (Farquhar et al., 1980)"); - frame.set ("Ea_rd", 66400.); - - frame.declare ("Sv", "J/mol/K", Check::positive (), Attribute::Const, - "Entropy term. Sv = 650 J/mol/K"); - frame.set ("Sv", 650.); + Model* make (const BlockModel& al) const + { return new PhotoFCC3 (al); } + Photo_FCC3Syntax () + : DeclareModel (Photo::component, "FC_C3", "Farquhar", "\ +Photosynthesis for C3 crops described by Faquhar et al. (1980).") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "pf1997simple"); + frame.declare ("TempEff", "dg C", Attribute::None (), + Check::non_negative (), Attribute::Const, + "Temperature factor for assimilate production."); + + frame.declare ("Kc25", "Pa", Check::positive (), Attribute::Const, + "Micahyaelis-Menten constant of Rubisco for CO2. Kc25 = 40.4 Pa for wheat (Collatz et al.,1991) "); + + frame.set ("Kc25", 40.4); - frame.declare ("theta", Attribute::Unknown (), Check::positive (), Attribute::Const, - "Curvature of leaf response of electron transport to irradiance, (De Pury & Farquhar, 1997"); - frame.set ("theta", 0.7); + frame.declare ("Ko25", "Pa", Check::positive (), Attribute::Const, + "Micahaelis-Menten constant of Rubisco for O2 at 25 degrees. Ko25 = 24800 Pa for wheat (Collatz et al., 1991)"); + frame.set ("Ko25", 24800.); + + frame.declare ("S", "J/mol/K", Check::positive (), Attribute::Const, + "Electron transport temperature response parameter,(De Pury & Farquhar, 1997)"); + frame.set ("S", 710.); + + frame.declare ("H", "J/mol", Check::positive (), Attribute::Const, + "Curvature parameter of Jm, (De Pury & Farquhar, 1997)"); + frame.set ("H", 220000.); + + frame.declare ("c_Vm", Attribute::Unknown (), Check::positive (), Attribute::Const, + "Temperature scaling constant for Vmax. c_Vm, = 26.35 (Bernacchi et al., 2001)"); + frame.set ("c_Vm", 26.35); + + frame.declare ("Ea_Vm", "J/mol", Check::positive (), Attribute::Const, + "Activation energy for Vmax. Ea_Vm = 65330 J/mol (Ball, 1988)"); + frame.set ("Ea_Vm", 65330.); + + frame.declare ("Eda_Vm", "J/mol", Check::positive (), Attribute::Const, + "Deactimation energy for Vmax. Eda_Vm = 202900 J/mol"); + frame.set ("Eda_Vm", 202900.); + + frame.declare ("Ea_Jm", "J/mol", Check::positive (), Attribute::Const, + "Actimation energy for Jm. Ea_Jm = 37000 J/mol (Farquhar et al., 1980)."); + frame.set ("Ea_Jm", 37000.); + + frame.declare ("Ea_ko", "J/mol", Check::positive (), Attribute::Const, + "Actimation energy for ko. Ea_ko 0 36000 J/mol (Badger & Collatz, 1977)."); + frame.set ("Ea_ko", 36000.); + + frame.declare ("Ea_kc", "J/mol", Check::positive (), Attribute::Const, + "Actimation energy for kc. Ea_kc = 59400 J/mol (Badger & Collatz, 1977)"); + frame.set ("Ea_kc", 59400.); + + frame.declare ("Ea_rd", "J/mol", Check::positive (), Attribute::Const, + "Actimation energy for rd. Ea_rd = 66400 J/mol (Farquhar et al., 1980)"); + frame.set ("Ea_rd", 66400.); + + frame.declare ("Sv", "J/mol/K", Check::positive (), Attribute::Const, + "Entropy term. Sv = 650 J/mol/K"); + frame.set ("Sv", 650.); - frame.declare ("beta", Attribute::Unknown (), Check::positive (), Attribute::Const, - "Curvature, Collatz et al., 1991"); - frame.set ("beta", 0.95); - - frame.declare ("alfa", "mol/mol", Check::positive (), Attribute::Const, - "Fraction of PAR effectively absorbed by PSII, "); - frame.set ("alfa", 0.08); - - // Ball & Berry parameters: - // frame.set ("m", 11.0); - // frame.set ("b", 0.01); - } - -} PhotoFCC3_syntax; + frame.declare ("theta", Attribute::Unknown (), Check::positive (), Attribute::Const, + "Curvature of leaf response of electron transport to irradiance, (De Pury & Farquhar, 1997"); + frame.set ("theta", 0.7); + + frame.declare ("beta", Attribute::Unknown (), Check::positive (), Attribute::Const, + "Curvature, Collatz et al., 1991"); + frame.set ("beta", 0.95); + + frame.declare ("alfa", "mol/mol", Check::positive (), Attribute::Const, + "Fraction of PAR effectively absorbed by PSII, "); + frame.set ("alfa", 0.08); + + // Ball & Berry parameters: + // frame.set ("m", 11.0); + // frame.set ("b", 0.01); + } + + } PhotoFCC3_syntax; +} // photo_FCC3.C ends here. + diff --git a/src/daisy/crop/photo_FCC4.C b/src/daisy/crop/photo_FCC4.C index 986d55a12..a64385c09 100644 --- a/src/daisy/crop/photo_FCC4.C +++ b/src/daisy/crop/photo_FCC4.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/photo_Farquhar.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/crop/root/rubiscoNdist.h" #include "daisy/upper_boundary/bioclimate/bioclimate.h" #include "daisy/crop/canopy_std.h" @@ -177,53 +178,58 @@ PhotoFCC4::respiration_rate (const double Vm_25, const double Tl) const return rd; } -static struct Photo_FCC4Syntax : public DeclareModel +void +register_photo_FCC4_models () { - Model* make (const BlockModel& al) const - { return new PhotoFCC4 (al); } - Photo_FCC4Syntax () - : DeclareModel (Photo::component, "FC_C4", "Farquhar", "\ -C4 photosynthesis and stomatal conductance model by Collatz et al., 1992.") - { } - void load_frame (Frame& frame) const + static struct Photo_FCC4Syntax : public DeclareModel { - frame.declare ("Q10k", Attribute::Unknown (), Check::positive (), Attribute::Const, - "Q10k = 1.8 (Collatz et al., 1992)"); - frame.set ("Q10k", 1.8); - - frame.declare ("Q10vm", Attribute::Unknown (), Check::positive (), Attribute::Const, - "Q10vm = 2.4 (Collatz et al., 1992)"); - frame.set ("Q10vm", 2.4); - - frame.declare ("Q10rd", Attribute::Unknown (), Check::positive (), Attribute::Const, - "Q10rd = 2.0 (Collatz et al., 1992)"); - frame.set ("Q10rd", 2.0); - - frame.declare ("kj", Attribute::Unknown (), Check::positive (), Attribute::Const, - "Initial slope of photosynthetic CO2 response, kj = 0.6 mol/m^2/s (Collatz et al., 1992)"); - frame.set ("kj", 0.6); - - frame.declare ("alpha", "mol/mol", Check::positive (), Attribute::Const, - "Initial slope of photosynthetic light response. alpha = 0.04 (Collatz et al., 1992)"); - frame.set ("alpha", 0.04); - - frame.declare ("paab", Attribute::Unknown (), Check::positive (), Attribute::Const, - "Leaf absorbtivity to PAR. paab = 0.86 (Collatz et al., 1992)"); - frame.set ("paab", 0.86); - - frame.declare ("theta", Attribute::Unknown (), Check::positive (), Attribute::Const, - "Curvature parameter"); - frame.set ("theta", 0.83); - - frame.declare ("beta", Attribute::Unknown (), Check::positive (), Attribute::Const, - "Curvanture parameter"); - frame.set ("beta", 0.93); - - // Ball & Berry parameters: - // frame.set ("m", 3.0); - // frame.set ("b", 0.08); - } - -} PhotoFCC4_syntax; + Model* make (const BlockModel& al) const + { return new PhotoFCC4 (al); } + Photo_FCC4Syntax () + : DeclareModel (Photo::component, "FC_C4", "Farquhar", "\ +C4 photosynthesis and stomatal conductance model by Collatz et al., 1992.") + { } + void load_frame (Frame& frame) const + { + frame.declare ("Q10k", Attribute::Unknown (), Check::positive (), Attribute::Const, + "Q10k = 1.8 (Collatz et al., 1992)"); + frame.set ("Q10k", 1.8); + + frame.declare ("Q10vm", Attribute::Unknown (), Check::positive (), Attribute::Const, + "Q10vm = 2.4 (Collatz et al., 1992)"); + frame.set ("Q10vm", 2.4); + + frame.declare ("Q10rd", Attribute::Unknown (), Check::positive (), Attribute::Const, + "Q10rd = 2.0 (Collatz et al., 1992)"); + frame.set ("Q10rd", 2.0); + + frame.declare ("kj", Attribute::Unknown (), Check::positive (), Attribute::Const, + "Initial slope of photosynthetic CO2 response, kj = 0.6 mol/m^2/s (Collatz et al., 1992)"); + frame.set ("kj", 0.6); + + frame.declare ("alpha", "mol/mol", Check::positive (), Attribute::Const, + "Initial slope of photosynthetic light response. alpha = 0.04 (Collatz et al., 1992)"); + frame.set ("alpha", 0.04); + + frame.declare ("paab", Attribute::Unknown (), Check::positive (), Attribute::Const, + "Leaf absorbtivity to PAR. paab = 0.86 (Collatz et al., 1992)"); + frame.set ("paab", 0.86); + + frame.declare ("theta", Attribute::Unknown (), Check::positive (), Attribute::Const, + "Curvature parameter"); + frame.set ("theta", 0.83); + + frame.declare ("beta", Attribute::Unknown (), Check::positive (), Attribute::Const, + "Curvanture parameter"); + frame.set ("beta", 0.93); + + // Ball & Berry parameters: + // frame.set ("m", 3.0); + // frame.set ("b", 0.08); + } + + } PhotoFCC4_syntax; +} // photo_FCC4 ends here. + diff --git a/src/daisy/crop/photo_Farquhar.C b/src/daisy/crop/photo_Farquhar.C index 68c674d7f..0751201e0 100644 --- a/src/daisy/crop/photo_Farquhar.C +++ b/src/daisy/crop/photo_Farquhar.C @@ -23,6 +23,7 @@ #define BUILD_DLL #include "daisy/crop/photo_Farquhar.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/crop/root/rubiscoNdist.h" #include "daisy/upper_boundary/bioclimate/resistance.h" @@ -65,7 +66,6 @@ PhotoFarquhar::crop_Vmax_total (const std::vector& rubisco_Ndist /* [mol cropVm[i] = Xn * rubisco_Ndist[i]; //[mol/m² leaf/s] } - // Arrhenius temperature response function used for Kc, Ko og Gamma double PhotoFarquhar::Arrhenius (const double k25, const double Ea, const double T) const @@ -191,7 +191,6 @@ PhotoFarquhar::assimilate (const Units& units, cropN /*[g/m²area]*/, msg); crop_Vmax_total (rubisco_Ndist, crop_Vm_total); - // Net photosynthesis (for logging) while (pn_vector.size () < No) pn_vector.push_back (0.0);// @@ -454,75 +453,80 @@ bool PhotoFarquhar::handle_water_stress () const { return true; } -static struct PhotoFarquharSyntax : DeclareBase +void +register_photo_Farquhar_models () { - PhotoFarquharSyntax () - : DeclareBase (Photo::component, "Farquhar", "\ + static struct PhotoFarquharSyntax : DeclareBase + { + PhotoFarquharSyntax () + : DeclareBase (Photo::component, "Farquhar", "\ Base parameterization for Farquhar derived photosynthesis models.\n\ \n\ Farquhar et al. (1980) photosynthesis and Ball et al. (1987)\n\ stomataconductance model coupled as described by Collatz et al., 1991.") - { } - void load_frame (Frame& frame) const - { - frame.declare ("Xn", "mol/mol/s", Check::positive (), Attribute::Const, - "Slope of relationship between leaf rubisco N and Vmax.\n\ + { } + void load_frame (Frame& frame) const + { + frame.declare ("Xn", "mol/mol/s", Check::positive (), Attribute::Const, + "Slope of relationship between leaf rubisco N and Vmax.\n\ Xn = 1.16E-3 mol/mol/s for wheat (de Pury & Farquhar, 1997)"); - frame.set_cited ("Xn", 1.16e-3, "page 550", "pf1997simple"); - - frame.declare ("Gamma25", "Pa", Check::positive (), Attribute::Const, - "CO2 compensation point of photosynthesis.\n\ + frame.set_cited ("Xn", 1.16e-3, "page 550", "pf1997simple"); + + frame.declare ("Gamma25", "Pa", Check::positive (), Attribute::Const, + "CO2 compensation point of photosynthesis.\n\ Gamma25 = 3.69 Pa for wheat (Collatz et al., 1991)"); - frame.set ("Gamma25", 3.69); - - frame.declare ("Ea_Gamma", "J/mol", Check::positive (), Attribute::Const, - "Actimation energy for Gamma. Ea_Gamma = 29000 (Jordan & Ogren, 1984)"); - frame.set ("Ea_Gamma", 29000.); - - //log variables - frame.declare ("ABA_effect", Attribute::None (), Attribute::LogOnly, - "Water stress effect induced by ABA and crown water potential"); - frame.declare ("ci_vector", "Pa", Attribute::LogOnly, Attribute::CanopyCells, "CO2 pressure in Stomatal in each layer."); - frame.declare ("Vm_vector", "mmol/m^2/s", Attribute::LogOnly, Attribute::CanopyCells, "Photosynthetic capacity in each layer."); - frame.declare ("Jm_vector", "mmol/m^2/s", Attribute::LogOnly, Attribute::CanopyCells, "Potential rate of electron transport in each layer."); - frame.declare ("pn_vector", "mol/m^2 leaf/s", - Attribute::LogOnly, Attribute::CanopyCells, "\ + frame.set ("Gamma25", 3.69); + + frame.declare ("Ea_Gamma", "J/mol", Check::positive (), Attribute::Const, + "Actimation energy for Gamma. Ea_Gamma = 29000 (Jordan & Ogren, 1984)"); + frame.set ("Ea_Gamma", 29000.); + + //log variables + frame.declare ("ABA_effect", Attribute::None (), Attribute::LogOnly, + "Water stress effect induced by ABA and crown water potential"); + frame.declare ("ci_vector", "Pa", Attribute::LogOnly, Attribute::CanopyCells, "CO2 pressure in Stomatal in each layer."); + frame.declare ("Vm_vector", "mmol/m^2/s", Attribute::LogOnly, Attribute::CanopyCells, "Photosynthetic capacity in each layer."); + frame.declare ("Jm_vector", "mmol/m^2/s", Attribute::LogOnly, Attribute::CanopyCells, "Potential rate of electron transport in each layer."); + frame.declare ("pn_vector", "mol/m^2 leaf/s", + Attribute::LogOnly, Attribute::CanopyCells, "\ Net photosynthesis."); - frame.declare ("cs_vector", "Pa", - Attribute::LogOnly, Attribute::CanopyCells, "\ + frame.declare ("cs_vector", "Pa", + Attribute::LogOnly, Attribute::CanopyCells, "\ CO2 pressure at leaf surface."); - frame.declare_fraction ("hs_vector", - Attribute::LogOnly, Attribute::CanopyCells, "\ + frame.declare_fraction ("hs_vector", + Attribute::LogOnly, Attribute::CanopyCells, "\ Relative humidity at leaf surface."); - frame.declare ("gs_vector", "mol/m^2 leaf/s", Attribute::LogOnly, Attribute::CanopyCells, "Stomata cunductance in each layer."); - frame.declare ("Nleaf_vector", "mol N/m^2", Attribute::LogOnly, Attribute::CanopyCells, "Distribution of photosynthetic N-leaf."); - frame.declare ("Ass_vector", "mol CH2O/m^2/h", Attribute::LogOnly, Attribute::CanopyCells, "Brutto assimilate."); - frame.declare ("LAI_vector", "m^2 leaf/m^2 field", Attribute::LogOnly, Attribute::CanopyCells, "LAI."); - - frame.declare ("ci_middel", "Pa", Attribute::LogOnly, "Stomata average CO2 pressure."); - frame.declare ("Gamma", "Pa", Attribute::LogOnly, "\ + frame.declare ("gs_vector", "mol/m^2 leaf/s", Attribute::LogOnly, Attribute::CanopyCells, "Stomata cunductance in each layer."); + frame.declare ("Nleaf_vector", "mol N/m^2", Attribute::LogOnly, Attribute::CanopyCells, "Distribution of photosynthetic N-leaf."); + frame.declare ("Ass_vector", "mol CH2O/m^2/h", Attribute::LogOnly, Attribute::CanopyCells, "Brutto assimilate."); + frame.declare ("LAI_vector", "m^2 leaf/m^2 field", Attribute::LogOnly, Attribute::CanopyCells, "LAI."); + + frame.declare ("ci_middel", "Pa", Attribute::LogOnly, "Stomata average CO2 pressure."); + frame.declare ("Gamma", "Pa", Attribute::LogOnly, "\ CO2 compensation point of photosynthesis."); - frame.declare ("gbw", "mol/m^2 leaf/s", Attribute::LogOnly, "Boundary lauer conductance."); - frame.declare ("gs", "mol/m^2 field/s", Attribute::LogOnly, "Stomata conductance."); - frame.declare ("gs_ms", "m/s", Attribute::LogOnly, "Stomata conductance."); - frame.declare ("Ass", "g CH2O/m^2/h", Attribute::LogOnly, "'Net' leaf assimilate of CO2 (brutto photosynthesis)."); - frame.declare ("Res", "g CH2O/m^2/h", Attribute::LogOnly, "Farquhar leaf respiration."); - frame.declare ("LAI", "", Attribute::LogOnly, "Leaf area index for the canopy used in photosynthesis."); - frame.declare ("PAR_", "mol/m^2/h", Attribute::LogOnly, "PAR."); - frame.declare ("Vmax", "[mmol/m^2/s]", Attribute::LogOnly, "Photosynthetic Rubisco capacity."); - frame.declare ("jm", "[mmol/m^2/s]", Attribute::LogOnly, "Potential rate of electron transport."); - frame.declare ("leafPhotN", "[mol N/m^2]", Attribute::LogOnly, "Content of photosynthetic active leaf N."); - frame.declare ("fraction_total", "", Attribute::LogOnly, "Fraction of leaf contributing to the photosynthesis."); - - // Models - frame.declare_object ("N-dist", RubiscoNdist::component, - "Rubisco N-distribution in the canopy layer."); - frame.set ("N-dist", "exp"); - - frame.declare_object ("Stomatacon", StomataCon::component, - "Stomata conductance of water vapor."); - frame.set ("Stomatacon", "Leuning"); - } -} PhotoFarquhar_syntax; + frame.declare ("gbw", "mol/m^2 leaf/s", Attribute::LogOnly, "Boundary lauer conductance."); + frame.declare ("gs", "mol/m^2 field/s", Attribute::LogOnly, "Stomata conductance."); + frame.declare ("gs_ms", "m/s", Attribute::LogOnly, "Stomata conductance."); + frame.declare ("Ass", "g CH2O/m^2/h", Attribute::LogOnly, "'Net' leaf assimilate of CO2 (brutto photosynthesis)."); + frame.declare ("Res", "g CH2O/m^2/h", Attribute::LogOnly, "Farquhar leaf respiration."); + frame.declare ("LAI", "", Attribute::LogOnly, "Leaf area index for the canopy used in photosynthesis."); + frame.declare ("PAR_", "mol/m^2/h", Attribute::LogOnly, "PAR."); + frame.declare ("Vmax", "[mmol/m^2/s]", Attribute::LogOnly, "Photosynthetic Rubisco capacity."); + frame.declare ("jm", "[mmol/m^2/s]", Attribute::LogOnly, "Potential rate of electron transport."); + frame.declare ("leafPhotN", "[mol N/m^2]", Attribute::LogOnly, "Content of photosynthetic active leaf N."); + frame.declare ("fraction_total", "", Attribute::LogOnly, "Fraction of leaf contributing to the photosynthesis."); + + // Models + frame.declare_object ("N-dist", RubiscoNdist::component, + "Rubisco N-distribution in the canopy layer."); + frame.set ("N-dist", "exp"); + + frame.declare_object ("Stomatacon", StomataCon::component, + "Stomata conductance of water vapor."); + frame.set ("Stomatacon", "Leuning"); + } + } PhotoFarquhar_syntax; +} // photo_Farquhar.C ends here. + diff --git a/src/daisy/crop/photo_GL.C b/src/daisy/crop/photo_GL.C index 33763e950..554256cca 100644 --- a/src/daisy/crop/photo_GL.C +++ b/src/daisy/crop/photo_GL.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/crop/photo.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/crop/canopy_std.h" #include "daisy/crop/phenology.h" @@ -157,35 +158,40 @@ PhotoGL::assimilate (const Units&, const double, const double, const double, return (molWeightCH2O / molWeightCO2) * Teff * Ass; } -static struct Photo_GLSyntax : public DeclareModel +void +register_photo_GL_models () { - Model* make (const BlockModel& al) const - { return new PhotoGL (al); } - void load_frame (Frame& frame) const - { - PLF DS_null_eff; - DS_null_eff.add (0.0, 1.00); - DS_null_eff.add (2.0, 1.00); - - frame.declare ("Qeff", "(g CO2/m^2/h)/(W/m^2)", Attribute::Const, - "Quantum efficiency at low light."); - frame.declare ("Fm", "g CO2/m^2/h", Check::positive (), Attribute::Const, - "Maximum assimilation rate."); - frame.declare ("TempEff", "dg C", Attribute::None (), Check::non_negative (), - Attribute::Const, - "Temperature factor for assimilate production."); - frame.declare ("DSEff", "DS", Attribute::None (), Check::non_negative (), - Attribute::Const, "\ + static struct Photo_GLSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new PhotoGL (al); } + void load_frame (Frame& frame) const + { + PLF DS_null_eff; + DS_null_eff.add (0.0, 1.00); + DS_null_eff.add (2.0, 1.00); + + frame.declare ("Qeff", "(g CO2/m^2/h)/(W/m^2)", Attribute::Const, + "Quantum efficiency at low light."); + frame.declare ("Fm", "g CO2/m^2/h", Check::positive (), Attribute::Const, + "Maximum assimilation rate."); + frame.declare ("TempEff", "dg C", Attribute::None (), Check::non_negative (), + Attribute::Const, + "Temperature factor for assimilate production."); + frame.declare ("DSEff", "DS", Attribute::None (), Check::non_negative (), + Attribute::Const, "\ Development stage factor for assimilate production."); - frame.set ("DSEff",DS_null_eff); - frame.declare ("DAPEff", "d", Attribute::None (), Check::non_negative (), - Attribute::Const, "Age factor for assimilate production.\n\ + frame.set ("DSEff",DS_null_eff); + frame.declare ("DAPEff", "d", Attribute::None (), Check::non_negative (), + Attribute::Const, "Age factor for assimilate production.\n\ Age is given as day after planting."); - frame.set ("DAPEff",DS_null_eff); - } - Photo_GLSyntax () - : DeclareModel (Photo::component, "GL", "Goudriaan and Laar, 1978.") - { } -} PhotoGL_syntax; + frame.set ("DAPEff",DS_null_eff); + } + Photo_GLSyntax () + : DeclareModel (Photo::component, "GL", "Goudriaan and Laar, 1978.") + { } + } PhotoGL_syntax; +} // photo_GL.C ends here. + diff --git a/src/daisy/crop/production.C b/src/daisy/crop/production.C index e397880db..51196a873 100644 --- a/src/daisy/crop/production.C +++ b/src/daisy/crop/production.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/production.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/crop/crpn.h" #include "daisy/crop/partition.h" #include "daisy/organic_matter/organic.h" @@ -1036,8 +1037,13 @@ Production::Production (const FrameSubmodel& al) Production::~Production () { } -static DeclareSubmodel -production_submodel (Production::load_syntax, "Production", "\ +void +register_production_models () +{ + static DeclareSubmodel + production_submodel (Production::load_syntax, "Production", "\ Crop production in the default crop model."); +} // production.C ends here. + diff --git a/src/daisy/crop/root/ABAprod.C b/src/daisy/crop/root/ABAprod.C index 2b55538c4..982947d19 100644 --- a/src/daisy/crop/root/ABAprod.C +++ b/src/daisy/crop/root/ABAprod.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/crop/root/ABAprod.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" @@ -41,16 +42,6 @@ ABAProd::ABAProd (const BlockModel& al) ABAProd::~ABAProd () { } -static struct ABAProdInit : public DeclareComponent -{ - ABAProdInit () - : DeclareComponent (ABAProd::component, "\ -The 'ABAproduction' component calculates the prod of ABA in soil.") - { } - void load_frame (Frame& frame) const - { Model::load_model (frame); } -} ABAProd_init; - struct ABAProdNone : public ABAProd { // Solve. @@ -75,16 +66,33 @@ struct ABAProdNone : public ABAProd { } }; -static struct ABAProdNoneSyntax : public DeclareModel +void +register_ABAprod_models () { - Model* make (const BlockModel& al) const - { return new ABAProdNone (al); } - ABAProdNoneSyntax () - : DeclareModel (ABAProd::component, "none", "No ABA production.") - { } - void load_frame (Frame& frame) const - { } -} ABAProdNone_syntax; + static struct ABAProdInit : public DeclareComponent + { + ABAProdInit () + : DeclareComponent (ABAProd::component, "\ +The 'ABAproduction' component calculates the prod of ABA in soil.") + { } + void load_frame (Frame& frame) const + { Model::load_model (frame); } + } ABAProd_init; + static struct ABAProdNoneSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new ABAProdNone (al); } + ABAProdNoneSyntax () + : DeclareModel (ABAProd::component, "none", "No ABA production.") + { } + void load_frame (Frame& frame) const + { } + } ABAProdNone_syntax; + + register_ABAprod_root_models (); + register_ABAprod_soil_models (); + register_ABAprod_uptake_models (); +} // ABAprod.C ends here diff --git a/src/daisy/crop/root/ABAprod_root.C b/src/daisy/crop/root/ABAprod_root.C index ebb548c84..8ed6683d3 100644 --- a/src/daisy/crop/root/ABAprod_root.C +++ b/src/daisy/crop/root/ABAprod_root.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/crop/root/ABAprod.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/parameter_types/number.h" #include "util/scope_id.h" #include "daisy/soil/transport/geometry.h" @@ -116,26 +117,30 @@ ABAProdRoot::ABAProdRoot (const BlockModel& al) ABAProdRoot::~ABAProdRoot () { } -static struct ABAProdRootSyntax : public DeclareModel +void +register_ABAprod_root_models () { - Model* make (const BlockModel& al) const - { return new ABAProdRoot (al); } - ABAProdRootSyntax () - : DeclareModel (ABAProd::component, "root", "\ + static struct ABAProdRootSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new ABAProdRoot (al); } + ABAProdRootSyntax () + : DeclareModel (ABAProd::component, "root", "\ ABA production based on production in roots.\n\ \n\ The assumptions are that that each length of root will produce ABA\n\ with a rate that depends solely on the water pressure in that cell,\n\ and that all the ABA will be included in the water uptake.") - { } - void load_frame (Frame& frame) const - { - frame.declare_object ("expr", Number::component, - Attribute::Const, Attribute::Singleton, "\ + { } + void load_frame (Frame& frame) const + { + frame.declare_object ("expr", Number::component, + Attribute::Const, Attribute::Singleton, "\ Expression to evaluate to ABA production per root length [g/cm/h].\n\ The symbol 'h' will be bound to the water pressure [cm]."); - } -} ABAProdRoot_syntax; + } + } ABAProdRoot_syntax; +} // ABAprod_root.C ends here diff --git a/src/daisy/crop/root/ABAprod_soil.C b/src/daisy/crop/root/ABAprod_soil.C index e754bd64e..d68f52a5f 100644 --- a/src/daisy/crop/root/ABAprod_soil.C +++ b/src/daisy/crop/root/ABAprod_soil.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/crop/root/ABAprod.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/parameter_types/number.h" #include "util/scope_exchange.h" #include "daisy/soil/transport/geometry.h" @@ -131,23 +132,28 @@ ABAProdSoil::ABAProdSoil (const BlockModel& al) ABAProdSoil::~ABAProdSoil () { } -static struct ABAProdSoilSyntax : public DeclareModel +void +register_ABAprod_soil_models () { - Model* make (const BlockModel& al) const - { return new ABAProdSoil (al); } - ABAProdSoilSyntax () - : DeclareModel (ABAProd::component, "soil", "\ -ABA production based on soil location.") - { } - void load_frame (Frame& frame) const + static struct ABAProdSoilSyntax : public DeclareModel { - frame.declare_object ("expr", Number::component, - Attribute::Const, Attribute::Singleton, "\ + Model* make (const BlockModel& al) const + { return new ABAProdSoil (al); } + ABAProdSoilSyntax () + : DeclareModel (ABAProd::component, "soil", "\ +ABA production based on soil location.") + { } + void load_frame (Frame& frame) const + { + frame.declare_object ("expr", Number::component, + Attribute::Const, Attribute::Singleton, "\ Expression to evaluate to ABA uptake [g/cm^3/h].\n\ The symbol 'h' will be bound to the water pressure [cm].\n\ The symbol 'L' will be bound to the root density [cm/cm^3].\n\ The symbol 'S' will be bound to the water uptake [cm^3/cm^3/h]."); - } -} ABAProdSoil_syntax; + } + } ABAProdSoil_syntax; +} // ABAprod_soil.C ends here + diff --git a/src/daisy/crop/root/ABAprod_uptake.C b/src/daisy/crop/root/ABAprod_uptake.C index 94030311d..d1abc7546 100644 --- a/src/daisy/crop/root/ABAprod_uptake.C +++ b/src/daisy/crop/root/ABAprod_uptake.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/crop/root/ABAprod.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/parameter_types/number.h" #include "util/scope_id.h" #include "daisy/soil/transport/geometry.h" @@ -133,26 +134,30 @@ ABAProdUptake::ABAProdUptake (const BlockModel& al) ABAProdUptake::~ABAProdUptake () { } -static struct ABAProdUptakeSyntax : DeclareModel +void +register_ABAprod_uptake_models () { - Model* make (const BlockModel& al) const - { return new ABAProdUptake (al); } - ABAProdUptakeSyntax () - : DeclareModel (ABAProd::component, "uptake", "\ + static struct ABAProdUptakeSyntax : DeclareModel + { + Model* make (const BlockModel& al) const + { return new ABAProdUptake (al); } + ABAProdUptakeSyntax () + : DeclareModel (ABAProd::component, "uptake", "\ ABA production based on concentration in water uptake.\n\ \n\ The assumption is water uptake from roots in specific region of the soil\n\ comes with a specific ABA concentration, which depends solely on the\n\ water pressure in that region.") - { } - void load_frame (Frame& frame) const - { - frame.declare_object ("expr", Number::component, - Attribute::Const, Attribute::Singleton, "\ + { } + void load_frame (Frame& frame) const + { + frame.declare_object ("expr", Number::component, + Attribute::Const, Attribute::Singleton, "\ Expression to evaluate to ABA concentration in water uptake [g/cm^3].\n\ The symbol 'h' will be bound to the water pressure [cm]."); - } -} ABAProdUptake_syntax; + } + } ABAProdUptake_syntax; +} // ABAprod_uptake.C ends here diff --git a/src/daisy/crop/root/root_system.C b/src/daisy/crop/root/root_system.C index b9fbb43cf..01ad45565 100644 --- a/src/daisy/crop/root/root_system.C +++ b/src/daisy/crop/root/root_system.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/root/root_system.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/crop/root/rootdens.h" #include "daisy/crop/root/ABAprod.h" #include "daisy/crop/root/solupt.h" @@ -54,27 +55,6 @@ RootSystem::library_id () const return id; } -static struct RootSystemInit : public DeclareComponent -{ - static bool - check_alist (const Metalib&, const Frame& al, Treelog& msg) - { - bool ok = true; - return ok; - } - - void load_frame (Frame& frame) const - { - RootSystem::load_syntax (frame); - } - - RootSystemInit () - : DeclareComponent (RootSystem::component, "\ -Root processes.") - { } -} RootSystem_init; - - double RootSystem::crown_potential () const { return h_x; } @@ -718,28 +698,63 @@ struct RootClassic : public RootSystem { } }; -static struct RootClassicSyntax : DeclareModel +void +register_root_system_models () { - static bool - check_alist (const Metalib&, const Frame& al, Treelog& msg) + static struct RootSystemInit : public DeclareComponent { - bool ok = true; - return ok; - } - - void load_frame (Frame& frame) const - { } - - bool used_to_be_a_submodel () const - { return true; } - - Model* make (const BlockModel& al) const - { return new RootClassic (al); } - - RootClassicSyntax () - : DeclareModel (RootSystem::component, "classic", "\ + static bool + check_alist (const Metalib&, const Frame& al, Treelog& msg) + { + bool ok = true; + return ok; + } + + void load_frame (Frame& frame) const + { + RootSystem::load_syntax (frame); + } + + RootSystemInit () + : DeclareComponent (RootSystem::component, "\ +Root processes.") + { } + } RootSystem_init; + static struct RootClassicSyntax : DeclareModel + { + static bool + check_alist (const Metalib&, const Frame& al, Treelog& msg) + { + bool ok = true; + return ok; + } + + void load_frame (Frame& frame) const + { } + + bool used_to_be_a_submodel () const + { return true; } + + Model* make (const BlockModel& al) const + { return new RootClassic (al); } + + RootClassicSyntax () + : DeclareModel (RootSystem::component, "classic", "\ Classic root system model.") - { } -} RootClassic_syntax; + { } + } RootClassic_syntax; +} + +void +register_crop_root_models () +{ + register_rootdens_models (); + register_root_system_models (); + register_rubiscoN_models (); + register_rubiscoNdist_models (); + register_ABAprod_models (); + register_solupt_models (); +} // root_system.C ends here. + diff --git a/src/daisy/crop/root/rootdens.C b/src/daisy/crop/root/rootdens.C index 181498b8f..36a7435c9 100644 --- a/src/daisy/crop/root/rootdens.C +++ b/src/daisy/crop/root/rootdens.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/root/rootdens.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/frame.h" #include "object_model/check.h" @@ -50,20 +51,32 @@ Rootdens::Rootdens (const BlockModel& al) Rootdens::~Rootdens () { } -static struct RootdensInit : public DeclareComponent +void +register_rootdens_models () { - RootdensInit () - : DeclareComponent (Rootdens::component, "\ -Root density calculations.") - { } - void load_frame (Frame& frame) const + static struct RootdensInit : public DeclareComponent { - Model::load_model (frame); - frame.declare ("SpRtLength", "m/g", Check::positive (), Attribute::Const, - "Specific root length"); - frame.set ("SpRtLength", 100.0); - } -} Rootdens_init; + RootdensInit () + : DeclareComponent (Rootdens::component, "\ +Root density calculations.") + { } + void load_frame (Frame& frame) const + { + Model::load_model (frame); + frame.declare ("SpRtLength", "m/g", Check::positive (), Attribute::Const, + "Specific root length"); + frame.set ("SpRtLength", 100.0); + } + } Rootdens_init; + + register_rootdens_AP_models (); + register_rootdens_GP1D_models (); + register_rootdens_GP2D_models (); + register_rootdens_G_P_models (); + register_rootdens_growth_models (); + register_rootdens_local_models (); + register_rootdens_PLF_models (); +} // rootdens.C ends here. diff --git a/src/daisy/crop/root/rootdens_AP.C b/src/daisy/crop/root/rootdens_AP.C index 3e683399a..d08cc95b4 100644 --- a/src/daisy/crop/root/rootdens_AP.C +++ b/src/daisy/crop/root/rootdens_AP.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/root/rootdens.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/soil/transport/geometry.h" #include "daisy/output/log.h" @@ -106,29 +107,33 @@ Rootdens_AP::Rootdens_AP (const BlockModel& al) { } -static struct Rootdens_APSyntax : public DeclareModel +void +register_rootdens_AP_models () { - Model* make (const BlockModel& al) const - { return new Rootdens_AP (al); } - Rootdens_APSyntax () - : DeclareModel (Rootdens::component, "Anders Pedersen", - "Use exponential function for root density.\n\ + static struct Rootdens_APSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new Rootdens_AP (al); } + Rootdens_APSyntax () + : DeclareModel (Rootdens::component, "Anders Pedersen", + "Use exponential function for root density.\n\ In this variant of Gerwitz and Page, 'a' is specified as a function of\n\ development stage.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "gp74"); - - frame.declare ("a_DS", "DS", "cm^-1", Attribute::Const, - "Form parameter as a function of development stage."); - frame.declare ("q", "cm", Check::non_negative (), Attribute::Const, - "Extra root length below max rooting depth.\n\ + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "gp74"); + + frame.declare ("a_DS", "DS", "cm^-1", Attribute::Const, + "Form parameter as a function of development stage."); + frame.declare ("q", "cm", Check::non_negative (), Attribute::Const, + "Extra root length below max rooting depth.\n\ Root density will decrease linearly from the GP calculated amount\n\ at max rooting depth to zero 'q' further down."); - frame.declare ("a", "cm^-1", Attribute::LogOnly, "Form parameter.\n\ + frame.declare ("a", "cm^-1", Attribute::LogOnly, "Form parameter.\n\ Calculated from 'a_DS'."); - frame.declare ("L0", "cm/cm^3", Attribute::LogOnly, - "Root density at soil surface."); - } -} Rootdens_AP_syntax; + frame.declare ("L0", "cm/cm^3", Attribute::LogOnly, + "Root density at soil surface."); + } + } Rootdens_AP_syntax; +} diff --git a/src/daisy/crop/root/rootdens_GP1D.C b/src/daisy/crop/root/rootdens_GP1D.C index eac635b64..6e6dee9d0 100644 --- a/src/daisy/crop/root/rootdens_GP1D.C +++ b/src/daisy/crop/root/rootdens_GP1D.C @@ -23,6 +23,7 @@ #define BUILD_DLL #include "daisy/crop/root/rootdens.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/soil/transport/geometry.h" #include "daisy/output/log.h" @@ -287,36 +288,41 @@ Rootdens_GP1D::Rootdens_GP1D (const BlockModel& al) k (-42.42e42) { } -static struct Rootdens_GP1DSyntax : public DeclareModel +void +register_rootdens_GP1D_models () { - Model* make (const BlockModel& al) const - { return new Rootdens_GP1D (al); } - Rootdens_GP1DSyntax () - : DeclareModel (Rootdens::component, "GP1D", - "Use exponential function for root density.") - { } - void load_frame (Frame& frame) const + static struct Rootdens_GP1DSyntax : public DeclareModel { - frame.set_strings ("cite", "gp74"); - frame.declare ("DensRtTip", "cm/cm^3", Check::positive (), Attribute::Const, - "Root density at (potential) penetration depth."); - frame.set ("DensRtTip", 0.1); - frame.declare ("DensIgnore", "cm/cm^3", Check::positive (), - Attribute::OptionalConst, - "Ignore cells with less than this root density.\n\ + Model* make (const BlockModel& al) const + { return new Rootdens_GP1D (al); } + Rootdens_GP1DSyntax () + : DeclareModel (Rootdens::component, "GP1D", + "Use exponential function for root density.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "gp74"); + frame.declare ("DensRtTip", "cm/cm^3", Check::positive (), Attribute::Const, + "Root density at (potential) penetration depth."); + frame.set ("DensRtTip", 0.1); + frame.declare ("DensIgnore", "cm/cm^3", Check::positive (), + Attribute::OptionalConst, + "Ignore cells with less than this root density.\n\ By default, this is the same as DensRtTip."); - frame.declare ("a", "cm^-1", Attribute::LogOnly, "Form parameter.\n\ + frame.declare ("a", "cm^-1", Attribute::LogOnly, "Form parameter.\n\ Calculated from 'DensRtTip'."); - frame.declare ("L0", "cm/cm^3", Attribute::LogOnly, - "Root density at soil surface."); - frame.declare ("k", Attribute::None (), Attribute::LogOnly, - "Scale factor due to soil limit.\n\ + frame.declare ("L0", "cm/cm^3", Attribute::LogOnly, + "Root density at soil surface."); + frame.declare ("k", Attribute::None (), Attribute::LogOnly, + "Scale factor due to soil limit.\n\ \n\ Some roots might be below the soil imposed maximum root depth, or in areas\n\ with a density lower than the limit specified by DensIgnore.\n\ These roots will be re distributed within the root zone by multiplying the\n\ density with this scale factor."); - } -} Rootdens_GP1D_syntax; + } + } Rootdens_GP1D_syntax; +} // rootdens_GP1D.C ends here. + diff --git a/src/daisy/crop/root/rootdens_GP2D.C b/src/daisy/crop/root/rootdens_GP2D.C index 058b6e17a..bd099031a 100644 --- a/src/daisy/crop/root/rootdens_GP2D.C +++ b/src/daisy/crop/root/rootdens_GP2D.C @@ -23,6 +23,7 @@ #define BUILD_DLL #include "daisy/crop/root/rootdens.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/soil/transport/geometry.h" #include "daisy/output/log.h" @@ -403,13 +404,16 @@ Rootdens::create_row (const Metalib& metalib, Treelog& msg, return std::unique_ptr (Librarian::build_frame (metalib, msg, frame, "row")); } -static struct Rootdens_GP2DSyntax : public DeclareModel +void +register_rootdens_GP2D_models () { - Model* make (const BlockModel& al) const - { return new Rootdens_GP2D (al); } - Rootdens_GP2DSyntax () - : DeclareModel (Rootdens::component, "GP2D", - "Use exponential function for root density in row crops.\n\ + static struct Rootdens_GP2DSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new Rootdens_GP2D (al); } + Rootdens_GP2DSyntax () + : DeclareModel (Rootdens::component, "GP2D", + "Use exponential function for root density in row crops.\n\ \n\ This is a two dimension model (z, x), where the z-axis is vertical,\n\ and the x-axis is horizontal and ortogonal to the row. The row is\n\ @@ -417,40 +421,42 @@ assumed to be uniform (dense), allowing us to ignore that dimension.\n\ \n\ We assume the root density decrease with horizontal distance to row,\n\ as well as depth below row.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "gp74"); - frame.declare_integer ("debug", Attribute::Const, "\ + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "gp74"); + frame.declare_integer ("debug", Attribute::Const, "\ Add debug messages if larger than 0."); - frame.set ("debug", 0); - frame.declare ("row_position", "cm", Attribute::State, "\ + frame.set ("debug", 0); + frame.declare ("row_position", "cm", Attribute::State, "\ Horizontal position of row crops."); - frame.set ("row_position", 0.0); - frame.declare ("row_distance", "cm", Attribute::State, - "Distance between rows of crops."); - frame.declare ("DensRtTip", "cm/cm^3", Check::positive (), Attribute::Const, - "Root density at (potential) penetration depth."); - frame.set ("DensRtTip", 0.1); - frame.declare ("DensIgnore", "cm/cm^3", Check::positive (), - Attribute::OptionalConst, - "Ignore cells with less than this root density.\n\ + frame.set ("row_position", 0.0); + frame.declare ("row_distance", "cm", Attribute::State, + "Distance between rows of crops."); + frame.declare ("DensRtTip", "cm/cm^3", Check::positive (), Attribute::Const, + "Root density at (potential) penetration depth."); + frame.set ("DensRtTip", 0.1); + frame.declare ("DensIgnore", "cm/cm^3", Check::positive (), + Attribute::OptionalConst, + "Ignore cells with less than this root density.\n\ By default, this is the same as DensRtTip."); - frame.declare ("a_z", "cm^-1", Attribute::LogOnly, "Form parameter.\n\ + frame.declare ("a_z", "cm^-1", Attribute::LogOnly, "Form parameter.\n\ Calculated from 'DensRtTip'."); - frame.declare ("a_x", "cm^-1", Attribute::LogOnly, "Form parameter.\n\ + frame.declare ("a_x", "cm^-1", Attribute::LogOnly, "Form parameter.\n\ Calculated from 'DensRtTip'."); - frame.declare ("L00", "cm/cm^3", Attribute::LogOnly, - "Root density at row crop at soil surface."); - frame.declare ("k", Attribute::None (), Attribute::LogOnly, - "Scale factor due to soil limit.\n\ + frame.declare ("L00", "cm/cm^3", Attribute::LogOnly, + "Root density at row crop at soil surface."); + frame.declare ("k", Attribute::None (), Attribute::LogOnly, + "Scale factor due to soil limit.\n\ \n\ Some roots might be below the soil imposed maximum root depth, or in areas\n\ with a density lower than the limit specified by 'DensIgnore'.\n\ These roots will be re distributed within the root zone by multiplying the\n\ density with this scale factor."); - - } -} Rootdens_GP2D_syntax; + + } + } Rootdens_GP2D_syntax; +} // rootdens_GP2D.C ends here. + diff --git a/src/daisy/crop/root/rootdens_G_P.C b/src/daisy/crop/root/rootdens_G_P.C index 98068f53b..9a39e0542 100644 --- a/src/daisy/crop/root/rootdens_G_P.C +++ b/src/daisy/crop/root/rootdens_G_P.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/root/rootdens.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/soil/transport/geometry.h" #include "daisy/output/log.h" @@ -219,32 +220,37 @@ Rootdens::create_uniform (const Metalib& metalib, Treelog& msg) (Librarian::build_stock (metalib, msg, "Gerwitz+Page74", "uniform")); } -static struct Rootdens_G_PSyntax : public DeclareModel +void +register_rootdens_G_P_models () { - Model* make (const BlockModel& al) const - { return new Rootdens_G_P (al); } - Rootdens_G_PSyntax () - : DeclareModel (Rootdens::component, "Gerwitz+Page74", - "Use exponential function for root density.") - { } - void load_frame (Frame& frame) const + static struct Rootdens_G_PSyntax : public DeclareModel { - frame.set_strings ("cite", "gp74"); - frame.declare ("DensRtTip", "cm/cm^3", Check::positive (), Attribute::Const, - "Root density at (potential) penetration depth."); - frame.set ("DensRtTip", 0.1); - frame.declare ("MinDens", "cm/cm^3", Check::non_negative (), Attribute::Const, - "Minimal root density\n\ + Model* make (const BlockModel& al) const + { return new Rootdens_G_P (al); } + Rootdens_G_PSyntax () + : DeclareModel (Rootdens::component, "Gerwitz+Page74", + "Use exponential function for root density.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "gp74"); + frame.declare ("DensRtTip", "cm/cm^3", Check::positive (), Attribute::Const, + "Root density at (potential) penetration depth."); + frame.set ("DensRtTip", 0.1); + frame.declare ("MinDens", "cm/cm^3", Check::non_negative (), Attribute::Const, + "Minimal root density\n\ Root density will never be below this, as long as there is enough root mass.\n \ Extra root mass will be distributed according to Gerwitz and Page.\n\ If there are too little root mass, the root will have the same density\n\ all the way down."); - frame.set ("MinDens", 0.0); - frame.declare ("a", "cm^-1", Attribute::LogOnly, "Form parameter.\n\ + frame.set ("MinDens", 0.0); + frame.declare ("a", "cm^-1", Attribute::LogOnly, "Form parameter.\n\ Calculated from 'DensRtTip'."); - frame.declare ("L0", "cm/cm^3", Attribute::LogOnly, - "Root density at soil surface."); - } -} Rootdens_G_P_syntax; + frame.declare ("L0", "cm/cm^3", Attribute::LogOnly, + "Root density at soil surface."); + } + } Rootdens_G_P_syntax; +} // rootdens_G_P.C ends here. + diff --git a/src/daisy/crop/root/rootdens_PLF.C b/src/daisy/crop/root/rootdens_PLF.C index 703fbe04e..5980442ff 100644 --- a/src/daisy/crop/root/rootdens_PLF.C +++ b/src/daisy/crop/root/rootdens_PLF.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/root/rootdens.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/soil/transport/geometry.h" #include "object_model/plf.h" #include "object_model/submodeler.h" @@ -230,32 +231,6 @@ struct Rootdens_DS_Depth : public Rootdens_PLF { } }; -static struct Rootdens_DS_Depth_Syntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new Rootdens_DS_Depth (al); } - - Rootdens_DS_Depth_Syntax () - : DeclareModel (Rootdens::component, "DS_Depth", "\ -Specify root density as a function of development stage.") - { } - void load_frame (Frame& frame) const - { - frame.declare_submodule_sequence("entries", Attribute::Const, "\ -A list of pairs, where the first element of each pair is a development\n\ -stage (usually a number between 0 (emergence) and 2 (ripe), and the\n\ -second element is a PLF specifying the relative root density as a\n\ -function of soil depth in cm (a positive number).\n\ -\n\ -To find the absolute root density, Daisy will interpolate the relative\n\ -root density distribution specified for the entries before and after\n\ -the current development stage, and scale them to match the current\n\ -total root mass.", - Rootdens_PLF::Entry::load_syntax); - frame.set_check ("entries", check_indexes); - } -} Rootdens_DS_Depth_syntax; - struct Rootdens_DS_Rel : public Rootdens_PLF { // Simulation. @@ -278,33 +253,6 @@ struct Rootdens_DS_Rel : public Rootdens_PLF { } }; -static struct Rootdens_DS_Rel_Syntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new Rootdens_DS_Rel (al); } - - Rootdens_DS_Rel_Syntax () - : DeclareModel (Rootdens::component, "DS_Rel", "\ -Specify root density as a function of development stage.") - { } - void load_frame (Frame& frame) const - { - frame.declare_submodule_sequence("entries", Attribute::Const, "\ -A list of pairs, where the first element of each pair is a development\n\ -stage (usually a number between 0 (emergence) and 2 (ripe), and the\n\ -second element is a PLF specifying the relative root density as a\n\ -function of soil depth relative to the total root depth.\n\ -\n\ -To find the absolute root density, Daisy will interpolate the relative\n\ -root density distribution specified for the entries before and after\n\ -the current development stage, and scale them to match the current\n\ -total root mass.", - Rootdens_PLF::Entry::load_syntax); - frame.set_check ("entries", check_indexes); - - } -} Rootdens_DS_Rel_syntax; - struct Rootdens_Depth_Depth : public Rootdens_PLF { // Simulation. @@ -326,18 +274,72 @@ struct Rootdens_Depth_Depth : public Rootdens_PLF { } }; -static struct Rootdens_Depth_Depth_Syntax : public DeclareModel +void +register_rootdens_PLF_models () { - Model* make (const BlockModel& al) const - { return new Rootdens_Depth_Depth (al); } - - Rootdens_Depth_Depth_Syntax () - : DeclareModel (Rootdens::component, "Depth_Depth", "\ + static struct Rootdens_DS_Depth_Syntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new Rootdens_DS_Depth (al); } + + Rootdens_DS_Depth_Syntax () + : DeclareModel (Rootdens::component, "DS_Depth", "\ Specify root density as a function of development stage.") - { } - void load_frame (Frame& frame) const + { } + void load_frame (Frame& frame) const + { + frame.declare_submodule_sequence("entries", Attribute::Const, "\ +A list of pairs, where the first element of each pair is a development\n\ +stage (usually a number between 0 (emergence) and 2 (ripe), and the\n\ +second element is a PLF specifying the relative root density as a\n\ +function of soil depth in cm (a positive number).\n\ +\n\ +To find the absolute root density, Daisy will interpolate the relative\n\ +root density distribution specified for the entries before and after\n\ +the current development stage, and scale them to match the current\n\ +total root mass.", + Rootdens_PLF::Entry::load_syntax); + frame.set_check ("entries", check_indexes); + } + } Rootdens_DS_Depth_syntax; + static struct Rootdens_DS_Rel_Syntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new Rootdens_DS_Rel (al); } + + Rootdens_DS_Rel_Syntax () + : DeclareModel (Rootdens::component, "DS_Rel", "\ +Specify root density as a function of development stage.") + { } + void load_frame (Frame& frame) const + { + frame.declare_submodule_sequence("entries", Attribute::Const, "\ +A list of pairs, where the first element of each pair is a development\n\ +stage (usually a number between 0 (emergence) and 2 (ripe), and the\n\ +second element is a PLF specifying the relative root density as a\n\ +function of soil depth relative to the total root depth.\n\ +\n\ +To find the absolute root density, Daisy will interpolate the relative\n\ +root density distribution specified for the entries before and after\n\ +the current development stage, and scale them to match the current\n\ +total root mass.", + Rootdens_PLF::Entry::load_syntax); + frame.set_check ("entries", check_indexes); + + } + } Rootdens_DS_Rel_syntax; + static struct Rootdens_Depth_Depth_Syntax : public DeclareModel { - frame.declare_submodule_sequence("entries", Attribute::Const, "\ + Model* make (const BlockModel& al) const + { return new Rootdens_Depth_Depth (al); } + + Rootdens_Depth_Depth_Syntax () + : DeclareModel (Rootdens::component, "Depth_Depth", "\ +Specify root density as a function of development stage.") + { } + void load_frame (Frame& frame) const + { + frame.declare_submodule_sequence("entries", Attribute::Const, "\ A list of pairs, where the first element of each pair is the root depth,\ \n(a positive number), and the second element is a PLF specifying the\n\ relative root density as a function of soil depth in cm (a positive number).\n\ @@ -346,10 +348,12 @@ To find the absolute root density, Daisy will interpolate the relative\n\ root density distribution specified for the entries before and after\n\ the current development stage, and scale them to match the current\n\ total root mass.", - Rootdens_PLF::Entry::load_syntax); - frame.set_check ("entries", check_indexes); - - } -} Rootdens_Depth_Depth_syntax; + Rootdens_PLF::Entry::load_syntax); + frame.set_check ("entries", check_indexes); + + } + } Rootdens_Depth_Depth_syntax; +} // rootdens_PLF.C ends here. + diff --git a/src/daisy/crop/root/rootdens_growth.C b/src/daisy/crop/root/rootdens_growth.C index 6bb77c12d..7ea4babfb 100644 --- a/src/daisy/crop/root/rootdens_growth.C +++ b/src/daisy/crop/root/rootdens_growth.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/crop/root/rootdens.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/soil/transport/geometry.h" #include "daisy/output/log.h" @@ -251,41 +252,46 @@ RootdensGrowth::RootdensGrowth (const BlockModel& al) LastWRoot (al.number ("WRoot", 0.0)) { } -static struct RootdensGrowthSyntax : public DeclareModel +void +register_rootdens_growth_models () { - Model* make (const BlockModel& al) const - { return new RootdensGrowth (al); } - RootdensGrowthSyntax () - : DeclareModel (Rootdens::component, "growth", "\ -Dynamic root growth model.") - { } - void load_frame (Frame& frame) const + static struct RootdensGrowthSyntax : public DeclareModel { - frame.declare ("row_position", "cm", Check::non_negative (), - Attribute::State, "\ + Model* make (const BlockModel& al) const + { return new RootdensGrowth (al); } + RootdensGrowthSyntax () + : DeclareModel (Rootdens::component, "growth", "\ +Dynamic root growth model.") + { } + void load_frame (Frame& frame) const + { + frame.declare ("row_position", "cm", Check::non_negative (), + Attribute::State, "\ Horizontal position of row crops."); - frame.set ("row_position", 0.0); - frame.declare ("row_distance", "cm", Attribute::OptionalState, - "Distance between rows of crops."); - frame.declare ("DensRtTip", "cm/cm^3", Check::positive (), Attribute::Const, - "Root density at (potential) penetration depth."); - frame.set ("DensRtTip", 0.1); - frame.declare ("depth_factor", "cm", Attribute::None (), - Check::non_negative (), Attribute::Const, "\ + frame.set ("row_position", 0.0); + frame.declare ("row_distance", "cm", Attribute::OptionalState, + "Distance between rows of crops."); + frame.declare ("DensRtTip", "cm/cm^3", Check::positive (), Attribute::Const, + "Root density at (potential) penetration depth."); + frame.set ("DensRtTip", 0.1); + frame.declare ("depth_factor", "cm", Attribute::None (), + Check::non_negative (), Attribute::Const, "\ Depth (negative) affect on root growth.\n\ Specify a value less than one to decrease root growth, and larger\n\ than one to increase root growth at the specified depth."); - frame.set ("depth_factor", PLF::always_1 ()); - frame.declare ("Depth", "cm", - Check::non_negative (), Attribute::OptionalState, - "Expected depth of root zone (positive)."); - frame.declare ("Width", "cm", - Check::non_negative (), Attribute::OptionalState, - "Expected width of root zone."); - frame.declare ("WRoot", "g DM/m^2", - Check::non_negative (), Attribute::OptionalState, - "Total root mass."); - } -} RootdensGrowth_syntax; + frame.set ("depth_factor", PLF::always_1 ()); + frame.declare ("Depth", "cm", + Check::non_negative (), Attribute::OptionalState, + "Expected depth of root zone (positive)."); + frame.declare ("Width", "cm", + Check::non_negative (), Attribute::OptionalState, + "Expected width of root zone."); + frame.declare ("WRoot", "g DM/m^2", + Check::non_negative (), Attribute::OptionalState, + "Total root mass."); + } + } RootdensGrowth_syntax; +} // rootdens_growth.C ends here. + diff --git a/src/daisy/crop/root/rootdens_local.C b/src/daisy/crop/root/rootdens_local.C index 5b5760cd9..cca540f8f 100644 --- a/src/daisy/crop/root/rootdens_local.C +++ b/src/daisy/crop/root/rootdens_local.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/crop/root/rootdens.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/soil/transport/geometry.h" #include "daisy/output/log.h" @@ -529,84 +530,89 @@ RootdensLocal::RootdensLocal (const BlockModel& al) D_tot (0.0) { } -static struct RootdensLocalSyntax : public DeclareModel +void +register_rootdens_local_models () { - Model* make (const BlockModel& al) const - { return new RootdensLocal (al); } - RootdensLocalSyntax () - : DeclareModel (Rootdens::component, "local", "\ -Dynamic root growth model.") - { } - void load_frame (Frame& frame) const + static struct RootdensLocalSyntax : public DeclareModel { - frame.declare ("row_position", "cm", Check::non_negative (), - Attribute::Const, "\ + Model* make (const BlockModel& al) const + { return new RootdensLocal (al); } + RootdensLocalSyntax () + : DeclareModel (Rootdens::component, "local", "\ +Dynamic root growth model.") + { } + void load_frame (Frame& frame) const + { + frame.declare ("row_position", "cm", Check::non_negative (), + Attribute::Const, "\ Horizontal position of row crops."); - frame.set ("row_position", 0.0); - frame.declare ("row_distance", "cm", Attribute::OptionalConst, - "Distance between rows of crops."); - frame.declare ("DensRtTip", "cm/cm^3", Check::positive (), Attribute::Const, - "Root density at (potential) penetration depth."); - frame.set ("DensRtTip", 0.1); - frame.declare ("depth_factor", "cm", Attribute::None (), - Check::non_negative (), Attribute::Const, "\ + frame.set ("row_position", 0.0); + frame.declare ("row_distance", "cm", Attribute::OptionalConst, + "Distance between rows of crops."); + frame.declare ("DensRtTip", "cm/cm^3", Check::positive (), Attribute::Const, + "Root density at (potential) penetration depth."); + frame.set ("DensRtTip", 0.1); + frame.declare ("depth_factor", "cm", Attribute::None (), + Check::non_negative (), Attribute::Const, "\ Depth (negative) affect on root growth.\n\ Specify a value less than one to decrease root growth, and larger\n\ than one to increase root growth at the specified depth."); - frame.set ("depth_factor", PLF::always_1 ()); - frame.declare ("neighbor_effect", "cm/d", Check::non_negative (), - Attribute::Const, "\ + frame.set ("depth_factor", PLF::always_1 ()); + frame.declare ("neighbor_effect", "cm/d", Check::non_negative (), + Attribute::Const, "\ How fast root density in neighbor cells affect growth.\n\ After expansion, excess roots are distributed propertional to existing\n\ root desinity in each cell, plus a part of the neighbor cells."); - frame.set ("neighbor_effect", 0.0); - frame.declare ("max_internal_growth_rate", "d^-1", Check::non_negative (), - Attribute::Const, "\ + frame.set ("neighbor_effect", 0.0); + frame.declare ("max_internal_growth_rate", "d^-1", Check::non_negative (), + Attribute::Const, "\ Root density within root zone cannot grow faster than this."); - frame.set ("max_internal_growth_rate", 0.1); - frame.declare ("h_threshold", "cm", Check::none (), Attribute::Const, "\ + frame.set ("max_internal_growth_rate", 0.1); + frame.declare ("h_threshold", "cm", Check::none (), Attribute::Const, "\ Root starts dying if pressure is above this threshold."); - frame.set ("h_threshold", 0.0); - frame.declare ("death_rate", "h", "h^-1", Attribute::Const, "\ + frame.set ("h_threshold", 0.0); + frame.declare ("death_rate", "h", "h^-1", Attribute::Const, "\ Death rate as function of temperature modified time flooded."); - PLF death_rate; - death_rate.add (36.0, 0.0); - death_rate.add (60.0, 0.1); - frame.set ("death_rate", death_rate); - frame.declare_function ("death_T_factor", "dg C", Attribute::None (), "\ + PLF death_rate; + death_rate.add (36.0, 0.0); + death_rate.add (60.0, 0.1); + frame.set ("death_rate", death_rate); + frame.declare_function ("death_T_factor", "dg C", Attribute::None (), "\ Temperature effect on flooding."); - frame.set ("death_T_factor", "T_min_15"); - frame.declare_boolean ("emerging", Attribute::State, "\ + frame.set ("death_T_factor", "T_min_15"); + frame.declare_boolean ("emerging", Attribute::State, "\ True until root mass is large enough to sustain root length in RZ.\n\ Until then, L within RZ is set to DensRtTip."); - frame.set ("emerging", true); - frame.declare ("Depth", "cm", - Check::non_negative (), Attribute::OptionalState, - "Expected depth of root zone (positive)."); - frame.declare ("Width", "cm", - Check::non_negative (), Attribute::OptionalState, - "Expected width of root zone."); - frame.declare ("flooded", "h", - Attribute::OptionalState, Attribute::SoilCells, "\ + frame.set ("emerging", true); + frame.declare ("Depth", "cm", + Check::non_negative (), Attribute::OptionalState, + "Expected depth of root zone (positive)."); + frame.declare ("Width", "cm", + Check::non_negative (), Attribute::OptionalState, + "Expected width of root zone."); + frame.declare ("flooded", "h", + Attribute::OptionalState, Attribute::SoilCells, "\ Time flooded, adjusted for temperature.\n\ The temperature adjustment is the same used for mineralization."); - frame.declare ("E", "cm/cm^3/d", Attribute::LogOnly, Attribute::SoilCells, - "Expansion"); - frame.declare ("expansion_volume", "cm^3", Attribute::LogOnly, "\ + frame.declare ("E", "cm/cm^3/d", Attribute::LogOnly, Attribute::SoilCells, + "Expansion"); + frame.declare ("expansion_volume", "cm^3", Attribute::LogOnly, "\ Expansion volume."); - frame.declare ("E_tot", "cm/d", Attribute::LogOnly, "\ + frame.declare ("E_tot", "cm/d", Attribute::LogOnly, "\ Total expansion root length."); - frame.declare ("A_tot", "cm^2", Attribute::LogOnly, "\ + frame.declare ("A_tot", "cm^2", Attribute::LogOnly, "\ Total expansion area."); - frame.declare ("I", "cm/cm^3/d", Attribute::LogOnly, Attribute::SoilCells, - "Internal adjustment."); - frame.declare ("I_tot", "cm/d", Attribute::LogOnly, "\ + frame.declare ("I", "cm/cm^3/d", Attribute::LogOnly, Attribute::SoilCells, + "Internal adjustment."); + frame.declare ("I_tot", "cm/d", Attribute::LogOnly, "\ Total internal adjustment root length."); - frame.declare ("D", "cm/cm^3/d", Attribute::LogOnly, Attribute::SoilCells, - "Death."); - frame.declare ("D_tot", "cm/d", Attribute::LogOnly, "\ + frame.declare ("D", "cm/cm^3/d", Attribute::LogOnly, Attribute::SoilCells, + "Death."); + frame.declare ("D_tot", "cm/d", Attribute::LogOnly, "\ Total death root length."); - } -} RootdensLocal_syntax; + } + } RootdensLocal_syntax; +} // rootdens_local.C ends here. + diff --git a/src/daisy/crop/root/rubiscoN.C b/src/daisy/crop/root/rubiscoN.C index 972a603a4..4bfd6112e 100644 --- a/src/daisy/crop/root/rubiscoN.C +++ b/src/daisy/crop/root/rubiscoN.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/root/rubiscoN.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" #include "object_model/check.h" @@ -43,14 +44,6 @@ RubiscoN::RubiscoN () RubiscoN::~RubiscoN () { } -static struct RubiscoNInit : public DeclareComponent -{ - RubiscoNInit () - : DeclareComponent (RubiscoN::component, "\ -Find total amount of Rubisco-N in leaves.") - { } -} RubiscoN_init; - // The 'default' model. struct RubiscoNStandard : public RubiscoN @@ -93,33 +86,45 @@ public: { } }; -static struct RubiscoNStandardSyntax : public DeclareModel +void +register_rubiscoN_models () { - Model* make (const BlockModel& al) const - { return new RubiscoNStandard (al); } - - RubiscoNStandardSyntax () - : DeclareModel (RubiscoN::component, "default", - "Standard estimation of RuBisCo N.") - { } - void load_frame (Frame& frame) const + static struct RubiscoNInit : public DeclareComponent + { + RubiscoNInit () + : DeclareComponent (RubiscoN::component, "\ +Find total amount of Rubisco-N in leaves.") + { } + } RubiscoN_init; + static struct RubiscoNStandardSyntax : public DeclareModel { - frame.declare_fraction ("fraction", Attribute::Const, "\ + Model* make (const BlockModel& al) const + { return new RubiscoNStandard (al); } + + RubiscoNStandardSyntax () + : DeclareModel (RubiscoN::component, "default", + "Standard estimation of RuBisCo N.") + { } + void load_frame (Frame& frame) const + { + frame.declare_fraction ("fraction", Attribute::Const, "\ Fraction of remaining N in leaves that RuBisCo-N.\n\ First structural and luxury N may be subtracted, as per the\n\ other parameters."); - frame.set_cited ("fraction", 0.75, "Equation 6", "boegh2002"); - frame.declare ("offset", "g N/m^2", Check::none (), Attribute::Const, "\ + frame.set_cited ("fraction", 0.75, "Equation 6", "boegh2002"); + frame.declare ("offset", "g N/m^2", Check::none (), Attribute::Const, "\ Subtract this amount of N per LAI."); - frame.set ("offset", 0.0); - frame.declare_boolean ("subtract_Nf", Attribute::Const, "\ + frame.set ("offset", 0.0); + frame.declare_boolean ("subtract_Nf", Attribute::Const, "\ Subtract N corresponding to the non functional concentration in leafs."); - frame.set ("subtract_Nf", false); - frame.declare_boolean ("subtract_Pt", Attribute::Const, "\ + frame.set ("subtract_Nf", false); + frame.declare_boolean ("subtract_Pt", Attribute::Const, "\ Subtract N above the critical concentration in leafs."); - frame.set ("subtract_Pt", false); - - } -} rubiscoNStandard_syntax; + frame.set ("subtract_Pt", false); + + } + } rubiscoNStandard_syntax; +} // rubiscoN.C ends here. + diff --git a/src/daisy/crop/root/rubiscoNdist.C b/src/daisy/crop/root/rubiscoNdist.C index 37176a96e..594ddaf59 100644 --- a/src/daisy/crop/root/rubiscoNdist.C +++ b/src/daisy/crop/root/rubiscoNdist.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/crop/root/rubiscoNdist.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "util/mathlib.h" #include "object_model/librarian.h" @@ -41,11 +42,19 @@ RubiscoNdist::RubiscoNdist (const BlockModel& al) RubiscoNdist::~RubiscoNdist () { } -static struct RubiscoNdistInit : public DeclareComponent +void +register_rubiscoNdist_models () { - RubiscoNdistInit () - : DeclareComponent (RubiscoNdist::component, "\ + static struct RubiscoNdistInit : public DeclareComponent + { + RubiscoNdistInit () + : DeclareComponent (RubiscoNdist::component, "\ The 'rubiscoNdist' component calculates the rubisco N distribution for photosynthesis in the canopy.") - { } -} RubiscoNdist_init; + { } + } RubiscoNdist_init; + register_rubiscoNdist_DPF_models (); + register_rubiscoNdist_expr_models (); + register_rubiscoNdist_forced_models (); + register_rubiscoNdist_uniform_models (); +} diff --git a/src/daisy/crop/root/rubiscoNdist_DPF.C b/src/daisy/crop/root/rubiscoNdist_DPF.C index 734adb3e2..7488ddac2 100644 --- a/src/daisy/crop/root/rubiscoNdist_DPF.C +++ b/src/daisy/crop/root/rubiscoNdist_DPF.C @@ -20,6 +20,7 @@ #define BUILD_DLL #include "daisy/crop/root/rubiscoNdist.h" +#include "daisy/daisy_registration_internal.h" #include "util/mathlib.h" #include "object_model/block_model.h" #include @@ -89,25 +90,29 @@ rubiscoNdistDPF::rubiscoN_distribution (const Units&, for (int i = 0; i < No; i++) rubiscoNdist[i] = cropN0 * (exp(-kn_LAI * dLAI *(i+0.5))); //[mol/m² leaf] - } -static struct rubiscoNdistDPFSyntax : public DeclareModel +void +register_rubiscoNdist_DPF_models () { - Model* make (const BlockModel& al) const - { return new rubiscoNdistDPF (al); } - - rubiscoNdistDPFSyntax () - : DeclareModel (RubiscoNdist::component, "exp", - "Boegh et al.(2002) rubisco N-distribution model in the canopy for photosynthesis.") - { } - void load_frame (Frame& frame) const + static struct rubiscoNdistDPFSyntax : public DeclareModel { - - frame.declare ("kn", Attribute::None (), Check::positive (), Attribute::Const, - "Extinction coefficient of nitrogen in the canopy, kn = 0.713 (De Pury &Farquhar, 1997)"); - frame.set ("kn", 0.713); - } -} rubiscoNdistDPF_syntax; + Model* make (const BlockModel& al) const + { return new rubiscoNdistDPF (al); } + + rubiscoNdistDPFSyntax () + : DeclareModel (RubiscoNdist::component, "exp", + "Boegh et al.(2002) rubisco N-distribution model in the canopy for photosynthesis.") + { } + void load_frame (Frame& frame) const + { + + frame.declare ("kn", Attribute::None (), Check::positive (), Attribute::Const, + "Extinction coefficient of nitrogen in the canopy, kn = 0.713 (De Pury &Farquhar, 1997)"); + frame.set ("kn", 0.713); + } + } rubiscoNdistDPF_syntax; +} // rubiscoNdist_DPF.C ends here + diff --git a/src/daisy/crop/root/rubiscoNdist_expr.C b/src/daisy/crop/root/rubiscoNdist_expr.C index 400517245..7beaa826c 100644 --- a/src/daisy/crop/root/rubiscoNdist_expr.C +++ b/src/daisy/crop/root/rubiscoNdist_expr.C @@ -20,6 +20,7 @@ #define BUILD_DLL #include "daisy/crop/root/rubiscoNdist.h" +#include "daisy/daisy_registration_internal.h" #include "util/mathlib.h" #include "object_model/block_model.h" #include @@ -170,28 +171,30 @@ rubiscoNdist_expr } } -static struct rubiscoNdist_exprSyntax : public DeclareModel +void +register_rubiscoNdist_expr_models () { - Model* make (const BlockModel& al) const - { return new rubiscoNdist_expr (al); } - - rubiscoNdist_exprSyntax () - : DeclareModel (RubiscoNdist::component, "expr", - "expr rubisco N-distribution model in the canopy.") - { } - void load_frame (Frame& frame) const + static struct rubiscoNdist_exprSyntax : public DeclareModel { - Model::declare_obsolete (frame, "Experimental, avoid"); - frame.declare ("f_photo", Attribute::None (), Check::positive (), Attribute::Const, - "Fraction of photosynthetically active N in canopy. According to (Boegh et al., 2002) f_photo = 0.75. However, non-functional N is already substracted from leaf-N in the cropN_std module, therefore f_photo = 1.0 as default."); - frame.set ("f_photo", 1.0); - - frame.declare_object ("value", Number::component, - Attribute::Const, Attribute::Singleton, "\ + Model* make (const BlockModel& al) const + { return new rubiscoNdist_expr (al); } + + rubiscoNdist_exprSyntax () + : DeclareModel (RubiscoNdist::component, "expr", + "expr rubisco N-distribution model in the canopy.") + { } + void load_frame (Frame& frame) const + { + Model::declare_obsolete (frame, "Experimental, avoid"); + frame.declare ("f_photo", Attribute::None (), Check::positive (), Attribute::Const, + "Fraction of photosynthetically active N in canopy. According to (Boegh et al., 2002) f_photo = 0.75. However, non-functional N is already substracted from leaf-N in the cropN_std module, therefore f_photo = 1.0 as default."); + frame.set ("f_photo", 1.0); + + frame.declare_object ("value", Number::component, + Attribute::Const, Attribute::Singleton, "\ Expression that evaluates to the relative rubisco N intesity where 1 is the value in top of the canopy."); - frame.order ("value"); - - } -} rubiscoNdist_exprsyntax; - - + frame.order ("value"); + + } + } rubiscoNdist_exprsyntax; +} diff --git a/src/daisy/crop/root/rubiscoNdist_forced.C b/src/daisy/crop/root/rubiscoNdist_forced.C index 2707f963d..aa06d2ab3 100644 --- a/src/daisy/crop/root/rubiscoNdist_forced.C +++ b/src/daisy/crop/root/rubiscoNdist_forced.C @@ -20,6 +20,7 @@ #define BUILD_DLL #include "daisy/crop/root/rubiscoNdist.h" +#include "daisy/daisy_registration_internal.h" #include "util/mathlib.h" #include "object_model/block_model.h" #include @@ -132,24 +133,26 @@ rubiscoNdist_forced } } -static struct rubiscoNdist_forcedSyntax : public DeclareModel +void +register_rubiscoNdist_forced_models () { - Model* make (const BlockModel& al) const - { return new rubiscoNdist_forced (al); } - - rubiscoNdist_forcedSyntax () - : DeclareModel (RubiscoNdist::component, "forced", - "Forced rubisco capacity distribution model in the canopy.") - { } - void load_frame (Frame& frame) const + static struct rubiscoNdist_forcedSyntax : public DeclareModel { - Model::declare_obsolete (frame, "Experimental, avoid"); - frame.declare_object ("value", Number::component, - Attribute::Const, Attribute::Singleton, "\ + Model* make (const BlockModel& al) const + { return new rubiscoNdist_forced (al); } + + rubiscoNdist_forcedSyntax () + : DeclareModel (RubiscoNdist::component, "forced", + "Forced rubisco capacity distribution model in the canopy.") + { } + void load_frame (Frame& frame) const + { + Model::declare_obsolete (frame, "Experimental, avoid"); + frame.declare_object ("value", Number::component, + Attribute::Const, Attribute::Singleton, "\ Expression that evaluates to the relative rubisco capacity where 1 is the value in top of the canopy."); - frame.order ("value"); - - } -} rubiscoNdist_forcedsyntax; - - + frame.order ("value"); + + } + } rubiscoNdist_forcedsyntax; +} diff --git a/src/daisy/crop/root/rubiscoNdist_uniform.C b/src/daisy/crop/root/rubiscoNdist_uniform.C index b70612ec2..91cb4c503 100644 --- a/src/daisy/crop/root/rubiscoNdist_uniform.C +++ b/src/daisy/crop/root/rubiscoNdist_uniform.C @@ -20,6 +20,7 @@ #define BUILD_DLL #include "daisy/crop/root/rubiscoNdist.h" +#include "daisy/daisy_registration_internal.h" #include "util/mathlib.h" #include #include "object_model/check.h" @@ -76,21 +77,23 @@ rubiscoNdistUniform::rubiscoN_distribution (const Units&, } -static struct rubiscoNdistUniformSyntax : public DeclareModel +void +register_rubiscoNdist_uniform_models () { - Model* make (const BlockModel& al) const - { return new rubiscoNdistUniform (al); } - rubiscoNdistUniformSyntax () - : DeclareModel (RubiscoNdist::component, "uniform", - "Uniform rubisco N-distribution model in the canopy for photosynthesis.") - { } - void load_frame (Frame& frame) const + static struct rubiscoNdistUniformSyntax : public DeclareModel { - frame.declare ("f_photo", Attribute::None (), Check::positive (), Attribute::Const, - "Fraction of photosynthetically active N in canopy, f_photo = 0.75 (Boegh et al., 2002). However, non-functional N is already substracted from leaf-N in the cropN_std module, therefore f_photo = 1.0 as default."); - frame.set ("f_photo", 1.0); - - } -} rubiscoNdistUniform_syntax; - - + Model* make (const BlockModel& al) const + { return new rubiscoNdistUniform (al); } + rubiscoNdistUniformSyntax () + : DeclareModel (RubiscoNdist::component, "uniform", + "Uniform rubisco N-distribution model in the canopy for photosynthesis.") + { } + void load_frame (Frame& frame) const + { + frame.declare ("f_photo", Attribute::None (), Check::positive (), Attribute::Const, + "Fraction of photosynthetically active N in canopy, f_photo = 0.75 (Boegh et al., 2002). However, non-functional N is already substracted from leaf-N in the cropN_std module, therefore f_photo = 1.0 as default."); + frame.set ("f_photo", 1.0); + + } + } rubiscoNdistUniform_syntax; +} diff --git a/src/daisy/crop/root/solupt.C b/src/daisy/crop/root/solupt.C index 3e8134ca4..984fbc5be 100644 --- a/src/daisy/crop/root/solupt.C +++ b/src/daisy/crop/root/solupt.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/crop/root/solupt.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" #include "util/mathlib.h" @@ -58,16 +59,6 @@ Solupt::Solupt (const BlockModel& al) Solupt::~Solupt () { } -static struct SoluptInit : public DeclareComponent -{ - SoluptInit () - : DeclareComponent (Solupt::component, "\ -The 'solute_uptake' component calculates uptake of nitrogen through roots.") - { } - void load_frame (Frame& frame) const - { Model::load_model (frame); } -} Solupt_init; - // The 'none' model. struct SoluptNone final : public Solupt @@ -100,17 +91,6 @@ struct SoluptNone final : public Solupt { } }; -static struct SoluptNoneSyntax : DeclareModel -{ - Model* make (const BlockModel& al) const - { return new SoluptNone (al); } - SoluptNoneSyntax () - : DeclareModel (Solupt::component, "none", "No uptake.") - { } - void load_frame (Frame& frame) const - { } -} SoluptNone_syntax; - // The 'diffusion' base model. struct SoluptDiffusion : public Solupt @@ -237,40 +217,6 @@ SoluptDiffusion::diffusion (const Geometry& geo, const Soil& soil, } } -static struct SoluteDiffusionSyntax : DeclareBase -{ - SoluteDiffusionSyntax () - : DeclareBase (Solupt::component, "diffusion", "\ -N is transported to the root surface based on diffusion and convection.\n\ -\n\ -The convection is based on concentration in the soil, while the\n\ -diffusion is based on concentration in both soil and at root surfaces.\n\ -\n\ -This base model find variables 'A' and 'B', so the transport of\n\ -nitrogen to the root surface is calculated as A - B * CRoot, where\n\ -CRoot is the concentration at the root surface.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "daisyN"); - frame.declare ("D", "cm^2/h", Check::none (), - Attribute::LogOnly, Attribute::SoilCells, - "Diffusion variable."); - frame.declare ("alpha", Attribute::None (), Check::none (), - Attribute::LogOnly, Attribute::SoilCells, - "Internal variable."); - frame.declare ("beta", Attribute::None (), Check::none (), - Attribute::LogOnly, Attribute::SoilCells, - "Internal variable."); - frame.declare ("A", Attribute::None (), Check::none (), - Attribute::LogOnly, Attribute::SoilCells, - "CRoot independent N uptake."); - frame.declare ("B", Attribute::None (), Check::none (), - Attribute::LogOnly, Attribute::SoilCells, - "CRoot dependent N uptake factor."); - } -} SoluteDiffusion_syntax; - // The 'fixed_sink' model. struct SoluptFixed final : public SoluptDiffusion @@ -379,21 +325,6 @@ SoluptFixed::value (const Geometry& geo, const Soil& soil, return geo.total_surface (uptake) * 1.0e4; } -static struct SoluptFixedSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new SoluptFixed (al); } - SoluptFixedSyntax () - : DeclareModel (Solupt::component, "fixed_sink", "diffusion", "\ -Find the highest value of 'CRoot' that meets the N demand.") - { } - void load_frame (Frame& frame) const - { - frame.declare ("CRoot", "g N/cm^3", Check::none (), Attribute::LogOnly, - "Nitrogen concentration at root surface."); - } -} SoluptFixed_syntax; - // The 'variable_sink' model. struct SoluptVariable : public SoluptDiffusion @@ -572,57 +503,6 @@ SoluptVariable::value (const Geometry& geo, const Soil& soil, return std::min (max_uptake, PotNUpt); } -static struct SoluptVariableSyntax : public DeclareModel -{ - SoluptVariableSyntax () - : DeclareModel (Solupt::component, "variable_sink", "diffusion", "\ -Nitrogen uptake limited by the root ability to assimilate N.\n\ -\n\ -The transport of N to the root surface is given as \n\ -\n\ - A - B C\n\ -\n\ -The assimilation of N from root surface is given as\n\ -\n\ - F1 C / (K1 + C) + F2 C / (K2 + C) \n\ -\n\ -We find the C for which \n\ -\n\ - A - B C = F1 C / (K1 + C) + F2 C / (K2 + C)\n\ -\n\ -If this is higher than the demand, uptake is scaled down.") - { } - Model* make (const BlockModel& al) const - { return new SoluptVariable (al); } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "tsay2007nitrate", "miller2005root"); - frame.declare ("K1", "g N/cm^3", Check::positive (), Attribute::Const, - "K parameter for high affinity uptake."); - frame.set_cited ("K1", 0.7e-6, "50 uM", "tsay2007nitrate"); - frame.declare ("K2", "g N/cm^3", Check::positive (), Attribute::Const, - "K parameter for low affinity uptake."); - frame.set_cited ("K2", 70.0e-6, "5 mM", "tsay2007nitrate"); - frame.declare_fraction ("F_relative", Attribute::Const, "\ -Fraction of max uptake accounted for by high affinity uptake."); - frame.set ("F_relative", 0.1); - frame.declare ("C1", "g N/cm^3", Check::none (), Attribute::LogOnly, - Attribute::SoilCells, - "CRoot calculated assuming C >> K1.\n\ -Solution to A - B C = F1 + F2 C / (K2 + C)."); - frame.declare ("C2", "g N/cm^3", Check::none (), Attribute::LogOnly, - Attribute::SoilCells, - "CRoot calculated assuming C << K2.\n\ -Solution to A - B C = F1 C / (K1 + C) + F2 C / K2."); - frame.declare ("CEst", "g N/cm^3", Check::none (), Attribute::LogOnly, - Attribute::SoilCells, - "Best of C1 or C2.."); - frame.declare ("CRoot", "g N/cm^3", Check::none (), Attribute::LogOnly, - Attribute::SoilCells, - "Nitrogen concentration at root surface."); - } -} SoluptVariable_syntax; - // The 'solute_uptake' Number model static void @@ -981,36 +861,6 @@ Concentration at root surface."); { } }; -static struct NumberSoluteUptakeSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new NumberSoluteUptake (al); } - NumberSoluteUptakeSyntax() - : DeclareModel (Number::component, "solute_uptake", - "Find root nitrogen uptake.") - { } - void load_frame (Frame& frame) const - { - frame.declare_object ("Theta", Number::component, "See root system."); - frame.declare_object ("Theta_sat", Number::component, "See root system."); - frame.declare_object ("S_w", Number::component, "See root system."); - frame.declare_object ("C_l", Number::component, "See root system."); - frame.declare_object ("PotNUpt", Number::component, "See root system."); - frame.declare_object ("L", Number::component, "See root system."); - frame.declare_object ("I_max", Number::component, "See root system."); - frame.declare_object ("C_root_min", Number::component, "See root system."); - frame.declare_object ("diffusion_coef", Number::component, "See root system."); - frame.declare_object ("volume", Number::component, "See root system."); - frame.declare_object ("Rad", Number::component, "See root system."); - frame.declare_object ("value", Number::component, "Value to return\n\ -One of 'uptake', 'C_root', 'D', 'alpha', 'beta'."); - } -} NumberSoluteUptake_syntax; - -static DeclareSubmodel solute_uptake_submodel (NumberSoluteUptake::result_syntax, - "SoluteUptakeResult", "\ -Result of the 'solute_uptake' number model."); - // The 'solute_uptake2' Number model static void @@ -1413,35 +1263,183 @@ Concentration at root surface (mechanism 2 dominating)."); { } }; -static struct NumberSoluteUptake2Syntax : public DeclareModel +void +register_solupt_models () { - Model* make (const BlockModel& al) const - { return new NumberSoluteUptake2 (al); } - NumberSoluteUptake2Syntax() - : DeclareModel (Number::component, "solute_uptake2", - "Find root nitrogen uptake.") - { } - void load_frame (Frame& frame) const + static struct SoluptInit : public DeclareComponent + { + SoluptInit () + : DeclareComponent (Solupt::component, "\ +The 'solute_uptake' component calculates uptake of nitrogen through roots.") + { } + void load_frame (Frame& frame) const + { Model::load_model (frame); } + } Solupt_init; + static struct SoluptNoneSyntax : DeclareModel + { + Model* make (const BlockModel& al) const + { return new SoluptNone (al); } + SoluptNoneSyntax () + : DeclareModel (Solupt::component, "none", "No uptake.") + { } + void load_frame (Frame& frame) const + { } + } SoluptNone_syntax; + static struct SoluteDiffusionSyntax : DeclareBase + { + SoluteDiffusionSyntax () + : DeclareBase (Solupt::component, "diffusion", "\ +N is transported to the root surface based on diffusion and convection.\n\ +\n\ +The convection is based on concentration in the soil, while the\n\ +diffusion is based on concentration in both soil and at root surfaces.\n\ +\n\ +This base model find variables 'A' and 'B', so the transport of\n\ +nitrogen to the root surface is calculated as A - B * CRoot, where\n\ +CRoot is the concentration at the root surface.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "daisyN"); + frame.declare ("D", "cm^2/h", Check::none (), + Attribute::LogOnly, Attribute::SoilCells, + "Diffusion variable."); + frame.declare ("alpha", Attribute::None (), Check::none (), + Attribute::LogOnly, Attribute::SoilCells, + "Internal variable."); + frame.declare ("beta", Attribute::None (), Check::none (), + Attribute::LogOnly, Attribute::SoilCells, + "Internal variable."); + frame.declare ("A", Attribute::None (), Check::none (), + Attribute::LogOnly, Attribute::SoilCells, + "CRoot independent N uptake."); + frame.declare ("B", Attribute::None (), Check::none (), + Attribute::LogOnly, Attribute::SoilCells, + "CRoot dependent N uptake factor."); + } + } SoluteDiffusion_syntax; + static struct SoluptFixedSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new SoluptFixed (al); } + SoluptFixedSyntax () + : DeclareModel (Solupt::component, "fixed_sink", "diffusion", "\ +Find the highest value of 'CRoot' that meets the N demand.") + { } + void load_frame (Frame& frame) const + { + frame.declare ("CRoot", "g N/cm^3", Check::none (), Attribute::LogOnly, + "Nitrogen concentration at root surface."); + } + } SoluptFixed_syntax; + static struct SoluptVariableSyntax : public DeclareModel { - frame.declare_object ("Theta", Number::component, "See root system."); - frame.declare_object ("Theta_sat", Number::component, "See root system."); - frame.declare_object ("S_w", Number::component, "See root system."); - frame.declare_object ("C_l", Number::component, "See root system."); - frame.declare_object ("L", Number::component, "See root system."); - frame.declare_object ("F1", Number::component, "See root system."); - frame.declare_object ("K1", Number::component, "See root system."); - frame.declare_object ("F2", Number::component, "See root system."); - frame.declare_object ("K2", Number::component, "See root system."); - frame.declare_object ("diffusion_coef", Number::component, "See root system."); - frame.declare_object ("volume", Number::component, "See root system."); - frame.declare_object ("Rad", Number::component, "See root system."); - frame.declare_object ("value", Number::component, "Value to return\n\ + SoluptVariableSyntax () + : DeclareModel (Solupt::component, "variable_sink", "diffusion", "\ +Nitrogen uptake limited by the root ability to assimilate N.\n\ +\n\ +The transport of N to the root surface is given as \n\ +\n\ + A - B C\n\ +\n\ +The assimilation of N from root surface is given as\n\ +\n\ + F1 C / (K1 + C) + F2 C / (K2 + C) \n\ +\n\ +We find the C for which \n\ +\n\ + A - B C = F1 C / (K1 + C) + F2 C / (K2 + C)\n\ +\n\ +If this is higher than the demand, uptake is scaled down.") + { } + Model* make (const BlockModel& al) const + { return new SoluptVariable (al); } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "tsay2007nitrate", "miller2005root"); + frame.declare ("K1", "g N/cm^3", Check::positive (), Attribute::Const, + "K parameter for high affinity uptake."); + frame.set_cited ("K1", 0.7e-6, "50 uM", "tsay2007nitrate"); + frame.declare ("K2", "g N/cm^3", Check::positive (), Attribute::Const, + "K parameter for low affinity uptake."); + frame.set_cited ("K2", 70.0e-6, "5 mM", "tsay2007nitrate"); + frame.declare_fraction ("F_relative", Attribute::Const, "\ +Fraction of max uptake accounted for by high affinity uptake."); + frame.set ("F_relative", 0.1); + frame.declare ("C1", "g N/cm^3", Check::none (), Attribute::LogOnly, + Attribute::SoilCells, + "CRoot calculated assuming C >> K1.\n\ +Solution to A - B C = F1 + F2 C / (K2 + C)."); + frame.declare ("C2", "g N/cm^3", Check::none (), Attribute::LogOnly, + Attribute::SoilCells, + "CRoot calculated assuming C << K2.\n\ +Solution to A - B C = F1 C / (K1 + C) + F2 C / K2."); + frame.declare ("CEst", "g N/cm^3", Check::none (), Attribute::LogOnly, + Attribute::SoilCells, + "Best of C1 or C2.."); + frame.declare ("CRoot", "g N/cm^3", Check::none (), Attribute::LogOnly, + Attribute::SoilCells, + "Nitrogen concentration at root surface."); + } + } SoluptVariable_syntax; + static struct NumberSoluteUptakeSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new NumberSoluteUptake (al); } + NumberSoluteUptakeSyntax() + : DeclareModel (Number::component, "solute_uptake", + "Find root nitrogen uptake.") + { } + void load_frame (Frame& frame) const + { + frame.declare_object ("Theta", Number::component, "See root system."); + frame.declare_object ("Theta_sat", Number::component, "See root system."); + frame.declare_object ("S_w", Number::component, "See root system."); + frame.declare_object ("C_l", Number::component, "See root system."); + frame.declare_object ("PotNUpt", Number::component, "See root system."); + frame.declare_object ("L", Number::component, "See root system."); + frame.declare_object ("I_max", Number::component, "See root system."); + frame.declare_object ("C_root_min", Number::component, "See root system."); + frame.declare_object ("diffusion_coef", Number::component, "See root system."); + frame.declare_object ("volume", Number::component, "See root system."); + frame.declare_object ("Rad", Number::component, "See root system."); + frame.declare_object ("value", Number::component, "Value to return\n\ +One of 'uptake', 'C_root', 'D', 'alpha', 'beta'."); + } + } NumberSoluteUptake_syntax; + static DeclareSubmodel solute_uptake_submodel (NumberSoluteUptake::result_syntax, + "SoluteUptakeResult", "\ +Result of the 'solute_uptake' number model."); + static struct NumberSoluteUptake2Syntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new NumberSoluteUptake2 (al); } + NumberSoluteUptake2Syntax() + : DeclareModel (Number::component, "solute_uptake2", + "Find root nitrogen uptake.") + { } + void load_frame (Frame& frame) const + { + frame.declare_object ("Theta", Number::component, "See root system."); + frame.declare_object ("Theta_sat", Number::component, "See root system."); + frame.declare_object ("S_w", Number::component, "See root system."); + frame.declare_object ("C_l", Number::component, "See root system."); + frame.declare_object ("L", Number::component, "See root system."); + frame.declare_object ("F1", Number::component, "See root system."); + frame.declare_object ("K1", Number::component, "See root system."); + frame.declare_object ("F2", Number::component, "See root system."); + frame.declare_object ("K2", Number::component, "See root system."); + frame.declare_object ("diffusion_coef", Number::component, "See root system."); + frame.declare_object ("volume", Number::component, "See root system."); + frame.declare_object ("Rad", Number::component, "See root system."); + frame.declare_object ("value", Number::component, "Value to return\n\ One of 'uptake', 'C_root', 'C1', 'C2', 'D', 'alpha', 'beta', 'A', 'B'."); - } -} NumberSoluteUptake2_syntax; - -static DeclareSubmodel solute_uptake2_submodel (NumberSoluteUptake2::result_syntax, - "SoluteUptake2Result", "\ + } + } NumberSoluteUptake2_syntax; + static DeclareSubmodel solute_uptake2_submodel (NumberSoluteUptake2::result_syntax, + "SoluteUptake2Result", "\ Result of the 'solute_uptake2' number model."); +} // solupt.C ends here + diff --git a/src/daisy/crop/seed.C b/src/daisy/crop/seed.C index 4ee6b31b8..beb9d2d00 100644 --- a/src/daisy/crop/seed.C +++ b/src/daisy/crop/seed.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/crop/seed.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" @@ -40,15 +41,23 @@ Seed::Seed (const BlockModel& al) Seed::~Seed () { } -static struct SeedInit : public DeclareComponent +void +register_seed_models () { - SeedInit () - : DeclareComponent (Seed::component, "\ + static struct SeedInit : public DeclareComponent + { + SeedInit () + : DeclareComponent (Seed::component, "\ Initial growth after emergence.\n\ \n\ The initial growth process governs the growth of the crop until the\n\ point where there is enough leaf area for photosynthesis to take over.") - { } -} Seed_init; + { } + } Seed_init; + + register_seed_LAI_models (); + register_seed_release_models (); +} // seed.C ends here. + diff --git a/src/daisy/crop/seed_LAI.C b/src/daisy/crop/seed_LAI.C index a1eb700c4..2b6c96076 100644 --- a/src/daisy/crop/seed_LAI.C +++ b/src/daisy/crop/seed_LAI.C @@ -20,6 +20,7 @@ #define BUILD_DLL #include "daisy/crop/seed.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" #include "object_model/plf.h" @@ -96,7 +97,6 @@ SeedLAI::forced_CAI (const double WLeaf, const double SpLAI, const double DS) // This is then our initial CAI esstimate. const double CAI_init = std::min (CAI_max, CAI_fixed); - // If CAI_init is below CAI_exit, we will exit initialization phase. // The idea is that enough leaf DM has been generated to account for // the LAI using the ordinary mechanism, so we no longer need the @@ -110,35 +110,40 @@ SeedLAI::forced_CAI (const double WLeaf, const double SpLAI, const double DS) return -1.0; // No force. } -static struct Seed_LAISyntax : public DeclareModel +void +register_seed_LAI_models () { - Model* make (const BlockModel& al) const - { return new SeedLAI (al); } - Seed_LAISyntax () - : DeclareModel (Seed::component, "LAI", "\ -Initial crop growth is governed by a forced LAI function.") - { } - void load_frame (Frame& frame) const + static struct Seed_LAISyntax : public DeclareModel { - // Parameters. - frame.declare ("DSLAI05", "DS", Attribute::Const, - "DS at CAI=0.5; initial phase."); - frame.set ("DSLAI05", 0.15); - frame.declare ("SpLAIfac", "DS", Attribute::None (), Attribute::Const, "\ + Model* make (const BlockModel& al) const + { return new SeedLAI (al); } + Seed_LAISyntax () + : DeclareModel (Seed::component, "LAI", "\ +Initial crop growth is governed by a forced LAI function.") + { } + void load_frame (Frame& frame) const + { + // Parameters. + frame.declare ("DSLAI05", "DS", Attribute::Const, + "DS at CAI=0.5; initial phase."); + frame.set ("DSLAI05", 0.15); + frame.declare ("SpLAIfac", "DS", Attribute::None (), Attribute::Const, "\ Factor defining maximum specific leaf weight.\n\ Only used during the initial phase."); - PLF SpLf; - SpLf.add (0.00, 3.00); - SpLf.add (0.20, 1.50); - SpLf.add (0.40, 1.25); - SpLf.add (0.60, 1.00); - frame.set ("SpLAIfac", SpLf); - - // State. - frame.declare_boolean ("InitCAI", Attribute::State, - "Initial CAI development phase."); - frame.set ("InitCAI", true); - } -} SeedLAI_syntax; + PLF SpLf; + SpLf.add (0.00, 3.00); + SpLf.add (0.20, 1.50); + SpLf.add (0.40, 1.25); + SpLf.add (0.60, 1.00); + frame.set ("SpLAIfac", SpLf); + + // State. + frame.declare_boolean ("InitCAI", Attribute::State, + "Initial CAI development phase."); + frame.set ("InitCAI", true); + } + } SeedLAI_syntax; +} // seed_LAI.C ends here. + diff --git a/src/daisy/crop/seed_release.C b/src/daisy/crop/seed_release.C index bc06b2eaf..f53c388ac 100644 --- a/src/daisy/crop/seed_release.C +++ b/src/daisy/crop/seed_release.C @@ -20,6 +20,7 @@ #define BUILD_DLL #include "daisy/crop/seed.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" #include "daisy/output/log.h" @@ -121,39 +122,44 @@ SeedRelease::SeedRelease (const BlockModel& al) SeedRelease::~SeedRelease () { } -static struct Seed_ReleaseSyntax : public DeclareModel +void +register_seed_release_models () { - Model* make (const BlockModel& al) const - { return new SeedRelease (al); } - Seed_ReleaseSyntax () - : DeclareModel (Seed::component, "release", "\ -Initial crop growth is governed by carbon released from seeds.") - { } - void load_frame (Frame& frame) const + static struct Seed_ReleaseSyntax : public DeclareModel { - frame.declare ("initial_weight", "g w.w./m^2", - Check::positive (), Attribute::OptionalConst, "\ + Model* make (const BlockModel& al) const + { return new SeedRelease (al); } + Seed_ReleaseSyntax () + : DeclareModel (Seed::component, "release", "\ +Initial crop growth is governed by carbon released from seeds.") + { } + void load_frame (Frame& frame) const + { + frame.declare ("initial_weight", "g w.w./m^2", + Check::positive (), Attribute::OptionalConst, "\ Initial seed weight to use when not specified by the sow operation.\n\ If not specified here, specifying seed amount when sowing is mandatory."); - frame.declare ("DM_fraction", Attribute::Fraction (), Attribute::Const, "\ + frame.declare ("DM_fraction", Attribute::Fraction (), Attribute::Const, "\ Dry matter content in seeds."); - frame.declare ("C_fraction", Attribute::Fraction (), Attribute::Const, "\ + frame.declare ("C_fraction", Attribute::Fraction (), Attribute::Const, "\ Carbon content in seeds."); - frame.declare ("N_fraction", Attribute::Fraction (), Attribute::Const, "\ + frame.declare ("N_fraction", Attribute::Fraction (), Attribute::Const, "\ Nitrogen content in seeds."); - frame.declare ("T_factor", "dg C", Attribute::Fraction (), - Attribute::OptionalConst, "\ + frame.declare ("T_factor", "dg C", Attribute::Fraction (), + Attribute::OptionalConst, "\ Soil temperature effect on release rate.\n\ By default use the same as for maintenance respiration:\ 0.4281 (exp (0.57 - 0.024 T + 0.0020 T^2) - exp (0.57 - 0.042 T - 0.0051 T^2))\ \n\ This will give a rate of 1 at 20 dg C, slightly above 2 at 30 dg C, and a \ bit below 0.5 at 10 dg C."); - frame.declare ("rate", "h^-1", Check::positive (), Attribute::Const, "\ + frame.declare ("rate", "h^-1", Check::positive (), Attribute::Const, "\ Release rate of seed carbon to assimilate pool."); - frame.declare ("C", "g C/m^2", Check::non_negative (), Attribute::OptionalState, "\ + frame.declare ("C", "g C/m^2", Check::non_negative (), Attribute::OptionalState, "\ Unreleased carbon left in seeds."); - } -} SeedRelease_syntax; + } + } SeedRelease_syntax; +} // seed_release.C ends here. + diff --git a/src/daisy/crop/stomatacon.C b/src/daisy/crop/stomatacon.C index e4a9fc1a3..5bd78658a 100644 --- a/src/daisy/crop/stomatacon.C +++ b/src/daisy/crop/stomatacon.C @@ -1,284 +1,288 @@ -// stomatacon.C -- Calculating stomata conductance -// -// Copyright 2008 Birgitte Gjettermann, Per Abrahamsen and KU. -// -// This file is part of Daisy. -// -// Daisy is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version.5 -// -// Daisy is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser Public License for more details. -// -// You should have received a copy of the GNU Lesser Public License -// along with Daisy; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -#define BUILD_DLL - -#include "daisy/crop/stomatacon.h" -#include "util/mathlib.h" -#include "object_model/block_model.h" -#include "object_model/librarian.h" -#include "object_model/check.h" -#include - -// The 'stomatacon' component. - -const char *const StomataCon::component = "stomatacon"; - -symbol -StomataCon::library_id () const -{ - static const symbol id (component); - return id; -} - -StomataCon::StomataCon (const BlockModel& al) - : ModelLogable (al.type_name ()) -{ } - -StomataCon::~StomataCon () -{ } - -static struct StomataConInit : public DeclareComponent -{ - StomataConInit () - : DeclareComponent (StomataCon::component, "\ -The 'Stomatacon' component calculates the stomata conductance of water vapour.") - { } - void load_frame (Frame& frame) const - { Model::load_model (frame); } -} StomataCon_init; - -// The 'WSF' stomatacon base model. - -double -StomataCon_WSF_base::wsf (const double ABA /* [g/cm^3] */, - const double h_x /* [MPa] */) const -{ - daisy_assert (ABA >= 0.0); - daisy_assert (h_x >= 0.0); - const double wsf - = std::exp (-beta * std::max (ABA - ABA_min, 0.0)) - * std::exp (-delta * h_x); - if (wsf <= 0.0) - { - std::ostringstream tmp; - tmp << "wsf = " << wsf - << ", beta = " << beta - << ", ABA = " << ABA - << ", ABA_min = " << ABA_min - << ", ABA effect = " - << std::exp (-beta * std::max (ABA - ABA_min, 0.0)) // - << ", delta = " << delta - << ", h_x = " << h_x - << ", Psi effect = " << std::exp (-delta * h_x); - Assertion::message (tmp.str ()); - return 1.0; - } - - return wsf; -} - -StomataCon_WSF_base::StomataCon_WSF_base (const BlockModel& al) - : StomataCon (al), - beta (al.number ("beta")), - ABA_min (al.number ("ABA_min")), - delta (al.number ("delta")) -{ } - -static struct StomataConWSFSyntax : public DeclareBase -{ - StomataConWSFSyntax () - : DeclareBase (StomataCon::component, "WSF", "\ -Common water stress effect parameters.") - { } - void load_frame (Frame& frame) const - { - frame.declare ("beta", "cm^3/g", Check::non_negative (), Attribute::Const, - "Effect of ABA concentration.\n\ -The effect is exp (-beta (|ABA| - ABA_min)), where |ABA| is the ABA\n\ -concentration in the xylem."); - frame.set ("beta", 0.0); - frame.declare ("ABA_min", "g/cm^3", Check::non_negative (), - Attribute::Const, - "Level of ABA with unstressed production."); - frame.set ("ABA_min", 0.0); - frame.declare ("delta", "MPa^-1", Check::non_negative (), Attribute::Const, - "Effect of crown water potential.\n\ -The effect is exp (-delta |psi_c|), where psi_c is the crown potential."); - frame.set ("delta", 0.0); - } -} StomataConWSF_syntax; - -// The 'BB_base' stomatacon base model. - -struct StomataCon_BB_base : public StomataCon_WSF_base -{ - // Parameters. - const double m; // Stomatal slope factor. - const double b; // Stomatal intercept. - - // Simulation. - double minimum () const; - - // Create. - StomataCon_BB_base (const BlockModel&); -}; - -double -StomataCon_BB_base::minimum () const -{ return b; } - -StomataCon_BB_base::StomataCon_BB_base (const BlockModel& al) - : StomataCon_WSF_base (al), - m (al.number("m")), - b (al.number("b")) -{ } - -static struct StomataConBBbaseSyntax : public DeclareBase -{ - StomataConBBbaseSyntax () - : DeclareBase (StomataCon::component, "BB_base", "WSF", "\ -Common parameters for Ball&Berry derived models.") - { } - void load_frame (Frame& frame) const - { - frame.declare ("m", Attribute::None (), Check::positive (), - Attribute::Const, "\ -Stomatal slope factor.\n\ -Ball and Berry (1982): m = 9 for soyabean.\n\ -Wang and Leuning(1998): m = 11 for wheat"); - frame.declare ("b", "mol/m^2/s", Check::positive (), Attribute::Const, "\ -Stomatal intercept.\n \ -Ball and Berry (1982) & Wang and Leuning(1998): (0.01 mol/m2/s)"); - } -} StomataConBBbase_syntax; - -// The 'BB' stomatacon model. - -struct StomataCon_BB : public StomataCon_BB_base -{ - double stomata_con (const double ABA, // [g/cm^3] - const double h_x, // [MPa] - const double hs, - const double pz, const double Ptot, const double cs, - const double Gamma, - const double, Treelog&); - - void output (Log&) const - { } - - // Create. - StomataCon_BB (const BlockModel& al) - : StomataCon_BB_base (al) - { } -}; - -double -StomataCon_BB::stomata_con (const double ABA, // [g/cm^3] - const double h_x, // [MPa] - const double hs /*[]*/, - const double pz /*[mol/m²leaf/s]*/, - const double Ptot /*[Pa]*/, - const double cs /*[Pa]*/, - const double, - const double, Treelog&) -{ - - if (pz <= 0.0) - return b; - daisy_assert (cs > 0.0); - const double gsw = wsf (ABA, h_x) * (m * hs * pz * Ptot)/cs + b; - - daisy_assert (gsw >= 0.0); - return gsw; -} - -static struct StomataConBBSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new StomataCon_BB (al); } - StomataConBBSyntax () - : DeclareModel (StomataCon::component, "BB", "BB_base", - "Stomata conductance calculated by the Ball & Berry model.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "bb87"); - } -} StomataConBBsyntax; - -// The 'Leuning' stomatacon model. - -struct StomataCon_Leuning : public StomataCon_BB_base -{ - // Parameters. - const double Do; - - // Simulation. - double stomata_con (const double ABA, // [g/cm^3] - const double h_x, // [MPa] - const double hs, - const double pz, const double Ptot, const double cs, - const double Gamma, const double Ds, Treelog&); - void output (Log&) const - { } - - // Create. - StomataCon_Leuning (const BlockModel& al) - : StomataCon_BB_base (al), - Do (al.number ("Do")) - { } -}; - -double -StomataCon_Leuning::stomata_con (const double ABA, // [g/cm^3] - const double h_x, // [MPa] - const double, - const double pz /*[mol/m²leaf/s]*/, - const double Ptot /*[Pa]*/, - const double cs /*[Pa]*/, - const double Gamma /*[Pa]*/, - const double Ds /*[Pa]*/, Treelog& msg) -{ - if (pz <= 0.0) - return b; - - daisy_assert (cs > Gamma); - daisy_assert (cs > 0.0); - daisy_assert (Gamma >= 0.0); - daisy_assert (pz > 0.0); - daisy_assert (Ds >= 0.0); - daisy_assert (((cs - Gamma)*(1 + Ds/Do)) > 0.0); - - const double gsw - = wsf (ABA, h_x) * (m * pz * Ptot)/((cs - Gamma)*(1 + Ds/Do)) + b; - daisy_assert (gsw >= 0.0); - - return gsw; -} - -static struct StomataConLeuningSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new StomataCon_Leuning (al); } - StomataConLeuningSyntax () - : DeclareModel (StomataCon::component, "Leuning", "BB_base", "\ -Stomata conductance calculated by the Leuning model.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "Leuning95"); - frame.declare ("Do", "[Pa]", Check::positive (), Attribute::Const, - "Empirical coefficient."); - frame.set ("Do", 1500.); - } -} StomataConLeuningsyntax; - -// StomataCon.C ends here. +// stomatacon.C -- Calculating stomata conductance +// +// Copyright 2008 Birgitte Gjettermann, Per Abrahamsen and KU. +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version.5 +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#define BUILD_DLL + +#include "daisy/crop/stomatacon.h" +#include "daisy/daisy_registration_internal.h" +#include "util/mathlib.h" +#include "object_model/block_model.h" +#include "object_model/librarian.h" +#include "object_model/check.h" +#include + +// The 'stomatacon' component. + +const char *const StomataCon::component = "stomatacon"; + +symbol +StomataCon::library_id () const +{ + static const symbol id (component); + return id; +} + +StomataCon::StomataCon (const BlockModel& al) + : ModelLogable (al.type_name ()) +{ } + +StomataCon::~StomataCon () +{ } + +// The 'WSF' stomatacon base model. + +double +StomataCon_WSF_base::wsf (const double ABA /* [g/cm^3] */, + const double h_x /* [MPa] */) const +{ + daisy_assert (ABA >= 0.0); + daisy_assert (h_x >= 0.0); + const double wsf + = std::exp (-beta * std::max (ABA - ABA_min, 0.0)) + * std::exp (-delta * h_x); + if (wsf <= 0.0) + { + std::ostringstream tmp; + tmp << "wsf = " << wsf + << ", beta = " << beta + << ", ABA = " << ABA + << ", ABA_min = " << ABA_min + << ", ABA effect = " + << std::exp (-beta * std::max (ABA - ABA_min, 0.0)) // + << ", delta = " << delta + << ", h_x = " << h_x + << ", Psi effect = " << std::exp (-delta * h_x); + Assertion::message (tmp.str ()); + return 1.0; + } + + return wsf; +} + +StomataCon_WSF_base::StomataCon_WSF_base (const BlockModel& al) + : StomataCon (al), + beta (al.number ("beta")), + ABA_min (al.number ("ABA_min")), + delta (al.number ("delta")) +{ } + +// The 'BB_base' stomatacon base model. + +struct StomataCon_BB_base : public StomataCon_WSF_base +{ + // Parameters. + const double m; // Stomatal slope factor. + const double b; // Stomatal intercept. + + // Simulation. + double minimum () const; + + // Create. + StomataCon_BB_base (const BlockModel&); +}; + +double +StomataCon_BB_base::minimum () const +{ return b; } + +StomataCon_BB_base::StomataCon_BB_base (const BlockModel& al) + : StomataCon_WSF_base (al), + m (al.number("m")), + b (al.number("b")) +{ } + +// The 'BB' stomatacon model. + +struct StomataCon_BB : public StomataCon_BB_base +{ + double stomata_con (const double ABA, // [g/cm^3] + const double h_x, // [MPa] + const double hs, + const double pz, const double Ptot, const double cs, + const double Gamma, + const double, Treelog&); + + void output (Log&) const + { } + + // Create. + StomataCon_BB (const BlockModel& al) + : StomataCon_BB_base (al) + { } +}; + +double +StomataCon_BB::stomata_con (const double ABA, // [g/cm^3] + const double h_x, // [MPa] + const double hs /*[]*/, + const double pz /*[mol/m²leaf/s]*/, + const double Ptot /*[Pa]*/, + const double cs /*[Pa]*/, + const double, + const double, Treelog&) +{ + + if (pz <= 0.0) + return b; + daisy_assert (cs > 0.0); + const double gsw = wsf (ABA, h_x) * (m * hs * pz * Ptot)/cs + b; + + daisy_assert (gsw >= 0.0); + return gsw; +} + +// The 'Leuning' stomatacon model. + +struct StomataCon_Leuning : public StomataCon_BB_base +{ + // Parameters. + const double Do; + + // Simulation. + double stomata_con (const double ABA, // [g/cm^3] + const double h_x, // [MPa] + const double hs, + const double pz, const double Ptot, const double cs, + const double Gamma, const double Ds, Treelog&); + void output (Log&) const + { } + + // Create. + StomataCon_Leuning (const BlockModel& al) + : StomataCon_BB_base (al), + Do (al.number ("Do")) + { } +}; + +double +StomataCon_Leuning::stomata_con (const double ABA, // [g/cm^3] + const double h_x, // [MPa] + const double, + const double pz /*[mol/m²leaf/s]*/, + const double Ptot /*[Pa]*/, + const double cs /*[Pa]*/, + const double Gamma /*[Pa]*/, + const double Ds /*[Pa]*/, Treelog& msg) +{ + if (pz <= 0.0) + return b; + + daisy_assert (cs > Gamma); + daisy_assert (cs > 0.0); + daisy_assert (Gamma >= 0.0); + daisy_assert (pz > 0.0); + daisy_assert (Ds >= 0.0); + daisy_assert (((cs - Gamma)*(1 + Ds/Do)) > 0.0); + + const double gsw + = wsf (ABA, h_x) * (m * pz * Ptot)/((cs - Gamma)*(1 + Ds/Do)) + b; + daisy_assert (gsw >= 0.0); + + return gsw; +} + +void +register_stomatacon_models () +{ + static struct StomataConInit : public DeclareComponent + { + StomataConInit () + : DeclareComponent (StomataCon::component, "\ +The 'Stomatacon' component calculates the stomata conductance of water vapour.") + { } + void load_frame (Frame& frame) const + { Model::load_model (frame); } + } StomataCon_init; + static struct StomataConWSFSyntax : public DeclareBase + { + StomataConWSFSyntax () + : DeclareBase (StomataCon::component, "WSF", "\ +Common water stress effect parameters.") + { } + void load_frame (Frame& frame) const + { + frame.declare ("beta", "cm^3/g", Check::non_negative (), Attribute::Const, + "Effect of ABA concentration.\n\ +The effect is exp (-beta (|ABA| - ABA_min)), where |ABA| is the ABA\n\ +concentration in the xylem."); + frame.set ("beta", 0.0); + frame.declare ("ABA_min", "g/cm^3", Check::non_negative (), + Attribute::Const, + "Level of ABA with unstressed production."); + frame.set ("ABA_min", 0.0); + frame.declare ("delta", "MPa^-1", Check::non_negative (), Attribute::Const, + "Effect of crown water potential.\n\ +The effect is exp (-delta |psi_c|), where psi_c is the crown potential."); + frame.set ("delta", 0.0); + } + } StomataConWSF_syntax; + static struct StomataConBBbaseSyntax : public DeclareBase + { + StomataConBBbaseSyntax () + : DeclareBase (StomataCon::component, "BB_base", "WSF", "\ +Common parameters for Ball&Berry derived models.") + { } + void load_frame (Frame& frame) const + { + frame.declare ("m", Attribute::None (), Check::positive (), + Attribute::Const, "\ +Stomatal slope factor.\n\ +Ball and Berry (1982): m = 9 for soyabean.\n\ +Wang and Leuning(1998): m = 11 for wheat"); + frame.declare ("b", "mol/m^2/s", Check::positive (), Attribute::Const, "\ +Stomatal intercept.\n \ +Ball and Berry (1982) & Wang and Leuning(1998): (0.01 mol/m2/s)"); + } + } StomataConBBbase_syntax; + static struct StomataConBBSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new StomataCon_BB (al); } + StomataConBBSyntax () + : DeclareModel (StomataCon::component, "BB", "BB_base", + "Stomata conductance calculated by the Ball & Berry model.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "bb87"); + } + } StomataConBBsyntax; + static struct StomataConLeuningSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new StomataCon_Leuning (al); } + StomataConLeuningSyntax () + : DeclareModel (StomataCon::component, "Leuning", "BB_base", "\ +Stomata conductance calculated by the Leuning model.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "Leuning95"); + frame.declare ("Do", "[Pa]", Check::positive (), Attribute::Const, + "Empirical coefficient."); + frame.set ("Do", 1500.); + } + } StomataConLeuningsyntax; + + register_stomatacon_SHA_models (); +} + +// StomataCon.C ends here. + diff --git a/src/daisy/crop/stomatacon_SHA.C b/src/daisy/crop/stomatacon_SHA.C index 497ad4cb9..0b09d4b51 100644 --- a/src/daisy/crop/stomatacon_SHA.C +++ b/src/daisy/crop/stomatacon_SHA.C @@ -1,283 +1,286 @@ -// stomatacon_SHA.C -- Stomata conductance calculated by Seyed Hamid Ahmadi. -// -// Copyright 2008 Birgitte Gjettermann and KU -// -// This file is part of Daisy. -// -// Daisy is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// Daisy is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the -// GNU Lesser Public License for more details. -// -// You should have received a copy of the GNU Lesser Public License -// along with Daisy; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -#define BUILD_DLL - -#include "daisy/crop/stomatacon.h" -#include "util/mathlib.h" -#include -#include "object_model/check.h" -#include "object_model/block_model.h" -#include "object_model/librarian.h" -#include "object_model/frame.h" - -struct StomataCon_SHA12 : public StomataCon_WSF_base -{ - // Parameters. -private: - const double lambda; // Assimilate exponent. [] - const double alpha; // Humidity exponent. [] - const double m; // Conductivity factor. [?] - const double gs_min; // Minimal gs value. [mol H2O/m^2 leaf/s] - - // Simulation. - double minimum () const - { return gs_min; } - double stomata_con (const double ABA, // [g/cm^3] - const double h_x, // [MPa] - const double hs, - const double pz, const double Ptot, const double cs, - const double Gamma, const double Ds, Treelog&); - void output (Log&) const - { } - - // Create. - public: - StomataCon_SHA12 (const BlockModel& al) - : StomataCon_WSF_base (al), - lambda (al.number ("lambda")), - alpha (al.number ("alpha")), - m (al.number ("m")), - gs_min (al.number ("min")) - { } -}; - -double -StomataCon_SHA12::stomata_con (const double ABA, // [g/cm^3] - const double h_x, // [MPa] - const double hs /*[]*/, - const double pz /*[mol/m²leaf/s]*/, - const double Ptot /*[Pa]*/, - const double cs /*[Pa]*/, - const double, const double, Treelog&) -{ - if (pz <= 0.0) - return gs_min; - const double cs_ppm = cs /*[Pa]*/ / Ptot /*[Pa]*/ * 1.0e6 /*[ppm]*/; - const double A = pz * 1e6; // [umol/m^2 LEAF/s] - return std::max (wsf (ABA, h_x) - * (m * pow(hs, alpha) * pow(A, lambda)) /(cs_ppm), - gs_min); -} - -static struct StomataConSHA12Syntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new StomataCon_SHA12 (al); } - StomataConSHA12Syntax () - : DeclareModel (StomataCon::component, "SHA12", "WSF", "\ -Stomata conductance calculated by the model given by Eq. 12.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "Ahmadi20091541"); - - frame.declare ("alpha", Attribute::None (), Check::non_negative (), - Attribute::Const, - "Humidity effect"); - frame.set ("alpha", 1.0); - frame.declare ("lambda", Attribute::None (), Check::non_negative (), - Attribute::Const, - "Net photosyhtesis effect"); - frame.set ("lambda", 1.0); - frame.declare ("m", Attribute::Unknown (), - Check::non_negative (), Attribute::Const, - "Slope parameter, dimension depends on alpha and lambda."); - frame.declare ("min", "mol H2O/m^2 leaf/s", - Check::positive (), Attribute::OptionalConst, - "Minimal conductivity."); - } -} StomataConSHA12syntax; - - -struct StomataCon_SHA14 : public StomataCon_WSF_base -{ - // Parameters. -private: - const double lambda; // Net photosynthesis effect [m^2 leaf s/mol CO2] - const double alpha; // Humidity effect [] - const double m; // Conductivity factor [mol H2O/m^2 leaf/s] - const double gs_max; // Maximum gs [mol/m^2 leaf/s] - - // Simulation. - double minimum () const - { - // Assuming wsf = 1.0, A = 0, hs = 0.0. - const double cs_min = 2.0; // [ppm] - return m / cs_min; - } - double stomata_con (const double ABA, // [g/cm^3] - const double h_x, // [MPa] - const double hs, - const double pz, const double Ptot, const double cs, - const double Gamma, - const double Ds, Treelog&); - void output (Log&) const - { } - - // Create. - public: - StomataCon_SHA14 (const BlockModel& al) - : StomataCon_WSF_base (al), - lambda (al.number ("lambda")), - alpha (al.number ("alpha")), - m (al.number ("m")), - gs_max (al.number ("max", -42.42e42)) - { } -}; - -double -StomataCon_SHA14::stomata_con (const double ABA, // [g/cm^3] - const double h_x, // [MPa] - const double hs /*[]*/, - const double pz /*[mol/m²leaf/s]*/, - const double Ptot /*[Pa]*/, - const double cs /*[Pa]*/, - const double, - const double, Treelog&) -{ - const double cs_ppm = cs /*[Pa]*/ / Ptot /*[Pa]*/ * 1.0e6 /*[ppm]*/; - const double A = std::max (pz, 0.0) * 1e6; // [umol/m^2 LEAF/s] - const double gsw = wsf (ABA, h_x) - * m * exp (hs * alpha) * exp (A * lambda) / cs_ppm; - daisy_assert (gsw >= 0.0); - - if (gs_max < 0.0) - return gsw; - return std::min (gsw, gs_max); -} - -static struct StomataConSHA14Syntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new StomataCon_SHA14 (al); } - StomataConSHA14Syntax () - : DeclareModel (StomataCon::component, "SHA14", "WSF", "\ -Stomata conductance calculated by the model given by Eq. 14.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "Ahmadi20091541"); - - frame.declare ("alpha", Attribute::None (), Check::non_negative (), - Attribute::Const, - "Humidity effect"); - frame.declare ("lambda", "m^2 leaf s/umol CO2", Check::non_negative (), - Attribute::Const, - "Net photosyhtesis effect"); - frame.declare ("m", "mol H2O/m^2 leaf/s", - Check::non_negative (), Attribute::Const, - "Conductivity factor."); - frame.declare ("max", "mol H2O/m^2 leaf/s", - Check::none (), Attribute::OptionalConst, - "Maximal conductivity.\n\ -By default, there is no maxium."); - } -} StomataConSHA14syntax; - -struct StomataCon_MNA : public StomataCon_WSF_base -{ - // Parameters. -private: - const double lambda; // Net photosynthesis effect [m^2 leaf s/mol CO2] - const double alpha; // Humidity effect [] - const double m; // Conductivity factor [mol H2O/m^2 leaf/s] - const double b; // Stomatal intercept. - const double gs_max; // Maximum gs [mol/m^2 leaf/s] - - // Simulation. - double minimum () const - { return b; } - double stomata_con (const double ABA, // [g/cm^3] - const double h_x, // [MPa] - const double hs, - const double pz, const double Ptot, const double cs, - const double Gamma, - const double Ds, Treelog&); - void output (Log&) const - { } - - // Create. - public: - StomataCon_MNA (const BlockModel& al) - : StomataCon_WSF_base (al), - lambda (al.number ("lambda")), - alpha (al.number ("alpha")), - m (al.number ("m")), - b (al.number ("b")), - gs_max (al.number ("max", -42.42e42)) - { } -}; - -double -StomataCon_MNA::stomata_con (const double ABA, // [g/cm^3] - const double h_x, // [MPa] - const double hs /*[]*/, - const double pz /*[mol/m²leaf/s]*/, - const double Ptot /*[Pa]*/, - const double cs /*[Pa]*/, - const double, - const double, Treelog&) -{ - if (pz <= 0.0) - return b; - - const double cs_ppm = cs /*[Pa]*/ / Ptot /*[Pa]*/ * 1.0e6 /*[ppm]*/; - const double A = pz * 1e6; // [umol/m^2 LEAF/s] - daisy_assert (A > 0.0); - const double gsw = b - + wsf (ABA, h_x) * m * exp (hs * alpha) * exp (lambda / A) / cs_ppm; - daisy_assert (gsw >= 0.0); - if (gs_max < 0.0) - return gsw; - return std::min (gsw, gs_max); -} - -static struct StomataConMNASyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new StomataCon_MNA (al); } - StomataConMNASyntax () - : DeclareModel (StomataCon::component, "MNA", "WSF", "\ -Stomata conductance calculated by the model given by Eq. 14.") - { } - void load_frame (Frame& frame) const - { - Model::declare_obsolete (frame, "We can't find a source to this equation."); - frame.declare ("alpha", Attribute::None (), Check::non_negative (), - Attribute::Const, - "Humidity effect"); - frame.declare ("lambda", "umol CO2/m^2 leaf/s", Check::non_positive (), - Attribute::Const, - "Net photosyhtesis effect"); - frame.declare ("m", "mol H2O/m^2 leaf/s", - Check::non_negative (), Attribute::Const, - "Conductivity factor."); - frame.declare ("b", "mol/m^2/s", Check::positive (), Attribute::Const, "\ -Stomatal intercept.\n\ -Ball and Berry (1982) & Wang and Leuning(1998): (0.01 mol/m2/s)"); - frame.declare ("max", "mol H2O/m^2 leaf/s", - Check::none (), Attribute::OptionalConst, - "Maximal conductivity.\n\ -By default, there is no maximum."); - } -} StomataConMNAsyntax; - -// stomatacon_SHA.C ends here. +// stomatacon_SHA.C -- Stomata conductance calculated by Seyed Hamid Ahmadi. +// +// Copyright 2008 Birgitte Gjettermann and KU +// +// This file is part of Daisy. +// +// Daisy is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// Daisy is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with Daisy; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#define BUILD_DLL + +#include "daisy/crop/stomatacon.h" +#include "daisy/daisy_registration_internal.h" +#include "util/mathlib.h" +#include +#include "object_model/check.h" +#include "object_model/block_model.h" +#include "object_model/librarian.h" +#include "object_model/frame.h" + +struct StomataCon_SHA12 : public StomataCon_WSF_base +{ + // Parameters. +private: + const double lambda; // Assimilate exponent. [] + const double alpha; // Humidity exponent. [] + const double m; // Conductivity factor. [?] + const double gs_min; // Minimal gs value. [mol H2O/m^2 leaf/s] + + // Simulation. + double minimum () const + { return gs_min; } + double stomata_con (const double ABA, // [g/cm^3] + const double h_x, // [MPa] + const double hs, + const double pz, const double Ptot, const double cs, + const double Gamma, const double Ds, Treelog&); + void output (Log&) const + { } + + // Create. + public: + StomataCon_SHA12 (const BlockModel& al) + : StomataCon_WSF_base (al), + lambda (al.number ("lambda")), + alpha (al.number ("alpha")), + m (al.number ("m")), + gs_min (al.number ("min")) + { } +}; + +double +StomataCon_SHA12::stomata_con (const double ABA, // [g/cm^3] + const double h_x, // [MPa] + const double hs /*[]*/, + const double pz /*[mol/m²leaf/s]*/, + const double Ptot /*[Pa]*/, + const double cs /*[Pa]*/, + const double, const double, Treelog&) +{ + if (pz <= 0.0) + return gs_min; + const double cs_ppm = cs /*[Pa]*/ / Ptot /*[Pa]*/ * 1.0e6 /*[ppm]*/; + const double A = pz * 1e6; // [umol/m^2 LEAF/s] + return std::max (wsf (ABA, h_x) + * (m * pow(hs, alpha) * pow(A, lambda)) /(cs_ppm), + gs_min); +} + +struct StomataCon_SHA14 : public StomataCon_WSF_base +{ + // Parameters. +private: + const double lambda; // Net photosynthesis effect [m^2 leaf s/mol CO2] + const double alpha; // Humidity effect [] + const double m; // Conductivity factor [mol H2O/m^2 leaf/s] + const double gs_max; // Maximum gs [mol/m^2 leaf/s] + + // Simulation. + double minimum () const + { + // Assuming wsf = 1.0, A = 0, hs = 0.0. + const double cs_min = 2.0; // [ppm] + return m / cs_min; + } + double stomata_con (const double ABA, // [g/cm^3] + const double h_x, // [MPa] + const double hs, + const double pz, const double Ptot, const double cs, + const double Gamma, + const double Ds, Treelog&); + void output (Log&) const + { } + + // Create. + public: + StomataCon_SHA14 (const BlockModel& al) + : StomataCon_WSF_base (al), + lambda (al.number ("lambda")), + alpha (al.number ("alpha")), + m (al.number ("m")), + gs_max (al.number ("max", -42.42e42)) + { } +}; + +double +StomataCon_SHA14::stomata_con (const double ABA, // [g/cm^3] + const double h_x, // [MPa] + const double hs /*[]*/, + const double pz /*[mol/m²leaf/s]*/, + const double Ptot /*[Pa]*/, + const double cs /*[Pa]*/, + const double, + const double, Treelog&) +{ + const double cs_ppm = cs /*[Pa]*/ / Ptot /*[Pa]*/ * 1.0e6 /*[ppm]*/; + const double A = std::max (pz, 0.0) * 1e6; // [umol/m^2 LEAF/s] + const double gsw = wsf (ABA, h_x) + * m * exp (hs * alpha) * exp (A * lambda) / cs_ppm; + daisy_assert (gsw >= 0.0); + + if (gs_max < 0.0) + return gsw; + return std::min (gsw, gs_max); +} + +struct StomataCon_MNA : public StomataCon_WSF_base +{ + // Parameters. +private: + const double lambda; // Net photosynthesis effect [m^2 leaf s/mol CO2] + const double alpha; // Humidity effect [] + const double m; // Conductivity factor [mol H2O/m^2 leaf/s] + const double b; // Stomatal intercept. + const double gs_max; // Maximum gs [mol/m^2 leaf/s] + + // Simulation. + double minimum () const + { return b; } + double stomata_con (const double ABA, // [g/cm^3] + const double h_x, // [MPa] + const double hs, + const double pz, const double Ptot, const double cs, + const double Gamma, + const double Ds, Treelog&); + void output (Log&) const + { } + + // Create. + public: + StomataCon_MNA (const BlockModel& al) + : StomataCon_WSF_base (al), + lambda (al.number ("lambda")), + alpha (al.number ("alpha")), + m (al.number ("m")), + b (al.number ("b")), + gs_max (al.number ("max", -42.42e42)) + { } +}; + +double +StomataCon_MNA::stomata_con (const double ABA, // [g/cm^3] + const double h_x, // [MPa] + const double hs /*[]*/, + const double pz /*[mol/m²leaf/s]*/, + const double Ptot /*[Pa]*/, + const double cs /*[Pa]*/, + const double, + const double, Treelog&) +{ + if (pz <= 0.0) + return b; + + const double cs_ppm = cs /*[Pa]*/ / Ptot /*[Pa]*/ * 1.0e6 /*[ppm]*/; + const double A = pz * 1e6; // [umol/m^2 LEAF/s] + daisy_assert (A > 0.0); + const double gsw = b + + wsf (ABA, h_x) * m * exp (hs * alpha) * exp (lambda / A) / cs_ppm; + daisy_assert (gsw >= 0.0); + if (gs_max < 0.0) + return gsw; + return std::min (gsw, gs_max); +} + +void +register_stomatacon_SHA_models () +{ + static struct StomataConSHA12Syntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new StomataCon_SHA12 (al); } + StomataConSHA12Syntax () + : DeclareModel (StomataCon::component, "SHA12", "WSF", "\ +Stomata conductance calculated by the model given by Eq. 12.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "Ahmadi20091541"); + + frame.declare ("alpha", Attribute::None (), Check::non_negative (), + Attribute::Const, + "Humidity effect"); + frame.set ("alpha", 1.0); + frame.declare ("lambda", Attribute::None (), Check::non_negative (), + Attribute::Const, + "Net photosyhtesis effect"); + frame.set ("lambda", 1.0); + frame.declare ("m", Attribute::Unknown (), + Check::non_negative (), Attribute::Const, + "Slope parameter, dimension depends on alpha and lambda."); + frame.declare ("min", "mol H2O/m^2 leaf/s", + Check::positive (), Attribute::OptionalConst, + "Minimal conductivity."); + } + } StomataConSHA12syntax; + static struct StomataConSHA14Syntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new StomataCon_SHA14 (al); } + StomataConSHA14Syntax () + : DeclareModel (StomataCon::component, "SHA14", "WSF", "\ +Stomata conductance calculated by the model given by Eq. 14.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "Ahmadi20091541"); + + frame.declare ("alpha", Attribute::None (), Check::non_negative (), + Attribute::Const, + "Humidity effect"); + frame.declare ("lambda", "m^2 leaf s/umol CO2", Check::non_negative (), + Attribute::Const, + "Net photosyhtesis effect"); + frame.declare ("m", "mol H2O/m^2 leaf/s", + Check::non_negative (), Attribute::Const, + "Conductivity factor."); + frame.declare ("max", "mol H2O/m^2 leaf/s", + Check::none (), Attribute::OptionalConst, + "Maximal conductivity.\n\ +By default, there is no maxium."); + } + } StomataConSHA14syntax; + static struct StomataConMNASyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new StomataCon_MNA (al); } + StomataConMNASyntax () + : DeclareModel (StomataCon::component, "MNA", "WSF", "\ +Stomata conductance calculated by the model given by Eq. 14.") + { } + void load_frame (Frame& frame) const + { + Model::declare_obsolete (frame, "We can't find a source to this equation."); + frame.declare ("alpha", Attribute::None (), Check::non_negative (), + Attribute::Const, + "Humidity effect"); + frame.declare ("lambda", "umol CO2/m^2 leaf/s", Check::non_positive (), + Attribute::Const, + "Net photosyhtesis effect"); + frame.declare ("m", "mol H2O/m^2 leaf/s", + Check::non_negative (), Attribute::Const, + "Conductivity factor."); + frame.declare ("b", "mol/m^2/s", Check::positive (), Attribute::Const, "\ +Stomatal intercept.\n\ +Ball and Berry (1982) & Wang and Leuning(1998): (0.01 mol/m2/s)"); + frame.declare ("max", "mol H2O/m^2 leaf/s", + Check::none (), Attribute::OptionalConst, + "Maximal conductivity.\n\ +By default, there is no maximum."); + } + } StomataConMNAsyntax; +} + +// stomatacon_SHA.C ends here. + diff --git a/src/daisy/crop/vernalization.C b/src/daisy/crop/vernalization.C index e0c1dcf5c..8a82f44f0 100644 --- a/src/daisy/crop/vernalization.C +++ b/src/daisy/crop/vernalization.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/crop/vernalization.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/librarian.h" #include "daisy/output/log.h" #include "object_model/frame.h" @@ -45,13 +46,6 @@ Vernalization::Vernalization (const BlockModel& al) Vernalization::~Vernalization () { } -static struct VernalizationInit : public DeclareComponent -{ - VernalizationInit () - : DeclareComponent (Vernalization::component, "\ -Requirement for a cold period before flowering.") - { } -} Vernalization_init; // The 'default' vernalization model. struct VernalizationStandard : public Vernalization @@ -86,26 +80,6 @@ struct VernalizationStandard : public Vernalization { } }; -static struct VernalizationStandardSyntax : public DeclareModel -{ - // We can't use "used_to_be_a_submodel" since the default model is "none". - Model* make (const BlockModel& al) const - { return new VernalizationStandard (al); } - VernalizationStandardSyntax () - : DeclareModel (Vernalization::component, "default", "\ -Temperature sum dependent vernalization.") - { } - void load_frame (Frame& frame) const - { - frame.declare ("DSLim", "DS", Attribute::Const, - "Development stage at vernalization."); - frame.declare ("TaLim", "dg C", Attribute::Const, - "Vernalization temperature threshold."); - frame.declare ("TaSum", "dg C d", Attribute::State, - "Vernalization temperature-sum requirement."); - } -} standard_vernalization_syntax; - // The 'none' vernalization model. struct VernalizationNone : public Vernalization @@ -123,16 +97,47 @@ struct VernalizationNone : public Vernalization { } }; -static struct VernalizationNoneSyntax : public DeclareModel +void +register_vernalization_models () { - Model* make (const BlockModel& al) const - { return new VernalizationNone (al); } - VernalizationNoneSyntax () - : DeclareModel (Vernalization::component, "none", "\ + static struct VernalizationInit : public DeclareComponent + { + VernalizationInit () + : DeclareComponent (Vernalization::component, "\ +Requirement for a cold period before flowering.") + { } + } Vernalization_init; + static struct VernalizationStandardSyntax : public DeclareModel + { + // We can't use "used_to_be_a_submodel" since the default model is "none". + Model* make (const BlockModel& al) const + { return new VernalizationStandard (al); } + VernalizationStandardSyntax () + : DeclareModel (Vernalization::component, "default", "\ +Temperature sum dependent vernalization.") + { } + void load_frame (Frame& frame) const + { + frame.declare ("DSLim", "DS", Attribute::Const, + "Development stage at vernalization."); + frame.declare ("TaLim", "dg C", Attribute::Const, + "Vernalization temperature threshold."); + frame.declare ("TaSum", "dg C d", Attribute::State, + "Vernalization temperature-sum requirement."); + } + } standard_vernalization_syntax; + static struct VernalizationNoneSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new VernalizationNone (al); } + VernalizationNoneSyntax () + : DeclareModel (Vernalization::component, "none", "\ No vernalization.") - { } - void load_frame (Frame&) const - { } -} none_vernalization_syntax; + { } + void load_frame (Frame&) const + { } + } none_vernalization_syntax; +} // vernalization.C ends here. + diff --git a/src/daisy/crop/wse.C b/src/daisy/crop/wse.C index 82ff09d00..0c245ea41 100644 --- a/src/daisy/crop/wse.C +++ b/src/daisy/crop/wse.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/crop/wse.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "programs/program.h" #include "util/mathlib.h" @@ -65,22 +66,6 @@ WSE::create_full () return full; } -static struct WSE_fullSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new WSE_full (al); } - WSE_fullSyntax () - : DeclareModel (WSE::component, "full", "\ -Water stress has full effect on crop growth.\n\ -This means that if there is 50% water stress, assimilate production\n\ -will be cut into half.") - { } - void load_frame (Frame& frame) const - { - - } -} WSE_full_syntax; - struct WSE_partial : public WSE { const double y_half; @@ -105,31 +90,6 @@ struct WSE_partial : public WSE { } }; -static struct WSE_partialSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new WSE_partial (al); } - WSE_partialSyntax () - : DeclareModel (WSE::component, "partial", "\ -Water stress has partial effect on crop growth.\n\ -\n\ -With this model, there will be full production when there is enough\n\ -available soil water to cover the potential evapotranspiration, and no\n\ -production when there is no soil water available. In between production\n\ -is controled by the 'y_half' parameter.\n\ -\n\ -See SH:REFERENCE for more explanation.") - { } - void load_frame (Frame& frame) const - { - frame.declare_fraction ("y_half", Attribute::Const, "\ -Effect on assimilate production of water stress.\n\ -This parameter specifies the effect on assimilate production\n(\ -compared to potential) when the amount of available soil water is\n\ -enough to cover exactly half the potential evapotranspiration."); - } -} WSE_partial_syntax; - struct WSE_none : public WSE { double factor (const double) const @@ -150,21 +110,6 @@ WSE::create_none () return none; } -static struct WSE_noneSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new WSE_none (al); } - WSE_noneSyntax () - : DeclareModel (WSE::component, "none", - "Water stress has no effect on plant growth.") - { } - void load_frame (Frame& frame) const - { - - } -} WSE_none_syntax; - - struct ProgramWSE_table : public Program { const std::unique_ptr wse; @@ -198,31 +143,87 @@ struct ProgramWSE_table : public Program { } }; -static struct ProgramWSE_tableSyntax : public DeclareModel +void +register_wse_models () { - Model* make (const BlockModel& al) const - { return new ProgramWSE_table (al); } - ProgramWSE_tableSyntax () - : DeclareModel (Program::component, "wse", "Generate a table of the water stress effect.") - { } - void load_frame (Frame& frame) const + static struct WSEInit : public DeclareComponent + { + WSEInit () + : DeclareComponent (WSE::component, "\ +The water stress effect on crop growth.") + { } + } WSE_init; + static struct WSE_fullSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new WSE_full (al); } + WSE_fullSyntax () + : DeclareModel (WSE::component, "full", "\ +Water stress has full effect on crop growth.\n\ +This means that if there is 50% water stress, assimilate production\n\ +will be cut into half.") + { } + void load_frame (Frame& frame) const + { + + } + } WSE_full_syntax; + static struct WSE_partialSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new WSE_partial (al); } + WSE_partialSyntax () + : DeclareModel (WSE::component, "partial", "\ +Water stress has partial effect on crop growth.\n\ +\n\ +With this model, there will be full production when there is enough\n\ +available soil water to cover the potential evapotranspiration, and no\n\ +production when there is no soil water available. In between production\n\ +is controled by the 'y_half' parameter.\n\ +\n\ +See SH:REFERENCE for more explanation.") + { } + void load_frame (Frame& frame) const + { + frame.declare_fraction ("y_half", Attribute::Const, "\ +Effect on assimilate production of water stress.\n\ +This parameter specifies the effect on assimilate production\n(\ +compared to potential) when the amount of available soil water is\n\ +enough to cover exactly half the potential evapotranspiration."); + } + } WSE_partial_syntax; + static struct WSE_noneSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new WSE_none (al); } + WSE_noneSyntax () + : DeclareModel (WSE::component, "none", + "Water stress has no effect on plant growth.") + { } + void load_frame (Frame& frame) const + { + + } + } WSE_none_syntax; + static struct ProgramWSE_tableSyntax : public DeclareModel { - frame.declare_object ("wse", WSE::component, - Attribute::Const, Attribute::Singleton, "\ + Model* make (const BlockModel& al) const + { return new ProgramWSE_table (al); } + ProgramWSE_tableSyntax () + : DeclareModel (Program::component, "wse", "Generate a table of the water stress effect.") + { } + void load_frame (Frame& frame) const + { + frame.declare_object ("wse", WSE::component, + Attribute::Const, Attribute::Singleton, "\ The water stress effect to show in the table."); - frame.declare_integer ("intervals", Attribute::Const, "\ + frame.declare_integer ("intervals", Attribute::Const, "\ Number of intervals in the table."); - frame.set ("intervals", 10); - frame.order ("wse"); - } -} ProgramWSE_table_syntax; - -static struct WSEInit : public DeclareComponent -{ - WSEInit () - : DeclareComponent (WSE::component, "\ -The water stress effect on crop growth.") - { } -} WSE_init; + frame.set ("intervals", 10); + frame.order ("wse"); + } + } ProgramWSE_table_syntax; +} // wse.C ends here. + diff --git a/src/daisy/daisy.C b/src/daisy/daisy.C index 0fd0603a9..484b76eb1 100644 --- a/src/daisy/daisy.C +++ b/src/daisy/daisy.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/daisy.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/upper_boundary/weather/wsource.h" #include "daisy/lower_boundary/groundwater.h" #include "daisy/soil/horizon.h" @@ -568,7 +569,7 @@ the simulation. Can be overwritten by column specific weather."); Daisy::~Daisy () { } -static struct ProgramDaisySyntax : public DeclareModel +struct ProgramDaisySyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new Daisy (al); } @@ -582,6 +583,12 @@ static struct ProgramDaisySyntax : public DeclareModel frame.set_strings ("cite", "daisy-def", "daisy-new", "daisy-fertilizer"); } -} ProgramDaisy_syntax; +}; + +void +register_daisy_program_models () +{ + static ProgramDaisySyntax program_daisy_syntax; +} // daisy.C ends here. diff --git a/src/daisy/daisy_time.C b/src/daisy/daisy_time.C index 740149cda..9b397cebc 100644 --- a/src/daisy/daisy_time.C +++ b/src/daisy/daisy_time.C @@ -23,6 +23,7 @@ #define BUILD_DLL #include "daisy/daisy_time.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/timestep.h" #include "util/assertion.h" #include "daisy/output/log.h" @@ -654,9 +655,12 @@ Time::Time (const FrameSubmodel& al) al.integer ("microsecond"))) { } -static DeclareSubmodel -time_submodel (Time::load_syntax, "Time", "\ +void +register_daisy_time_models () +{ + static DeclareSubmodel time_submodel (Time::load_syntax, "Time", "\ Year, month, day and hour, minute, second and microsecond."); +} // @ Construct. diff --git a/src/daisy/lower_boundary/groundwater.C b/src/daisy/lower_boundary/groundwater.C index 3b99fa5fa..a494e3d58 100644 --- a/src/daisy/lower_boundary/groundwater.C +++ b/src/daisy/lower_boundary/groundwater.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/lower_boundary/groundwater.h" #include "daisy/soil/transport/geometry.h" #include "daisy/output/log.h" @@ -55,16 +56,16 @@ Groundwater::Groundwater (const BlockModel& al) Groundwater::~Groundwater () { } -static struct GroundwaterInit : public DeclareComponent +struct GroundwaterInit : public DeclareComponent { GroundwaterInit () : DeclareComponent (Groundwater::component, "\ The 'groundwater' component is responsible for specifying the\n\ groundwater table at each timestep.") { } -} Groundwater_init; +}; -static struct GroundwaterBaseSyntax : public DeclareBase +struct GroundwaterBaseSyntax : public DeclareBase { GroundwaterBaseSyntax () : DeclareBase (Groundwater::component, "common", "\ @@ -75,6 +76,22 @@ All groundwater models can log height.") frame.declare ("height", "cm", Attribute::LogOnly, "Groundwater level. Positive numbers indicate free drainage."); } -} GroundwaterBase_syntax; +}; + +void +register_groundwater_models () +{ + static GroundwaterInit groundwater_init; + static GroundwaterBaseSyntax groundwater_base_syntax; + register_groundwater_aquitard_models (); + register_groundwater_deep_models (); + register_groundwater_extern_models (); + register_groundwater_file_models (); + register_groundwater_fixed_models (); + register_groundwater_flux_models (); + register_groundwater_lysimeter_models (); + register_groundwater_source_models (); + register_groundwater_static_models (); +} // groundwater.C ends here. diff --git a/src/daisy/lower_boundary/groundwater_aquitard.C b/src/daisy/lower_boundary/groundwater_aquitard.C index 4ff9001a6..a3cc8df20 100644 --- a/src/daisy/lower_boundary/groundwater_aquitard.C +++ b/src/daisy/lower_boundary/groundwater_aquitard.C @@ -1,5 +1,6 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/lower_boundary/groundwater_aquitard.h" GroundwaterAquitard::GroundwaterAquitard (const BlockModel& al) @@ -101,7 +102,7 @@ void GroundwaterAquitard::set_h_aquifer (const Geometry& geo) h_aquifer = pressure_table->operator()() - aquitard_bottom; } -static struct GroundwaterAquitardSyntax : public DeclareModel +struct GroundwaterAquitardSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new GroundwaterAquitard (al); } @@ -134,6 +135,12 @@ number). This is different from the actual groundwater table, because\n\ the aquitart block the water, and the pipes lead the water away.\n\ You can alternatively specify the pressure directly, with 'h_aquifer'."); } -} GroundwaterAquitard_syntax; +}; + +void +register_groundwater_aquitard_models () +{ + static GroundwaterAquitardSyntax groundwater_aquitard_syntax; +} // groundwater_aquitard.C ends here. diff --git a/src/daisy/lower_boundary/groundwater_deep.C b/src/daisy/lower_boundary/groundwater_deep.C index 76d562703..42ca4727d 100644 --- a/src/daisy/lower_boundary/groundwater_deep.C +++ b/src/daisy/lower_boundary/groundwater_deep.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/lower_boundary/groundwater.h" #include "util/assertion.h" #include "object_model/librarian.h" @@ -57,7 +58,7 @@ public: { } }; -static struct GroundwaterDeepSyntax : public DeclareModel +struct GroundwaterDeepSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new GroundwaterDeep (al); } @@ -69,4 +70,10 @@ Deep groundwater, free drainage.") void load_frame (Frame& frame) const { } -} GroundwaterDeep_syntax; +}; + +void +register_groundwater_deep_models () +{ + static GroundwaterDeepSyntax groundwater_deep_syntax; +} diff --git a/src/daisy/lower_boundary/groundwater_extern.C b/src/daisy/lower_boundary/groundwater_extern.C index 819b5e58d..1e4c16c94 100644 --- a/src/daisy/lower_boundary/groundwater_extern.C +++ b/src/daisy/lower_boundary/groundwater_extern.C @@ -20,6 +20,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/lower_boundary/groundwater.h" #include "daisy/output/output.h" #include "object_model/parameter_types/number.h" @@ -81,7 +82,7 @@ public: { } }; -static struct GroundwaterExternSyntax : public DeclareModel +struct GroundwaterExternSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new GroundwaterExtern (al); } @@ -97,4 +98,10 @@ Expression that evaluates to groundwate table in."); frame.declare ("initial_table", "cm", Check::none (), Attribute::OptionalConst, "Groundwater level for initialization of soil water."); } -} GroundwaterExtern_syntax; +}; + +void +register_groundwater_extern_models () +{ + static GroundwaterExternSyntax groundwater_extern_syntax; +} diff --git a/src/daisy/lower_boundary/groundwater_file.C b/src/daisy/lower_boundary/groundwater_file.C index 71f51aef2..e15f3bee0 100644 --- a/src/daisy/lower_boundary/groundwater_file.C +++ b/src/daisy/lower_boundary/groundwater_file.C @@ -20,6 +20,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/lower_boundary/groundwater_file.h" Groundwater::bottom_t @@ -134,7 +135,7 @@ GroundwaterFile::GroundwaterFile (const BlockModel& al) GroundwaterFile::~GroundwaterFile () { } -static struct GroundwaterFileSyntax : public DeclareModel +struct GroundwaterFileSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new GroundwaterFile (al); } @@ -154,6 +155,12 @@ Linear interpolation is used between the datapoints."); "Add this to depth from file."); frame.set ("offset", 0.0); } -} GroundwaterFile_syntax; +}; + +void +register_groundwater_file_models () +{ + static GroundwaterFileSyntax groundwater_file_syntax; +} // groundwater_file.C ends here. diff --git a/src/daisy/lower_boundary/groundwater_fixed.C b/src/daisy/lower_boundary/groundwater_fixed.C index d1f714dc3..950871e5b 100644 --- a/src/daisy/lower_boundary/groundwater_fixed.C +++ b/src/daisy/lower_boundary/groundwater_fixed.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/lower_boundary/groundwater.h" #include "object_model/block_model.h" #include "object_model/check.h" @@ -64,7 +65,7 @@ public: { } }; -static struct GroundwaterFixedSyntax : public DeclareModel +struct GroundwaterFixedSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new GroundwaterFixed (al); } @@ -78,6 +79,11 @@ Fixed high groundwater level.") "Groundwater level (negative number below surface)."); frame.order ("table"); } -} GroundwaterFixed_syntax; +}; +void +register_groundwater_fixed_models () +{ + static GroundwaterFixedSyntax groundwater_fixed_syntax; +} diff --git a/src/daisy/lower_boundary/groundwater_flux.C b/src/daisy/lower_boundary/groundwater_flux.C index 78c12c001..b8115c08b 100644 --- a/src/daisy/lower_boundary/groundwater_flux.C +++ b/src/daisy/lower_boundary/groundwater_flux.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/lower_boundary/groundwater.h" #include "object_model/block_model.h" #include "object_model/check.h" @@ -61,7 +62,7 @@ public: { } }; -static struct GroundwaterFluxSyntax : public DeclareModel +struct GroundwaterFluxSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new GroundwaterFlux (al); } @@ -76,4 +77,10 @@ Flux groundwater, free drainage.") "Constant flux to groundwater."); frame.order ("flux"); } -} GroundwaterFlux_syntax; +}; + +void +register_groundwater_flux_models () +{ + static GroundwaterFluxSyntax groundwater_flux_syntax; +} diff --git a/src/daisy/lower_boundary/groundwater_lysimeter.C b/src/daisy/lower_boundary/groundwater_lysimeter.C index 7885b859d..95baedd78 100644 --- a/src/daisy/lower_boundary/groundwater_lysimeter.C +++ b/src/daisy/lower_boundary/groundwater_lysimeter.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/lower_boundary/groundwater.h" #include "daisy/soil/transport/geometry.h" #include "util/assertion.h" @@ -64,7 +65,7 @@ public: { } }; -static struct GroundwaterLysimeterSyntax : public DeclareModel +struct GroundwaterLysimeterSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new GroundwaterLysimeter (al); } @@ -75,6 +76,11 @@ Lysimeter bottom.") { } void load_frame (Frame&) const { } -} GroundwaterLysimeter_syntax; +}; +void +register_groundwater_lysimeter_models () +{ + static GroundwaterLysimeterSyntax groundwater_lysimeter_syntax; +} diff --git a/src/daisy/lower_boundary/groundwater_source.C b/src/daisy/lower_boundary/groundwater_source.C index 06734ebca..a7f683a40 100644 --- a/src/daisy/lower_boundary/groundwater_source.C +++ b/src/daisy/lower_boundary/groundwater_source.C @@ -22,6 +22,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/lower_boundary/groundwater.h" #include "gnuplot/source.h" #include "daisy/daisy_time.h" @@ -177,7 +178,7 @@ GroundwaterSource::GroundwaterSource (const BlockModel& al) GroundwaterSource::~GroundwaterSource () { } -static struct GroundwaterSourceSyntax : public DeclareModel +struct GroundwaterSourceSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new GroundwaterSource (al); } @@ -195,6 +196,12 @@ Groundwater table time series."); "Add this to depth from source."); frame.set ("offset", 0.0); } -} GroundwaterSource_syntax; +}; + +void +register_groundwater_source_models () +{ + static GroundwaterSourceSyntax groundwater_source_syntax; +} // groundwater_source.C ends here. diff --git a/src/daisy/lower_boundary/groundwater_static.C b/src/daisy/lower_boundary/groundwater_static.C index e9ab8d0a2..bf940e610 100644 --- a/src/daisy/lower_boundary/groundwater_static.C +++ b/src/daisy/lower_boundary/groundwater_static.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/lower_boundary/groundwater.h" #include "object_model/block_model.h" #include "util/assertion.h" @@ -86,7 +87,7 @@ GroundwaterStatic::GroundwaterStatic (const BlockModel& al) GroundwaterStatic::~GroundwaterStatic () { } -static struct GroundwaterStaticSyntax : public DeclareModel +struct GroundwaterStaticSyntax : public DeclareModel { Model* make (const BlockModel& al) const { @@ -108,6 +109,12 @@ Provided for backward compatibility, use 'deep' or 'fixed' instead.") Positive numbers indicate free drainage."); frame.set ("table", 1.0); } -} GroundwaterStatic_syntax; +}; + +void +register_groundwater_static_models () +{ + static GroundwaterStaticSyntax groundwater_static_syntax; +} // groundwater_static.C ends here. diff --git a/src/daisy/manager/action.C b/src/daisy/manager/action.C index 645a000d4..6bb4795c3 100644 --- a/src/daisy/manager/action.C +++ b/src/daisy/manager/action.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "object_model/block_model.h" #include "object_model/librarian.h" @@ -61,7 +62,7 @@ Action::Action (const BlockModel& al) Action::~Action () { } -static struct ActionInit : public DeclareComponent +struct ActionInit : public DeclareComponent { ActionInit () : DeclareComponent (Action::component, "\ @@ -70,6 +71,33 @@ levels, from a single tillage operation to strategies of how to manage\n\ a farm. Typically, but not necessarily, the high level management\n\ strategies are build by combining low level management operations.") { } -} Action_init; +}; + +void +register_action_models () +{ + static ActionInit action_init; + register_action_BBCH_models (); + register_action_activity_models (); + register_action_crop_models (); + register_action_extern_models (); + register_action_fertilize_models (); + register_action_harvest_models (); + register_action_irrigate_models (); + register_action_lisp_models (); + register_action_markvand_models (); + register_action_message_models (); + register_action_repeat_models (); + register_action_sow_models (); + register_action_spray_models (); + register_action_stop_models (); + register_action_surface_models (); + register_action_table_models (); + register_action_tillage_models (); + register_action_wait_models (); + register_action_while_models (); + register_action_with_models (); + register_irrigation_models (); +} // action.C ends here. diff --git a/src/daisy/manager/action_BBCH.C b/src/daisy/manager/action_BBCH.C index 46c711426..9f06afefa 100644 --- a/src/daisy/manager/action_BBCH.C +++ b/src/daisy/manager/action_BBCH.C @@ -22,6 +22,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "daisy/daisy.h" #include "object_model/librarian.h" @@ -174,7 +175,7 @@ struct ActionBBCH : public Action { } }; -static struct ActionBBCHSyntax : DeclareModel +struct ActionBBCHSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionBBCH (al); } @@ -209,6 +210,12 @@ the specified BBCH interval, or at the end of the interval, whichever\n\ comes first. Use 'true' to perform the action at the start of the interval,\n\ or 'false' to perform it at the end."); } -} ActionBBCH_syntax; +}; + +void +register_action_BBCH_models () +{ + static ActionBBCHSyntax action_bbch_syntax; +} // action_BBCH.C ends here. diff --git a/src/daisy/manager/action_activity.C b/src/daisy/manager/action_activity.C index ed6ca17d5..304e3d118 100644 --- a/src/daisy/manager/action_activity.C +++ b/src/daisy/manager/action_activity.C @@ -22,6 +22,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "object_model/frame.h" #include "daisy/output/log.h" @@ -101,7 +102,7 @@ struct ActionActivity : public Action { } }; -static struct ActionSequenceSyntax : public DeclareModel +struct ActionSequenceSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionActivity (al); } @@ -132,9 +133,9 @@ at each time step.") "Sequence of actions to perform."); frame.set_empty ("do"); } -} ActionSequence_syntax; +}; -static struct ActionActivitySyntax : public DeclareParam +struct ActionActivitySyntax : public DeclareParam { ActionActivitySyntax () : DeclareParam (Action::component, "activity", "sequence", "\ @@ -146,6 +147,13 @@ at each time step.") { frame.order ("do"); } -} ActionActivity_syntax; +}; + +void +register_action_activity_models () +{ + static ActionSequenceSyntax action_sequence_syntax; + static ActionActivitySyntax action_activity_syntax; +} // action_activity.C ends here diff --git a/src/daisy/manager/action_crop.C b/src/daisy/manager/action_crop.C index b0c16dd9c..8d8f0f0a2 100644 --- a/src/daisy/manager/action_crop.C +++ b/src/daisy/manager/action_crop.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "daisy/daisy.h" #include "daisy/field.h" @@ -1026,7 +1027,7 @@ ActionCrop::~ActionCrop () } // Add the ActionCrop syntax to the syntax table. -static struct ActionCropSyntax : public DeclareModel +struct ActionCropSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionCrop (al); } @@ -1112,6 +1113,12 @@ Negative number means it hasn't started yet."); This is set at each irrigation, to avoid multiple applications."); } -} ActionCrop_syntax; +}; + +void +register_action_crop_models () +{ + static ActionCropSyntax action_crop_syntax; +} // action_crop.C ends here. diff --git a/src/daisy/manager/action_extern.C b/src/daisy/manager/action_extern.C index 7f1c9c324..a9c5b9ac3 100644 --- a/src/daisy/manager/action_extern.C +++ b/src/daisy/manager/action_extern.C @@ -20,6 +20,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "util/scope_multi.h" #include "util/scopesel.h" @@ -110,7 +111,7 @@ struct ActionExtern : public Action { } }; -static struct ActionExternSyntax : public DeclareModel +struct ActionExternSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionExtern (al); } @@ -128,7 +129,7 @@ Scope to evaluate expessions in."); "Action to perform if the condition is false."); frame.order ("scope", "action"); } -} ActionExtern_syntax; +}; // The 'extern_fertigation' action. @@ -295,7 +296,7 @@ struct ActionExternFertigation : public Action const symbol ActionExternFertigation::kg_N_per_ha_per_h ("kg N/ha/h"); -static struct ActionExternFertigationSyntax : public DeclareModel +struct ActionExternFertigationSyntax : public DeclareModel { static bool check_alist (const Metalib&, const Frame& al, Treelog& err) { @@ -359,7 +360,7 @@ Height where you want to start the incorporation (a negative number)."); Height where you want to end the incorporation (a negative number)."); frame.set ("from", -10.0); } -} ActionExternFertigation_syntax; +}; // The 'extern_subsoil' action. @@ -479,7 +480,7 @@ struct ActionExternSubsoil : public Action { } }; -static struct ActionExternSubsoilSyntax : public DeclareModel +struct ActionExternSubsoilSyntax : public DeclareModel { static bool check_alist (const Metalib&, const Frame& al, Treelog& err) { @@ -535,6 +536,14 @@ OBSOLETE: Use (volume box (top FROM)) instead."); Height where you want to end the incorporation (a negative number).\n\ OBSOLETE: Use (volume box (bottom TO)) instead."); } -} ActionExternSubsoil_syntax; +}; + +void +register_action_extern_models () +{ + static ActionExternSyntax action_extern_syntax; + static ActionExternFertigationSyntax action_extern_fertigation_syntax; + static ActionExternSubsoilSyntax action_extern_subsoil_syntax; +} // action_extern.C ends here. diff --git a/src/daisy/manager/action_fertilize.C b/src/daisy/manager/action_fertilize.C index e745d2508..1114f823a 100644 --- a/src/daisy/manager/action_fertilize.C +++ b/src/daisy/manager/action_fertilize.C @@ -22,6 +22,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "object_model/block_model.h" #include "daisy/daisy.h" @@ -217,7 +218,7 @@ ActionFertilize::ActionFertilize (const BlockModel& al) ActionFertilize::~ActionFertilize () { } -static struct ActionFertilizeSyntax : public DeclareBase +struct ActionFertilizeSyntax : public DeclareBase { static bool check_alist (const Metalib& metalib, const Frame& al, Treelog& err) @@ -297,7 +298,7 @@ organic fertilizer parameter. The second year effect does not fade with\n\ time, but is zeroed once you fertilize with this flag set."); frame.set ("second_year_compensation", false); } -} ActionFertilize_init; +}; // Surface fertilizer. @@ -359,7 +360,7 @@ ActionFertilizeSurface::doIt (Daisy& daisy, const Scope&, Treelog& msg) } } -static struct ActionFertilizeSurfaceSyntax : public DeclareModel +struct ActionFertilizeSurfaceSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionFertilizeSurface (al); } @@ -401,7 +402,7 @@ OBSOLETE: Use 'fertilize_incorporate' instead."); frame.set ("to", 0.0); frame.order ("am"); } -} ActionFertilizeSurface_syntax; +}; // Incorporate fertilizer. @@ -440,7 +441,7 @@ ActionFertilizeIncorporate::doIt (Daisy& daisy, const Scope&, Treelog& msg) volume, true, msg); } -static struct ActionFertilizeIncorporateSyntax : public DeclareModel +struct ActionFertilizeIncorporateSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionFertilizeIncorporate (al); } @@ -463,6 +464,14 @@ static struct ActionFertilizeIncorporateSyntax : public DeclareModel "Soil volume to incorporate fertilizer in."); frame.order ("am"); } -} ActionFertilizeIncorporate_syntax; +}; + +void +register_action_fertilize_models () +{ + static ActionFertilizeSyntax action_fertilize_syntax; + static ActionFertilizeSurfaceSyntax action_fertilize_surface_syntax; + static ActionFertilizeIncorporateSyntax action_fertilize_incorporate_syntax; +} // action_fertilize.C ends here. diff --git a/src/daisy/manager/action_harvest.C b/src/daisy/manager/action_harvest.C index 84e8cdf05..8098a731a 100644 --- a/src/daisy/manager/action_harvest.C +++ b/src/daisy/manager/action_harvest.C @@ -22,6 +22,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "daisy/daisy.h" #include "daisy/field.h" @@ -74,7 +75,7 @@ struct ActionEmerge : public Action { } }; -static struct ActionEmergeSyntax : DeclareModel +struct ActionEmergeSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionEmerge (al); } @@ -92,11 +93,11 @@ nothing will happen."); frame.set_check ("crop", Crop::check_all ()); frame.order ("crop"); } -} ActionEmerge_syntax; +}; // The 'harvest_base' base model. -static struct ActionHarvestBaseSyntax : DeclareBase +struct ActionHarvestBaseSyntax : DeclareBase { ActionHarvestBaseSyntax () : DeclareBase (Action::component, "harvest_base", "\ @@ -130,7 +131,7 @@ This is mostly useful for silage."); frame.set ("combine", false); frame.order ("crop"); } -} ActionHarvestBase_syntax; +}; // The 'harvest' action model. @@ -215,7 +216,7 @@ If this was intended, you should use the 'cut' action instead to avoid this mess { } }; -static struct ActionHarvestSyntax : DeclareModel +struct ActionHarvestSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionHarvest (al); } @@ -225,7 +226,7 @@ Harvest a crop.") { } void load_frame (Frame& frame) const { } -} ActionHarvest_syntax; +}; // The 'cut' action model. @@ -243,7 +244,7 @@ If this was intended, you should use the 'harvest' action instead to avoid this { } }; -static struct ActionCutSyntax : DeclareModel +struct ActionCutSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionCut (al); } @@ -252,7 +253,7 @@ static struct ActionCutSyntax : DeclareModel { } void load_frame (Frame& frame) const { } -} ActionCut_syntax; +}; // The 'pluck' action model. @@ -308,7 +309,7 @@ If this was intended, you should use the 'harvest' action instead to avoid this { } }; -static struct ActionPluckSyntax : DeclareModel +struct ActionPluckSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionPluck (al); } @@ -338,6 +339,16 @@ Fraction of storage organ to pluck."); frame.set ("sorg", 1.0); frame.order ("crop"); } -} ActionPluck_syntax; +}; + +void +register_action_harvest_models () +{ + static ActionEmergeSyntax action_emerge_syntax; + static ActionHarvestBaseSyntax action_harvest_base_syntax; + static ActionHarvestSyntax action_harvest_syntax; + static ActionCutSyntax action_cut_syntax; + static ActionPluckSyntax action_pluck_syntax; +} // action_harvest.C ends here. diff --git a/src/daisy/manager/action_irrigate.C b/src/daisy/manager/action_irrigate.C index f569d22ec..1ae082396 100644 --- a/src/daisy/manager/action_irrigate.C +++ b/src/daisy/manager/action_irrigate.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "util/scope.h" #include "object_model/block_model.h" @@ -94,7 +95,7 @@ struct ActionIrrigate : public Action { } }; -static struct ActionIrrigateBaseSyntax : public DeclareBase +struct ActionIrrigateBaseSyntax : public DeclareBase { ActionIrrigateBaseSyntax () : DeclareBase (Action::component, "irrigate_base", "\ @@ -143,7 +144,7 @@ Setting this overrides the 'days' and 'hours' parameters."); Solutes in irrigation water.", load_ppm); frame.set_empty ("solute"); } -} ActionIrrigateBase_syntax; +}; const symbol ActionIrrigate::mm_per_h ("mm/h"); @@ -189,7 +190,7 @@ struct ActionIrrigateSubsoil : public ActionIrrigate { } }; -static struct ActionIrrigateOverheadSyntax : DeclareModel +struct ActionIrrigateOverheadSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionIrrigateOverhead (al); } @@ -199,9 +200,9 @@ Irrigate the field from above.") { } void load_frame (Frame&) const { } -} ActionIrrigateOverhead_syntax; +}; -static struct ActionIrrigateSurfaceSyntax : DeclareModel +struct ActionIrrigateSurfaceSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionIrrigateSurface (al); } @@ -211,9 +212,9 @@ Irrigate the field directly on the soil surface, bypassing the canopy.") { } void load_frame (Frame&) const { } -} ActionIrrigateSurface_syntax; +}; -static struct ActionIrrigateSubsoilSyntax : DeclareModel +struct ActionIrrigateSubsoilSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionIrrigateSubsoil (al); } @@ -255,6 +256,15 @@ OBSOLETE: Use (volume box (top FROM)) instead."); Height where you want to end the incorporation (a negative number).\n\ OBSOLETE: Use (volume box (bottom TO)) instead."); } -} ActionIrrigateSubsoil_syntax; +}; + +void +register_action_irrigate_models () +{ + static ActionIrrigateBaseSyntax action_irrigate_base_syntax; + static ActionIrrigateOverheadSyntax action_irrigate_overhead_syntax; + static ActionIrrigateSurfaceSyntax action_irrigate_surface_syntax; + static ActionIrrigateSubsoilSyntax action_irrigate_subsoil_syntax; +} // action_irrigate.C ends here. diff --git a/src/daisy/manager/action_lisp.C b/src/daisy/manager/action_lisp.C index 5b68df061..ae41ef9f9 100644 --- a/src/daisy/manager/action_lisp.C +++ b/src/daisy/manager/action_lisp.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "daisy/daisy.h" #include "daisy/output/log.h" @@ -314,7 +315,7 @@ struct ActionIf : public Action { } }; -static struct ActionNilSyntax : public DeclareModel +struct ActionNilSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionNil (al); } @@ -324,9 +325,9 @@ This action does nothing, always done.") { } void load_frame (Frame&) const { } -} ActionNil_syntax; +}; -static struct ActionTSyntax : public DeclareModel +struct ActionTSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionT (al); } @@ -336,9 +337,9 @@ This action does nothing, never done.") { } void load_frame (Frame&) const { } -} ActionT_syntax; +}; -static struct ActionPrognSyntax : public DeclareModel +struct ActionPrognSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionProgn (al); } @@ -354,9 +355,9 @@ All the actions will be performed in the same time step.") "List of actions to perform."); frame.order ("actions"); } -} ActionProgn_syntax; +}; -static struct ActionCondSyntax : public DeclareModel +struct ActionCondSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionCond (al); } @@ -372,9 +373,9 @@ The first clause whose condition is true, will have its actions activated.", ActionCond::clause::load_syntax); frame.order ("clauses"); } -} ActionCond_syntax; +}; -static struct ActionIfSyntax : public DeclareModel +struct ActionIfSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionIf (al); } @@ -394,6 +395,16 @@ otherwise perform the second action.") frame.order ("if", "then", "else"); frame.set ("else", "nil"); } -} ActionIf_syntax; +}; + +void +register_action_lisp_models () +{ + static ActionNilSyntax action_nil_syntax; + static ActionTSyntax action_t_syntax; + static ActionPrognSyntax action_progn_syntax; + static ActionCondSyntax action_cond_syntax; + static ActionIfSyntax action_if_syntax; +} // action_lisp.C ends here. diff --git a/src/daisy/manager/action_markvand.C b/src/daisy/manager/action_markvand.C index be9506609..2f3919219 100644 --- a/src/daisy/manager/action_markvand.C +++ b/src/daisy/manager/action_markvand.C @@ -19,6 +19,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "object_model/block_model.h" #include "daisy/daisy.h" @@ -100,12 +101,12 @@ struct MV_Soil : public Model { } }; -static struct MV_SoilInit : public DeclareComponent +struct MV_SoilInit : public DeclareComponent { MV_SoilInit () : DeclareComponent (MV_Soil::component, MV_Soil::description) { } -} Soil_init; +}; const char *const MV_Soil::description = "\ @@ -120,7 +121,7 @@ MV_Soil::library_id () const return id; } -static struct MV_SoilSyntax : DeclareModel +struct MV_SoilSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new MV_Soil (al); } @@ -157,7 +158,7 @@ static struct MV_SoilSyntax : DeclareModel frame.declare ("k_qb", Attribute::None (), Attribute::Const, "Drainage constant subsone."); } -} MV_Soil_syntax; +}; // MV_Crop @@ -270,12 +271,12 @@ struct MV_Crop : public Model { } }; -static struct MV_CropInit : public DeclareComponent +struct MV_CropInit : public DeclareComponent { MV_CropInit () : DeclareComponent (MV_Crop::component, MV_Crop::description) { } -} Crop_init; +}; const char *const MV_Crop::description = "\ Description of a crop for use by the MARKVAND model."; @@ -289,7 +290,7 @@ MV_Crop::library_id () const return id; } -static struct MV_CropSyntax : DeclareModel +struct MV_CropSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new MV_Crop (al); } @@ -350,7 +351,7 @@ Green leaf area index at the time where growth rate become exponential."); frame.declare ("c_r", "mm/d", Check::non_negative (), Attribute::Const, "Root penetration rate."); } -} MV_Crop_syntax; +}; struct ActionMarkvand : public Action { @@ -666,7 +667,7 @@ ActionMarkvand::ActionMarkvand (const BlockModel& al) ActionMarkvand::~ActionMarkvand () { } -static struct ActionMarkvandSyntax : DeclareModel +struct ActionMarkvandSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionMarkvand (al); } @@ -722,6 +723,16 @@ By default, the reservoir will be full at plant emergence."); Solutes in irrigation water.", load_ppm); frame.set_empty ("solute"); } -} ActionMarkvand_syntax; +}; + +void +register_action_markvand_models () +{ + static MV_SoilInit mv_soil_init; + static MV_SoilSyntax mv_soil_syntax; + static MV_CropInit mv_crop_init; + static MV_CropSyntax mv_crop_syntax; + static ActionMarkvandSyntax action_markvand_syntax; +} // action_markvand.C ends here. diff --git a/src/daisy/manager/action_message.C b/src/daisy/manager/action_message.C index 1ea401bb5..475845849 100644 --- a/src/daisy/manager/action_message.C +++ b/src/daisy/manager/action_message.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "object_model/block_model.h" #include "daisy/condition.h" @@ -166,7 +167,7 @@ struct ActionPanic : public Action { } }; -static struct ActionAssertSyntax : public DeclareModel +struct ActionAssertSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionAssert (al); } @@ -183,9 +184,9 @@ Assert that condition is true, if not, stop the simulation.") "Error message to give iff assertion fails."); frame.set ("message", "Required condition not fulfilled"); } -} ActionAssert_syntax; +}; -static struct ActionMessageSyntax : public DeclareModel +struct ActionMessageSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionMessage (al); } @@ -199,9 +200,9 @@ Write a message to the user.") "Message to give to the user."); frame.order ("message"); } -} ActionMessage_syntax; +}; -static struct ActionWarningSyntax : public DeclareModel +struct ActionWarningSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionWarning (al); } @@ -215,9 +216,9 @@ Write a warning to the user.") "Warning to give to the user."); frame.order ("message"); } -} ActionWarning_syntax; +}; -static struct ActionErrorSyntax : public DeclareModel +struct ActionErrorSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionError (al); } @@ -231,9 +232,9 @@ Write a error message to the user.") "Error message to give."); frame.order ("message"); } -} ActionError_syntax; +}; -static struct ActionPanicSyntax : public DeclareModel +struct ActionPanicSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionPanic (al); } @@ -247,7 +248,7 @@ Write a error message to the user and stop the simulation.") "Error message to give."); frame.order ("message"); } -} ActionPanic_syntax; +}; // The 'sorption_table' action mode. @@ -284,7 +285,7 @@ struct ActionSorptionTable : public Action { } }; -static struct ActionSorptionTableSyntax : public DeclareModel +struct ActionSorptionTableSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionSorptionTable (al); } @@ -312,8 +313,18 @@ If zero, instead add start to C for the next entry in the table."); Number of entries in the table."); frame.set ("intervals", 10); } -} ActionSorptionTable_syntax; +}; + +void +register_action_message_models () +{ + static ActionAssertSyntax action_assert_syntax; + static ActionMessageSyntax action_message_syntax; + static ActionWarningSyntax action_warning_syntax; + static ActionErrorSyntax action_error_syntax; + static ActionPanicSyntax action_panic_syntax; + static ActionSorptionTableSyntax action_sorption_table_syntax; +} // action_message.C ends here. - diff --git a/src/daisy/manager/action_repeat.C b/src/daisy/manager/action_repeat.C index 13aeb40d5..3beabde60 100644 --- a/src/daisy/manager/action_repeat.C +++ b/src/daisy/manager/action_repeat.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "daisy/daisy.h" #include "object_model/block_model.h" @@ -103,7 +104,7 @@ struct ActionRepeat : public Action { } }; -static struct ActionRepeatSyntax : DeclareModel +struct ActionRepeatSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionRepeat (al); } @@ -123,6 +124,12 @@ The action may take several timesteps.") "Action currently being performed."); frame.order ("repeat"); } -} ActionRepeat_syntax; +}; + +void +register_action_repeat_models () +{ + static ActionRepeatSyntax action_repeat_syntax; +} // action_repeat.C ends here. diff --git a/src/daisy/manager/action_sow.C b/src/daisy/manager/action_sow.C index 5990ba20d..ce69a4934 100644 --- a/src/daisy/manager/action_sow.C +++ b/src/daisy/manager/action_sow.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "object_model/block_model.h" #include "daisy/daisy.h" @@ -55,7 +56,7 @@ struct ActionSowBase : public Action }; // Add the ActionSowBase syntax to the syntax table. -static struct ActionSowBaseSyntax : DeclareBase +struct ActionSowBaseSyntax : DeclareBase { ActionSowBaseSyntax () : DeclareBase (Action::component, "sow_base", "Shared sowing parameters.") @@ -90,7 +91,7 @@ ortogonal to the rows as is otherwise assumed by Daisy."); Attribute::OptionalConst, "Amount of seed applied.\n\ By default, initial growth will be governed by 'typical' seed amounts."); } -} ActionSowBase_syntax; +}; struct ActionSow : public ActionSowBase { @@ -112,7 +113,7 @@ struct ActionSow : public ActionSowBase }; // Add the ActionSow syntax to the syntax table. -static struct ActionSowSyntax : DeclareModel +struct ActionSowSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionSow (al); } @@ -126,10 +127,7 @@ static struct ActionSowSyntax : DeclareModel frame.declare_object ("crop", Crop::component, "Crop to sow."); frame.order ("crop"); } -} ActionSow_syntax; - -static DeclareAlias -ActionPlant_syntax (Action::component, "plant", "sow"); +}; struct ActionSowObject : public ActionSowBase { @@ -164,7 +162,7 @@ struct ActionSowObject : public ActionSowBase }; // Add the ActionSowObject syntax to the syntax table. -static struct ActionSowObjectSyntax : DeclareModel +struct ActionSowObjectSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionSowObject (al); } @@ -179,7 +177,7 @@ Unlike the normal 'sow', this action can only be called once per simulation.") frame.declare_object ("crop", Crop::component, "Crop to sow."); frame.order ("crop"); } -} ActionSowObject_syntax; +}; struct ActionSowName : public ActionSowBase { @@ -210,7 +208,7 @@ struct ActionSowName : public ActionSowBase }; // Add the ActionSowName syntax to the syntax table. -static struct ActionSowNameSyntax : DeclareModel +struct ActionSowNameSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionSowName (al); } @@ -226,6 +224,16 @@ This name can be a reference parameter.") frame.set_check ("crop", Crop::check_buildable ()); frame.order ("crop"); } -} ActionSowName_syntax; +}; + +void +register_action_sow_models () +{ + static ActionSowBaseSyntax action_sow_base_syntax; + static ActionSowSyntax action_sow_syntax; + static DeclareAlias action_plant_syntax (Action::component, "plant", "sow"); + static ActionSowObjectSyntax action_sow_object_syntax; + static ActionSowNameSyntax action_sow_name_syntax; +} // action_sow.C ends here. diff --git a/src/daisy/manager/action_spray.C b/src/daisy/manager/action_spray.C index 39f7992ac..387f28f5f 100644 --- a/src/daisy/manager/action_spray.C +++ b/src/daisy/manager/action_spray.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "object_model/block_model.h" #include "daisy/daisy.h" @@ -60,7 +61,7 @@ struct ActionSpray : public Action }; // Add the ActionSpray syntax to the syntax table. -static struct ActionSpraySyntax : DeclareModel +struct ActionSpraySyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionSpray (al); } @@ -78,7 +79,7 @@ Spray a chemical (typically a pesticide) on the field.") "Amount of pesticide to spray."); frame.order ("chemical", "amount"); } -} ActionSpray_syntax; +}; struct ActionSpraySurface : public Action { @@ -108,7 +109,7 @@ struct ActionSpraySurface : public Action }; // Add the ActionSpraySurface syntax to the syntax table. -static struct ActionSpraySurfaceSyntax : DeclareModel +struct ActionSpraySurfaceSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionSpraySurface (al); } @@ -126,7 +127,7 @@ Spray a chemical (typically a pesticide) on the field below the canopy.") "Amount of pesticide to spray."); frame.order ("chemical", "amount"); } -} ActionSpraySurface_syntax; +}; struct ActionRemoveSolute : public Action { @@ -155,7 +156,7 @@ struct ActionRemoveSolute : public Action }; // Add the ActionRemoveSolute syntax to the syntax table. -static struct ActionRemoveSoluteSyntax : DeclareModel +struct ActionRemoveSoluteSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionRemoveSolute (al); } @@ -171,6 +172,14 @@ Remove a specific chemical from the field.") frame.set_check ("chemical", Chemical::check_buildable ()); frame.order ("chemical"); } -} ActionRemoveSolute_syntax; +}; + +void +register_action_spray_models () +{ + static ActionSpraySyntax action_spray_syntax; + static ActionSpraySurfaceSyntax action_spray_surface_syntax; + static ActionRemoveSoluteSyntax action_remove_solute_syntax; +} // action_spray.C ends here. diff --git a/src/daisy/manager/action_stop.C b/src/daisy/manager/action_stop.C index 84f33a19e..ebd633ff8 100644 --- a/src/daisy/manager/action_stop.C +++ b/src/daisy/manager/action_stop.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "daisy/daisy.h" #include "object_model/librarian.h" @@ -42,7 +43,7 @@ struct ActionStop : public Action { } }; -static struct ActionStopSyntax : DeclareModel +struct ActionStopSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionStop (al); } @@ -51,6 +52,12 @@ static struct ActionStopSyntax : DeclareModel { } void load_frame (Frame&) const { } -} ActionStop_syntax; +}; + +void +register_action_stop_models () +{ + static ActionStopSyntax action_stop_syntax; +} // action_stop.C ends here. diff --git a/src/daisy/manager/action_surface.C b/src/daisy/manager/action_surface.C index e77ad1eee..014141e8b 100644 --- a/src/daisy/manager/action_surface.C +++ b/src/daisy/manager/action_surface.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "object_model/block_model.h" #include "daisy/daisy.h" @@ -55,7 +56,7 @@ struct ActionSetSurfaceDetentionCapacity : public Action { } }; -static struct ActionSurfaceSyntax : DeclareModel +struct ActionSurfaceSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionSetSurfaceDetentionCapacity (al); } @@ -70,6 +71,12 @@ Set amount of ponding the surface can retain.") "Max ponding height before runoff."); frame.order ("height"); } -} ActionSurface_syntax; +}; + +void +register_action_surface_models () +{ + static ActionSurfaceSyntax action_surface_syntax; +} // action_surface.C ends here. diff --git a/src/daisy/manager/action_table.C b/src/daisy/manager/action_table.C index 8282a9b30..3551fbe7c 100644 --- a/src/daisy/manager/action_table.C +++ b/src/daisy/manager/action_table.C @@ -20,6 +20,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "object_model/metalib.h" #include "object_model/library.h" @@ -350,7 +351,7 @@ ActionTable::ActionTable (const BlockModel& al) } // Add the ActionTable syntax to the syntax table. -static struct ActionTableSyntax : DeclareModel +struct ActionTableSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionTable (al); } @@ -440,6 +441,12 @@ Height where you want to end the incorporation (a negative number).\n\ OBSOLETE: Use (volume box (bottom TO)) instead."); frame.set ("to", -25.0); } -} ActionTable_syntax; +}; + +void +register_action_table_models () +{ + static ActionTableSyntax action_table_syntax; +} // action_table.C ends here. diff --git a/src/daisy/manager/action_tillage.C b/src/daisy/manager/action_tillage.C index 25ba82c4c..ed859c4e4 100644 --- a/src/daisy/manager/action_tillage.C +++ b/src/daisy/manager/action_tillage.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "object_model/block_model.h" #include "daisy/daisy.h" @@ -63,7 +64,7 @@ struct ActionMix : public Action { } }; -static struct ActionMixSyntax : DeclareModel +struct ActionMixSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionMix (al); } @@ -91,7 +92,7 @@ by this operation."); Fraction of surface beeing loosened by opretation.\n\ By defeault, this is equal to 'penetration'."); } -} ActionMix_syntax; +}; struct ActionSwap : public Action { @@ -123,7 +124,7 @@ struct ActionSwap : public Action { } }; -static struct ActionSwapSyntax : DeclareModel +struct ActionSwapSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionSwap (al); } @@ -162,7 +163,7 @@ Random roughhness generated by tillage operation."); frame.set ("random_roughness", 0.024); } -} ActionSwap_syntax; +}; struct ActionSetPorosity : public Action @@ -192,7 +193,7 @@ struct ActionSetPorosity : public Action { } }; -static struct ActionSetPorositySyntax : DeclareModel +struct ActionSetPorositySyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionSetPorosity (al); } @@ -210,7 +211,7 @@ Non-solid fraction of soil."); A point in the horizon to modify."); frame.set ("depth", 0.0); } -} ActionSetPorosity_syntax; +}; struct ActionRemoveLitter : public Action { @@ -234,7 +235,7 @@ struct ActionRemoveLitter : public Action { } }; -static struct ActionRemoveLitterSyntax : DeclareModel +struct ActionRemoveLitterSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionRemoveLitter (al); } @@ -245,7 +246,7 @@ Remove organic matter from soil surface.") { } void load_frame (Frame& frame) const { } -} ActionRemoveLitter_syntax; +}; struct ActionStoreSOM : public Action { @@ -268,7 +269,7 @@ struct ActionStoreSOM : public Action { } }; -static struct ActionStoreSOMSyntax : DeclareModel +struct ActionStoreSOMSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionStoreSOM (al); } @@ -279,7 +280,7 @@ Store the content of the soil organic matter pools.") { } void load_frame (Frame& frame) const { } -} ActionStoreSOM_syntax; +}; struct ActionRestoreSOM : public Action { @@ -302,7 +303,7 @@ struct ActionRestoreSOM : public Action { } }; -static struct ActionRestoreSOMSyntax : DeclareModel +struct ActionRestoreSOMSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionRestoreSOM (al); } @@ -313,6 +314,17 @@ Restore the content of the soil organic matter pools.") { } void load_frame (Frame& frame) const { } -} ActionRestoreSOM_syntax; +}; + +void +register_action_tillage_models () +{ + static ActionMixSyntax action_mix_syntax; + static ActionSwapSyntax action_swap_syntax; + static ActionSetPorositySyntax action_set_porosity_syntax; + static ActionRemoveLitterSyntax action_remove_litter_syntax; + static ActionStoreSOMSyntax action_store_som_syntax; + static ActionRestoreSOMSyntax action_restore_som_syntax; +} // action_tillage.C ends here. diff --git a/src/daisy/manager/action_wait.C b/src/daisy/manager/action_wait.C index b207582f6..de7d49823 100644 --- a/src/daisy/manager/action_wait.C +++ b/src/daisy/manager/action_wait.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "object_model/block_model.h" #include "daisy/condition.h" @@ -151,7 +152,7 @@ struct ActionWaitMMDD : public Action { } }; -static struct ActionWaitSyntax : public DeclareModel +struct ActionWaitSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionWait (al); } @@ -165,9 +166,9 @@ Wait until the specified condition is true.") "Condition to wait for."); frame.order ("condition"); } -} ActionWait_syntax; +}; -static struct ActionWaitPeriodSyntax : public DeclareModel +struct ActionWaitPeriodSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionWaitDays (al); } @@ -200,9 +201,9 @@ Waits the specified period.") "Wait until this date.\ Setting this overrides the 'days' and 'hours' parameters.", Time::load_syntax); } -} ActionWaitPeriod_syntax; +}; -static struct ActionWaitDaysSyntax : public DeclareParam +struct ActionWaitDaysSyntax : public DeclareParam { ActionWaitDaysSyntax () : DeclareParam (Action::component, "wait_days", "wait_period", "\ @@ -213,9 +214,9 @@ Waits the specified number of days.") frame.set ("hours", 0); frame.order ("days"); } -} ActionWaitDays_syntax; +}; -static struct ActionWaitHoursSyntax : public DeclareParam +struct ActionWaitHoursSyntax : public DeclareParam { ActionWaitHoursSyntax () : DeclareParam (Action::component, "wait_hours", "wait_period", "\ @@ -226,9 +227,9 @@ Waits the specified number of hours.") frame.set ("days", 0); frame.order ("hours"); } -} ActionWaitHours_syntax; +}; -static struct ActionWaitMMDDSyntax : public DeclareModel +struct ActionWaitMMDDSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionWaitMMDD (al); } @@ -276,7 +277,7 @@ Wait until a specific month and day in the year.") frame.set ("hour", 8); frame.order ("month", "day"); } -} ActionWaitMMDD_syntax; +}; // The 'at' action. @@ -330,7 +331,7 @@ struct ActionAt : public Action { } }; -static struct ActionAtSyntax : public DeclareModel +struct ActionAtSyntax : public DeclareModel { Model* make (const BlockModel& al) const { return new ActionAt (al); } @@ -375,6 +376,17 @@ Do action at specific time.") frame.order ("year", "month", "day"); } -} ActionAt_syntax; +}; + +void +register_action_wait_models () +{ + static ActionWaitSyntax action_wait_syntax; + static ActionWaitPeriodSyntax action_wait_period_syntax; + static ActionWaitDaysSyntax action_wait_days_syntax; + static ActionWaitHoursSyntax action_wait_hours_syntax; + static ActionWaitMMDDSyntax action_wait_mmdd_syntax; + static ActionAtSyntax action_at_syntax; +} // action_wait.C ends here. diff --git a/src/daisy/manager/action_while.C b/src/daisy/manager/action_while.C index 640744afc..59a03416d 100644 --- a/src/daisy/manager/action_while.C +++ b/src/daisy/manager/action_while.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "object_model/frame.h" #include "daisy/output/log.h" @@ -86,7 +87,7 @@ struct ActionWhile : public Action } }; -static struct ActionWhileSyntax : DeclareModel +struct ActionWhileSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionWhile (al); } @@ -117,6 +118,12 @@ list is done.") "List of actions to perform."); frame.order ("actions"); } -} ActionWhile_syntax; +}; + +void +register_action_while_models () +{ + static ActionWhileSyntax action_while_syntax; +} // action_while.C ends here. diff --git a/src/daisy/manager/action_with.C b/src/daisy/manager/action_with.C index 427530830..55d41d87a 100644 --- a/src/daisy/manager/action_with.C +++ b/src/daisy/manager/action_with.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/action.h" #include "object_model/block_model.h" #include "daisy/daisy.h" @@ -120,7 +121,7 @@ public: { sequence_delete (actions.begin (), actions.end ()); } }; -static struct ActionWithColumnSyntax : DeclareModel +struct ActionWithColumnSyntax : DeclareModel { Model* make (const BlockModel& al) const { return new ActionWithColumn (al); } @@ -138,6 +139,12 @@ Perform actions on a specific column.") "Actions to perform on the specified column."); frame.order ("column", "actions"); } -} ActionWithColumn_syntax; +}; + +void +register_action_with_models () +{ + static ActionWithColumnSyntax action_with_column_syntax; +} // action_with.C ends here. diff --git a/src/daisy/manager/irrigate.C b/src/daisy/manager/irrigate.C index 11233b4ba..fa232828a 100644 --- a/src/daisy/manager/irrigate.C +++ b/src/daisy/manager/irrigate.C @@ -20,6 +20,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/manager/irrigate.h" #include "daisy/soil/transport/volume.h" #include "daisy/chemicals/im.h" @@ -389,10 +390,13 @@ Irrigation::Irrigation (const BlockSubmodel& al) Irrigation::~Irrigation () { } -static DeclareSubmodel -irrigation_submodel (Irrigation::load_syntax, "Irrigation", "\ +void +register_irrigation_models () +{ + static DeclareSubmodel irrigation_submodel (Irrigation::load_syntax, + "Irrigation", "\ Keep track of active irrigation events.\n \ Usually not set explicitly, but may be found in a checkpint."); +} // irrigate.C ends here. - diff --git a/src/daisy/organic_matter/am.C b/src/daisy/organic_matter/am.C index 42c2c6730..5b2cb9421 100644 --- a/src/daisy/organic_matter/am.C +++ b/src/daisy/organic_matter/am.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/organic_matter/am.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/organic_matter/aom.h" #include "daisy/chemicals/chemical.h" #include "object_model/metalib.h" @@ -1009,18 +1010,21 @@ AM::initialize (const Geometry& geo, const double max_rooting_depth) AM::~AM () { } -static struct AMInit : public DeclareComponent +void +register_am_models () { - AMInit () - : DeclareComponent (AM::component, "\ + static struct AMInit : public DeclareComponent + { + AMInit () + : DeclareComponent (AM::component, "\ The 'am' component describes various kinds of fertilizer and other\n\ added matter such as crop residues. In particular, it describes how\n\ they decompose.") - { } -} AM_init; + { } + } am_init; -static struct AMMineralSyntax : public DeclareModel -{ + static struct AMMineralSyntax : public DeclareModel + { Model* make (const BlockModel&) const { // We never use this directly, onlu the frame. @@ -1042,12 +1046,12 @@ The remaining nitrogen is assumed to be nitrate."); Fraction of NH4 that evaporates on application."); frame.set ("volatilization", 0.0); } -} AMMineral_syntax; + } am_mineral_syntax; // The 'base' AM base model. -static struct AMBaseSyntax : public DeclareBase -{ + static struct AMBaseSyntax : public DeclareBase + { AMBaseSyntax () : DeclareBase (AM::component, "base", "\ Common attributes for all added organic matter models.") @@ -1069,7 +1073,7 @@ This AM belongs to a still living plant", Attribute::OptionalState, Attribute::Variable, "\ The individual AOM pools."); } -} AMBase_syntax; + } am_base_syntax; // The 'state' AM model. @@ -1082,8 +1086,8 @@ struct AMState : public AM { } }; -static struct AMStateSyntax : public DeclareModel -{ + static struct AMStateSyntax : public DeclareModel + { Model* make (const BlockModel& al) const { return new AMState (al); } AMStateSyntax () @@ -1095,7 +1099,7 @@ pools, each of which have their own turnover rate.") { } void load_frame (Frame&) const { } -} AMState_syntax; + } am_state_syntax; // The 'organic' AM model. @@ -1119,8 +1123,8 @@ struct AMOrganic : public AM { } }; -static struct AMOrganicSyntax : public DeclareModel -{ + static struct AMOrganicSyntax : public DeclareModel + { Model* make (const BlockModel& al) const { return new AMOrganic (al); } AMOrganicSyntax () @@ -1161,7 +1165,7 @@ The remaining nitrogen is assumed to be nitrate or organic."); Fraction of NH4 that evaporates on application."); frame.set ("volatilization", 0.0); } -} AMOrganic_syntax; + } am_organic_syntax; // The 'initial' AM model. @@ -1229,8 +1233,8 @@ struct AMInitial : public AM { } }; -static struct AMInitialSyntax : public DeclareModel -{ + static struct AMInitialSyntax : public DeclareModel + { Model* make (const BlockModel& al) const { return new AMInitial (al); } AMInitialSyntax () @@ -1276,7 +1280,7 @@ Height where this layer ends (a negative number)."); Carbon content in different soil layers. The carbon is assumed to be\n \ uniformly distributed in each layer.", load_layer); } -} AMInitial_syntax; + } am_initial_syntax; // The 'root' AM model. @@ -1310,8 +1314,8 @@ struct AMRoot : public AM { } }; -static struct AMRootSyntax : public DeclareModel -{ + static struct AMRootSyntax : public DeclareModel + { Model* make (const BlockModel& al) const { return new AMRoot (al); } AMRootSyntax () @@ -1362,7 +1366,7 @@ original."); frame.set ("total_N_fraction", 0.01); frame.set ("om", AM::default_AM ()); } -} AMRoot_syntax; + } am_root_syntax; // The 'AM_table' program model. @@ -1424,8 +1428,8 @@ struct ProgramAM_table : public Program { } }; -static struct ProgramAM_tableSyntax : DeclareModel -{ + static struct ProgramAM_tableSyntax : DeclareModel + { Model* make (const BlockModel& al) const { return new ProgramAM_table (al); } ProgramAM_tableSyntax () @@ -1434,6 +1438,7 @@ Generate a table of fertilizers.") { } void load_frame (Frame& frame) const { } -} ProgramAM_table_syntax; + } program_am_table_syntax; +} // am.C ends here. diff --git a/src/daisy/organic_matter/aom.C b/src/daisy/organic_matter/aom.C index a3c2f0b61..8c5522a01 100644 --- a/src/daisy/organic_matter/aom.C +++ b/src/daisy/organic_matter/aom.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/organic_matter/aom.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/librarian.h" #include "object_model/frame.h" #include "object_model/check.h" @@ -297,63 +298,66 @@ AOM::AOM (const BlockModel& al) top_N (al.number ("top_N")) { } -static struct AOMInit : public DeclareSolo +void +register_aom_models () { - bool used_to_be_a_submodel () const - { return true; } - Model* make (const BlockModel& al) const - { return new AOM (al); } - void load_frame (Frame& frame) const + static struct AOMInit : public DeclareSolo { - OM::load_syntax (frame, "\ + bool used_to_be_a_submodel () const + { return true; } + Model* make (const BlockModel& al) const + { return new AOM (al); } + void load_frame (Frame& frame) const + { + OM::load_syntax (frame, "\ The first numbers corresponds to each of the SMB pools, the next\n\ number to the SOM buffer, and any remaining numbers to each of\n\ the DOM pools. The length of the sequence should thus be the number\n\ of SMB pools plus 1 plus optionally the number of DOM pools."); - frame.declare_fraction ("initial_fraction", Attribute::OptionalConst, "\ + frame.declare_fraction ("initial_fraction", Attribute::OptionalConst, "\ The initial fraction of the total available carbon\n\ allocated to this pool for AOM. One pool should be left unspecified."); - frame.declare ("top_C", "g C/cm^2", Check::non_negative (), Attribute::State, + frame.declare ("top_C", "g C/cm^2", Check::non_negative (), Attribute::State, "Carbon on top of soil."); - frame.set ("top_C", 0.0); - frame.declare ("top_N", "g N/cm^2", Check::non_negative (), Attribute::State, + frame.set ("top_C", 0.0); + frame.declare ("top_N", "g N/cm^2", Check::non_negative (), Attribute::State, "Nitrogen on top of soil."); - frame.set ("top_N", 0.0); - } - AOMInit () - : DeclareSolo (AOM::component, "\ + frame.set ("top_N", 0.0); + } + AOMInit () + : DeclareSolo (AOM::component, "\ A single Added Organic Matter pool.") - { } -} AOM_init; + { } + } aom_init; -static struct AOMSlowSyntax : public DeclareParam -{ - AOMSlowSyntax () - : DeclareParam (AOM::component, "AOM-SLOW", root_name (), "\ -Slow AOM pool parameterization by Sander Bruun.") - { } - void load_frame (Frame& frame) const + static struct AOMSlowSyntax : public DeclareParam { - frame.set_strings ("cite", "daisy-somnew"); - frame.set ("initial_fraction", 0.80); - std::vector CN; - CN.push_back (90.0); - frame.set ("C_per_N", CN); - std::vector efficiency1; - efficiency1.push_back (0.50); - efficiency1.push_back (0.50); - frame.set ("efficiency", efficiency1); - Rate::set_rate (frame, "turnover", 2.0e-4); - std::vector fractions1; - fractions1.push_back (0.00); - fractions1.push_back (1.00); - fractions1.push_back (0.00); - frame.set ("fractions", fractions1); - } -} AOMSlow_syntax; + AOMSlowSyntax () + : DeclareParam (AOM::component, "AOM-SLOW", root_name (), "\ +Slow AOM pool parameterization by Sander Bruun.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "daisy-somnew"); + frame.set ("initial_fraction", 0.80); + std::vector CN; + CN.push_back (90.0); + frame.set ("C_per_N", CN); + std::vector efficiency1; + efficiency1.push_back (0.50); + efficiency1.push_back (0.50); + frame.set ("efficiency", efficiency1); + Rate::set_rate (frame, "turnover", 2.0e-4); + std::vector fractions1; + fractions1.push_back (0.00); + fractions1.push_back (1.00); + fractions1.push_back (0.00); + frame.set ("fractions", fractions1); + } + } aom_slow_syntax; -static struct AOMSlowOldSyntax : public DeclareParam -{ + static struct AOMSlowOldSyntax : public DeclareParam + { AOMSlowOldSyntax () : DeclareParam (AOM::component, "AOM-SLOW-OLD", "AOM-SLOW", "\ Original parameterization of the slow AOM pool.") @@ -367,10 +371,10 @@ Original parameterization of the slow AOM pool.") fractions1.push_back (0.00); frame.set ("fractions", fractions1); } -} AOMSlowOld_syntax; + } aom_slow_old_syntax; -static struct AOMFastSyntax : public DeclareParam -{ + static struct AOMFastSyntax : public DeclareParam + { AOMFastSyntax () : DeclareParam (AOM::component, "AOM-FAST", root_name (), "\ Fast AOM pool parameterization by Sander Bruun.") @@ -389,10 +393,10 @@ Fast AOM pool parameterization by Sander Bruun.") fractions2.push_back (0.00); frame.set ("fractions", fractions2); } -} AOMFast_syntax; + } aom_fast_syntax; -static struct AOMDirectSyntax : public DeclareParam -{ + static struct AOMDirectSyntax : public DeclareParam + { AOMDirectSyntax () : DeclareParam (AOM::component, "AOM-DIRECT", root_name (), "\ Third AOM pool of already decomposed material.") @@ -409,10 +413,10 @@ Third AOM pool of already decomposed material.") fractions1.push_back (1.00); frame.set ("fractions", fractions1); } -} AOMDirect_syntax; + } aom_direct_syntax; -static struct AOMSlowCropSyntax : public DeclareParam -{ + static struct AOMSlowCropSyntax : public DeclareParam + { AOMSlowCropSyntax () : DeclareParam (AOM::component, "CROP-SLOW", "AOM-SLOW", "\ Parameterization used for slow pool of some crop residuals.") @@ -424,10 +428,10 @@ Parameterization used for slow pool of some crop residuals.") frame.set ("C_per_N", CN); Rate::set_rate (frame, "turnover", 2.917E-0004); } -} AOMSlowCrop_syntax; + } aom_slow_crop_syntax; -static struct AOMFastCropSyntax : public DeclareParam -{ + static struct AOMFastCropSyntax : public DeclareParam + { AOMFastCropSyntax () : DeclareParam (AOM::component, "CROP-FAST", "AOM-FAST", "\ Parameterization used for fast pool of some crop residuals.") @@ -436,6 +440,7 @@ Parameterization used for fast pool of some crop residuals.") { Rate::set_rate (frame, "turnover", 2.917E-0003); } -} AOMFastCrop_syntax; + } aom_fast_crop_syntax; +} // aom.C ends here. diff --git a/src/daisy/organic_matter/bioincorporation.C b/src/daisy/organic_matter/bioincorporation.C index 2e545b049..236a1f689 100644 --- a/src/daisy/organic_matter/bioincorporation.C +++ b/src/daisy/organic_matter/bioincorporation.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/organic_matter/bioincorporation.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/frame_submodel.h" #include "daisy/output/log.h" #include "daisy/soil/transport/geometry.h" @@ -37,20 +38,6 @@ #include #include -static struct AOMSlowBioincorporationSyntax : public DeclareParam -{ - AOMSlowBioincorporationSyntax () - : DeclareParam (AOM::component, "AOM-SLOW-BIOINCORPORATION", "AOM-SLOW", "\ -Lower C/N ration for bioincorporated matter.") - { } - void load_frame (Frame& frame) const - { - std::vector CN; - CN.push_back (60.0); - frame.set ("C_per_N", CN); - } -} AOMSlowBioincorporation_syntax; - struct Bioincorporation::Implementation { // Parameters. @@ -364,8 +351,27 @@ Bioincorporation::Bioincorporation (const FrameSubmodel& al) Bioincorporation::~Bioincorporation () { } -static DeclareSubmodel -bioincorporation_submodel (Bioincorporation::load_syntax, "Bioincorporation", "\ +void +register_bioincorporation_models () +{ + static struct AOMSlowBioincorporationSyntax : public DeclareParam + { + AOMSlowBioincorporationSyntax () + : DeclareParam (AOM::component, "AOM-SLOW-BIOINCORPORATION", "AOM-SLOW", "\ +Lower C/N ration for bioincorporated matter.") + { } + void load_frame (Frame& frame) const + { + std::vector CN; + CN.push_back (60.0); + frame.set ("C_per_N", CN); + } + } aom_slow_bioincorporation_syntax; + + static DeclareSubmodel + bioincorporation_submodel (Bioincorporation::load_syntax, + "Bioincorporation", "\ Biological incorporation of organic matter in soil."); +} // bioincorporation.C ends here. diff --git a/src/daisy/organic_matter/clayom.C b/src/daisy/organic_matter/clayom.C index 1cb0bfc56..0315cd7e3 100644 --- a/src/daisy/organic_matter/clayom.C +++ b/src/daisy/organic_matter/clayom.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/organic_matter/clayom.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" @@ -40,16 +41,23 @@ ClayOM::ClayOM (const BlockModel& al) ClayOM::~ClayOM () { } -static struct ClayOMInit : public DeclareComponent +void +register_clay_om_models () { - void load_frame (Frame& frame) const + static struct ClayOMInit : public DeclareComponent { - Model::load_model (frame); - } - ClayOMInit () - : DeclareComponent (ClayOM::component, "\ + void load_frame (Frame& frame) const + { + Model::load_model (frame); + } + ClayOMInit () + : DeclareComponent (ClayOM::component, "\ Find the effect of clay on organic matter processing.") - { } -} ClayOM_init; + { } + } clay_om_init; + + register_clay_om_old_models (); + register_clay_om_biomod_models (); +} // clayom.C ends here. diff --git a/src/daisy/organic_matter/clayom_biomod.C b/src/daisy/organic_matter/clayom_biomod.C index b0b2ab78a..ba023168a 100644 --- a/src/daisy/organic_matter/clayom_biomod.C +++ b/src/daisy/organic_matter/clayom_biomod.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/organic_matter/clayom.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/check.h" #include "daisy/organic_matter/smb.h" @@ -242,45 +243,49 @@ ClayOMBiomod::ClayOMBiomod (const BlockModel& al) ClayOMBiomod::~ClayOMBiomod () { } -static struct ClayOMBiomodSyntax : public DeclareModel +void +register_clay_om_biomod_models () { - Model* make (const BlockModel& al) const - { return new ClayOMBiomod (al); } + static struct ClayOMBiomodSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new ClayOMBiomod (al); } - ClayOMBiomodSyntax () - : DeclareModel (ClayOM::component, "biomod", - "Clay influence on organic matter from BIOMOD project.\n\ + ClayOMBiomodSyntax () + : DeclareModel (ClayOM::component, "biomod", + "Clay influence on organic matter from BIOMOD project.\n\ All SMB pools are affected, but not the SOM pools. Additionally, the\n\ ration between maintenance and turnover is also clay dependent.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("cite", "biomod", "biomod2", "pedersen2007model"); - frame.declare ("a", Attribute::None (), Check::positive (), Attribute::Const, - "Maintenance parameter."); + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("cite", "biomod", "biomod2", "pedersen2007model"); + frame.declare ("a", Attribute::None (), Check::positive (), + Attribute::Const, "Maintenance parameter."); #ifdef OLD_VERSION - frame.declare ("alpha", Attribute::None (), Check::positive (), Attribute::Const, - "Speed parameter."); + frame.declare ("alpha", Attribute::None (), Check::positive (), + Attribute::Const, "Speed parameter."); #else // !OLD_VERSION - frame.declare ("factor", Attribute::Fraction (), Attribute::None (), - Attribute::Const, "\ + frame.declare ("factor", Attribute::Fraction (), Attribute::None (), + Attribute::Const, "\ Function of clay content, multiplied to the maintenance and turnover rates\n\ of the SMB pools."); - PLF factor; - factor.add (0.00, 1.0); - factor.add (0.25, 0.5); - factor.add (1.00, 0.5); - frame.set ("factor", factor); + PLF factor; + factor.add (0.00, 1.0); + factor.add (0.25, 0.5); + factor.add (1.00, 0.5); + frame.set ("factor", factor); #endif // !OLD_VERSION - frame.declare_fraction ("E_SMB", Attribute::Const, - "SMB efficiency in processing organic matter.\n\ + frame.declare_fraction ("E_SMB", Attribute::Const, + "SMB efficiency in processing organic matter.\n\ Note that you must set the 'efficiency' parameter for all OM pools to\n\ this number for the BIOMOD clay response model to work correctly."); - frame.declare_fraction ("f_SMB1", Attribute::Const, - "Fraction of AOM pools goind to SMB1.\n\ + frame.declare_fraction ("f_SMB1", Attribute::Const, + "Fraction of AOM pools goind to SMB1.\n\ Only the fraction of AOM going to a SMB pool count, so this is really\n\ a fraction of the fraction coing to the SMB pools.\n\ Note that you must set the 'fraction' parameter of all AOM pools to\n\ reflect this for the BIOMOD clay response model to work correctly."); - } -} ClayOMBiomod_syntax; + } + } clay_om_biomod_syntax; +} diff --git a/src/daisy/organic_matter/clayom_old.C b/src/daisy/organic_matter/clayom_old.C index 897ccea0a..8158dedcc 100644 --- a/src/daisy/organic_matter/clayom_old.C +++ b/src/daisy/organic_matter/clayom_old.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/organic_matter/clayom.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/plf.h" #include "daisy/organic_matter/smb.h" @@ -89,17 +90,20 @@ ClayOMOld::ClayOMOld (const BlockModel& al) ClayOMOld::~ClayOMOld () { } -static struct ClayOMOldSyntax : public DeclareModel +void +register_clay_om_old_models () { - Model* make (const BlockModel& al) const - { return new ClayOMOld (al); } - - ClayOMOldSyntax () - : DeclareModel (ClayOM::component, "old", - "Traditional clay influence on organic matter.") - { } - void load_frame (Frame& frame) const + static struct ClayOMOldSyntax : public DeclareModel { + Model* make (const BlockModel& al) const + { return new ClayOMOld (al); } + + ClayOMOldSyntax () + : DeclareModel (ClayOM::component, "old", + "Traditional clay influence on organic matter.") + { } + void load_frame (Frame& frame) const + { frame.declare ("factor", Attribute::Fraction (), Attribute::None (), Attribute::Const, "\ @@ -111,7 +115,8 @@ of SMB1 and all SOM pools."); factor.add (1.00, 0.5); frame.set ("factor", factor); - } -} ClayOMOld_syntax; + } + } clay_om_old_syntax; +} // clayom_old.C ends here. diff --git a/src/daisy/organic_matter/doe.C b/src/daisy/organic_matter/doe.C index a67ab3fb6..c6c4eb659 100644 --- a/src/daisy/organic_matter/doe.C +++ b/src/daisy/organic_matter/doe.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/organic_matter/doe.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/output/log.h" #include "daisy/soil/transport/geometry.h" #include "object_model/librarian.h" @@ -133,8 +134,12 @@ DOE::DOE (const FrameSubmodel& al) DOE::~DOE () { } -static DeclareSubmodel -dom_element_submodel (DOE::load_syntax, "DOM-Element", "\ +void +register_doe_models () +{ + static DeclareSubmodel + dom_element_submodel (DOE::load_syntax, "DOM-Element", "\ A single element in a Dissolved Organic Matter pool."); +} // doe.C ends here diff --git a/src/daisy/organic_matter/dom.C b/src/daisy/organic_matter/dom.C index 91a10bc05..8cbe3529c 100644 --- a/src/daisy/organic_matter/dom.C +++ b/src/daisy/organic_matter/dom.C @@ -22,6 +22,7 @@ #include "daisy/organic_matter/dom.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/organic_matter/doe.h" #include "daisy/organic_matter/smb.h" #include "daisy/organic_matter/om.h" @@ -243,5 +244,9 @@ DOM::~DOM () delete &N; } -static DeclareSubmodel dom_submodel (DOM::load_syntax, "DOM", "\ +void +register_dom_models () +{ + static DeclareSubmodel dom_submodel (DOM::load_syntax, "DOM", "\ A single Dissolved Organic Matter pool."); +} diff --git a/src/daisy/organic_matter/domsorp.C b/src/daisy/organic_matter/domsorp.C index 07e41b330..94ba591bb 100644 --- a/src/daisy/organic_matter/domsorp.C +++ b/src/daisy/organic_matter/domsorp.C @@ -22,6 +22,7 @@ #include "daisy/organic_matter/domsorp.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" @@ -41,16 +42,22 @@ Domsorp::Domsorp (const BlockModel& al) Domsorp::~Domsorp () { } -static struct DomsorpInit : public DeclareComponent +void +register_domsorp_models () { - void load_frame (Frame& frame) const - { - Model::load_model (frame); - } - DomsorpInit () - : DeclareComponent (Domsorp::component, "\ + static struct DomsorpInit : public DeclareComponent + { + void load_frame (Frame& frame) const + { + Model::load_model (frame); + } + DomsorpInit () + : DeclareComponent (Domsorp::component, "\ Sorption and desorption of DOM to SOM.") - { } -} Domsorp_init; + { } + } domsorp_init; + + register_domsorp_standard_models (); +} // domsorp.C ends here. diff --git a/src/daisy/organic_matter/domsorp_std.C b/src/daisy/organic_matter/domsorp_std.C index e5a04aba1..f148c9344 100644 --- a/src/daisy/organic_matter/domsorp_std.C +++ b/src/daisy/organic_matter/domsorp_std.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/organic_matter/domsorp.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "daisy/chemicals/transform.h" #include "daisy/organic_matter/dom.h" @@ -129,16 +130,19 @@ struct DomsorpStandard : public Domsorp { } }; -static struct DomsorpStandardSyntax : public DeclareModel +void +register_domsorp_standard_models () { - Model* make (const BlockModel& al) const - { return new DomsorpStandard (al); } - DomsorpStandardSyntax () - : DeclareModel (Domsorp::component, "default", - "Transformation between two soil chemicals.") - { } - void load_frame (Frame& frame) const + static struct DomsorpStandardSyntax : public DeclareModel { + Model* make (const BlockModel& al) const + { return new DomsorpStandard (al); } + DomsorpStandardSyntax () + : DeclareModel (Domsorp::component, "default", + "Transformation between two soil chemicals.") + { } + void load_frame (Frame& frame) const + { frame.declare_object ("transform", Transform::component, "Tranformation process between DOM and SOM."); frame.declare_integer ("dom_pool", Attribute::Const, @@ -150,5 +154,6 @@ static struct DomsorpStandardSyntax : public DeclareModel frame.declare ("S_N", "g N/cm^3/h", Attribute::LogOnly, Attribute::SoilCells, "Carbon converted from DOM to SOM (may be negative)."); - } -} DomsorpStandard_syntax; + } + } domsorp_standard_syntax; +} diff --git a/src/daisy/organic_matter/organic.C b/src/daisy/organic_matter/organic.C index d2228d9ae..c65e31b1a 100644 --- a/src/daisy/organic_matter/organic.C +++ b/src/daisy/organic_matter/organic.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/organic_matter/organic.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" @@ -40,12 +41,28 @@ OrganicMatter::OrganicMatter (const BlockModel& al) OrganicMatter::~OrganicMatter () { } -static struct OrganicInit : public DeclareComponent +void +register_organic_matter_models () { - OrganicInit () - : DeclareComponent (OrganicMatter::component, "\ + static struct OrganicInit : public DeclareComponent + { + OrganicInit () + : DeclareComponent (OrganicMatter::component, "\ Turnover of organic matter in the soil.") - { } -} Organic_init; + { } + } organic_init; + + register_aom_models (); + register_som_models (); + register_smb_models (); + register_dom_models (); + register_doe_models (); + register_domsorp_models (); + register_clay_om_models (); + register_am_models (); + register_bioincorporation_models (); + register_organic_standard_models (); + register_organic_none_models (); +} // organic.C ends here. diff --git a/src/daisy/organic_matter/organic_none.C b/src/daisy/organic_matter/organic_none.C index c8779eb51..ab298d1e1 100644 --- a/src/daisy/organic_matter/organic_none.C +++ b/src/daisy/organic_matter/organic_none.C @@ -20,6 +20,7 @@ #define BUILD_DLL #include "daisy/organic_matter/organic.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/soil/transport/geometry.h" #include "object_model/librarian.h" #include "object_model/frame.h" @@ -133,17 +134,21 @@ struct OrganicNone : public OrganicMatter { } }; -static struct OrganicNoneSyntax : public DeclareModel +void +register_organic_none_models () { - Model* make (const BlockModel& al) const - { return new OrganicNone (al); } + static struct OrganicNoneSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new OrganicNone (al); } - OrganicNoneSyntax () - : DeclareModel (OrganicMatter::component, "none", "\ + OrganicNoneSyntax () + : DeclareModel (OrganicMatter::component, "none", "\ Ignore all soil organic matter dynamics.") - { } - void load_frame (Frame&) const - { } -} OrganicNone_syntax; + { } + void load_frame (Frame&) const + { } + } organic_none_syntax; +} // organic_none.C ends here. diff --git a/src/daisy/organic_matter/organic_std.C b/src/daisy/organic_matter/organic_std.C index e89a353d9..ba57a89d5 100644 --- a/src/daisy/organic_matter/organic_std.C +++ b/src/daisy/organic_matter/organic_std.C @@ -23,6 +23,7 @@ #define BUILD_DLL #include "daisy/organic_matter/organic.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/frame_submodel.h" #include "object_model/frame_model.h" #include "object_model/submodeler.h" @@ -3113,31 +3114,34 @@ check_alist (const Metalib&, const Frame& al, Treelog& err) return ok; } -static struct OrganicStandardSyntax : DeclareModel +void +register_organic_standard_models () { - bool used_to_be_a_submodel () const - { return true; } + static struct OrganicStandardSyntax : DeclareModel + { + bool used_to_be_a_submodel () const + { return true; } - Model* make (const BlockModel& al) const - { return new OrganicStandard (al); } + Model* make (const BlockModel& al) const + { return new OrganicStandard (al); } - OrganicStandardSyntax () - : DeclareModel (OrganicMatter::component, "default", "\ + OrganicStandardSyntax () + : DeclareModel (OrganicMatter::component, "default", "\ Mineralization and immobilization in soil.") - { } + { } - static void load_layer (Frame& frame) - { - frame.declare ("end", "cm", Check::negative (), Attribute::Const, "\ + static void load_layer (Frame& frame) + { + frame.declare ("end", "cm", Check::negative (), Attribute::Const, "\ End point of this layer (a negative number)."); - frame.declare ("weight", "kg C/m^2", Check::positive (), Attribute::Const, "\ + frame.declare ("weight", "kg C/m^2", Check::positive (), Attribute::Const, "\ Organic carbon content of this layer."); - frame.order ("end", "weight"); - } + frame.order ("end", "weight"); + } - void load_frame (Frame& frame) const - { - Model::load_model (frame); + void load_frame (Frame& frame) const + { + Model::load_model (frame); frame.set_strings ("cite", "daisy-fertilizer", "daisy-somnew"); frame.add_check (check_alist); frame.declare_boolean ("active_underground", Attribute::Const, "\ @@ -3281,40 +3285,41 @@ If 'SOM_fractions' has been specified, the pools will be initialized\n\ assuming the SMB pools are in equilibrium. Otherwise, also SOM pools\n\ expect the first will be assumed to be in equilibrium as well.", OrganicStandard::Initialization::load_syntax); - } -} OrganicStandard_syntax; + } + } organic_standard_syntax; -static struct Organic2000Syntax : public DeclareParam -{ - Organic2000Syntax () - : DeclareParam (OrganicMatter::component, "SOM2000", "default", "\ + static struct Organic2000Syntax : public DeclareParam + { + Organic2000Syntax () + : DeclareParam (OrganicMatter::component, "SOM2000", "default", "\ Using pre Daisy v7 parameterization of SMB-FAST.\n\ Also, disable respiration for bioincorporation.") - { } - void load_frame (Frame& frame) const - { - frame.set_strings ("smb", "SMB-SLOW", "SMB-FAST-2000"); - - // Overwrite Bioincorporation::respiration. - boost::shared_ptr bio - (new FrameSubmodelValue (frame.submodel ("Bioincorporation"), - Frame::parent_link)); - bio->set ("respiration", 0.5); - frame.set ("Bioincorporation", bio); - } -} Organic2000_syntax; + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("smb", "SMB-SLOW", "SMB-FAST-2000"); + + // Overwrite Bioincorporation::respiration. + boost::shared_ptr bio + (new FrameSubmodelValue (frame.submodel ("Bioincorporation"), + Frame::parent_link)); + bio->set ("respiration", 0.5); + frame.set ("Bioincorporation", bio); + } + } organic_2000_syntax; -static struct Organic2025 : public DeclareParam -{ - Organic2025 () - : DeclareParam (OrganicMatter::component, "SOM2025", "default", "\ -Using Daisy v7 parameterization of SMB-FAST.") - { } - void load_frame (Frame& frame) const + static struct Organic2025 : public DeclareParam { - frame.set_strings ("smb", "SMB-SLOW", "SMB-FAST"); - } -} Organic2025_syntax; + Organic2025 () + : DeclareParam (OrganicMatter::component, "SOM2025", "default", "\ +Using Daisy v7 parameterization of SMB-FAST.") + { } + void load_frame (Frame& frame) const + { + frame.set_strings ("smb", "SMB-SLOW", "SMB-FAST"); + } + } organic_2025_syntax; +} // organic_std.C ends here. diff --git a/src/daisy/organic_matter/smb.C b/src/daisy/organic_matter/smb.C index e14185267..fb10e487b 100644 --- a/src/daisy/organic_matter/smb.C +++ b/src/daisy/organic_matter/smb.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/organic_matter/smb.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/organic_matter/dom.h" #include "object_model/librarian.h" #include "object_model/frame.h" @@ -139,28 +140,31 @@ SMB::SMB (const BlockModel& al) maintenance (al.number ("maintenance")) { } -static struct SMBInit : public DeclareSolo +void +register_smb_models () { - Model* make (const BlockModel& al) const - { return new SMB (al); } - void load_frame (Frame& frame) const + static struct SMBInit : public DeclareSolo { - OM::load_syntax (frame, "\ + Model* make (const BlockModel& al) const + { return new SMB (al); } + void load_frame (Frame& frame) const + { + OM::load_syntax (frame, "\ The first numbers corresponds to each of the SMB pools, the next\n\ numbers corresponds to the SOM pools, and the last numbers to each of\n\ the DOM pools. The length of the sequence should thus be the number\n\ of SMB pools plus the number of SOM pools plus the number of DOM pools."); - frame.declare ("maintenance", "h^-1", Check::fraction (), Attribute::Const, "\ + frame.declare ("maintenance", "h^-1", Check::fraction (), Attribute::Const, "\ The fraction used for staying alive each hour."); - } - SMBInit () - : DeclareSolo (SMB::component, "\ + } + SMBInit () + : DeclareSolo (SMB::component, "\ A single Soil MicroBiological pool.") - { } -} SMB_init; + { } + } smb_init; -static struct SMBSlowSyntax : public DeclareParam -{ + static struct SMBSlowSyntax : public DeclareParam + { SMBSlowSyntax () : DeclareParam (SMB::component, "SMB-SLOW", root_name (), "\ Slow SMB pool parameterization.") @@ -184,10 +188,10 @@ Slow SMB pool parameterization.") SMB1_fractions.push_back (0.0); frame.set ("fractions", SMB1_fractions); } -} SMBSlow_syntax; + } smb_slow_syntax; -static struct SMBFastSyntax : public DeclareParam -{ + static struct SMBFastSyntax : public DeclareParam + { SMBFastSyntax () : DeclareParam (SMB::component, "SMB-FAST", root_name (), "\ Fast SMB pool parameterization.") @@ -211,10 +215,10 @@ Fast SMB pool parameterization.") SMB2_fractions.push_back (0.0); frame.set ("fractions", SMB2_fractions); } -} SMBFast_syntax; + } smb_fast_syntax; -static struct SMBFast2000Syntax : public DeclareParam -{ + static struct SMBFast2000Syntax : public DeclareParam + { SMBFast2000Syntax () : DeclareParam (SMB::component, "SMB-FAST-2000", "SMB-FAST", "\ Fast SMB pool parameterization.") @@ -229,7 +233,8 @@ Fast SMB pool parameterization.") SMB2_fractions.push_back (0.0); frame.set ("fractions", SMB2_fractions); } -} SMBFast2000_syntax; + } smb_fast_2000_syntax; +} // smb.C ends here. diff --git a/src/daisy/organic_matter/som.C b/src/daisy/organic_matter/som.C index 400a03c83..570955326 100644 --- a/src/daisy/organic_matter/som.C +++ b/src/daisy/organic_matter/som.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/organic_matter/som.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/librarian.h" #include "object_model/block_model.h" #include "object_model/frame.h" @@ -39,26 +40,29 @@ SOM::SOM (const BlockModel& al) : OM (al) { } -static struct SOMInit : public DeclareSolo +void +register_som_models () { - Model* make (const BlockModel& al) const - { return new SOM (al); } - void load_frame (Frame& frame) const + static struct SOMInit : public DeclareSolo { - OM::load_syntax (frame, "\ + Model* make (const BlockModel& al) const + { return new SOM (al); } + void load_frame (Frame& frame) const + { + OM::load_syntax (frame, "\ The first numbers corresponds to each of the SMB pools, the next\n\ numbers corresponds to the SOM pools, and the last numbers to each of\n\ the DOM pools. The length of the sequence should thus be the number\n\ of SMB pools plus the number of SOM pools plus the number of DOM pools."); - } - SOMInit () - : DeclareSolo (SOM::component, "\ + } + SOMInit () + : DeclareSolo (SOM::component, "\ A single Soil Organic Matter pool.") - { } -} SOM_init; + { } + } som_init; -static struct SOMSlowSyntax : public DeclareParam -{ + static struct SOMSlowSyntax : public DeclareParam + { SOMSlowSyntax () : DeclareParam (SOM::component, "SOM-SLOW", root_name (), "\ Slow SOM pool parameterization by Sander Bruun.") @@ -79,10 +83,10 @@ Slow SOM pool parameterization by Sander Bruun.") fractions.push_back (0.0); // SOM3 frame.set ("fractions", fractions); } -} SOMSlow_syntax; + } som_slow_syntax; -static struct SOMSlowOldSyntax : public DeclareParam -{ + static struct SOMSlowOldSyntax : public DeclareParam + { SOMSlowOldSyntax () : DeclareParam (SOM::component, "SOM-SLOW-OLD", "SOM-SLOW", "\ Original parameterization of the slow SOM pool.") @@ -92,10 +96,10 @@ Original parameterization of the slow SOM pool.") frame.set_strings ("cite", "mueller-smb"); Rate::set_rate (frame, "turnover", 2.7e-6 / 24.0 /* 1.125e-7 */); } -} SOMSlowOld_syntax; + } som_slow_old_syntax; -static struct SOMFastSyntax : public DeclareParam -{ + static struct SOMFastSyntax : public DeclareParam + { SOMFastSyntax () : DeclareParam (SOM::component, "SOM-FAST", root_name (), "\ Fast SOM pool parameterization by Sander Bruun.") @@ -116,10 +120,10 @@ Fast SOM pool parameterization by Sander Bruun.") fractions.push_back (0.0); // SOM3 frame.set ("fractions", fractions); } -} SOMFast_syntax; + } som_fast_syntax; -static struct SOMFastOldSyntax : public DeclareParam -{ + static struct SOMFastOldSyntax : public DeclareParam + { SOMFastOldSyntax () : DeclareParam (SOM::component, "SOM-FAST-OLD", "SOM-FAST", "\ Original parameterization of the fast SOM pool.") @@ -135,10 +139,10 @@ Original parameterization of the fast SOM pool.") fractions.push_back (0.0); // SOM3 frame.set ("fractions", fractions); } -} SOMFastOld_syntax; + } som_fast_old_syntax; -static struct SOMInertSyntax : public DeclareParam -{ + static struct SOMInertSyntax : public DeclareParam + { SOMInertSyntax () : DeclareParam (SOM::component, "SOM-INERT", root_name (), "\ Inert SOM pool parameterization.") @@ -158,6 +162,7 @@ Inert SOM pool parameterization.") fractions.push_back (1.0); // SOM3 frame.set ("fractions", fractions); } -} SOMInert_syntax; + } som_inert_syntax; +} // som.C ends here. diff --git a/src/daisy/output/fetch.C b/src/daisy/output/fetch.C index d2b4511f7..cec1786d9 100644 --- a/src/daisy/output/fetch.C +++ b/src/daisy/output/fetch.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/output/fetch.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/output/select.h" #include "object_model/treelog.h" #include "object_model/frame_submodel.h" @@ -157,7 +158,11 @@ Fetch::Fetch (const symbol key) sum (-42.42e42) { } -static DeclareSubmodel fetch_submodel (Fetch::load_syntax, "Fetch", "\ +void +register_fetch_models () +{ + static DeclareSubmodel fetch_submodel (Fetch::load_syntax, "Fetch", "\ A summary file line."); +} // fetch.C ends here. diff --git a/src/daisy/output/fetch_pretty.C b/src/daisy/output/fetch_pretty.C index 33b489169..46fbe1e7a 100644 --- a/src/daisy/output/fetch_pretty.C +++ b/src/daisy/output/fetch_pretty.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/output/fetch_pretty.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/librarian.h" #include "object_model/frame_submodel.h" #include "util/mathlib.h" @@ -147,8 +148,12 @@ Typically 1.0 to add this line, or -1.0 to subtract it."); frame.set ("factor", 1.0); } -static DeclareSubmodel -fetch_prettysubmodel (FetchPretty::load_syntax, "FetchPretty", "\ +void +register_fetch_pretty_models () +{ + static DeclareSubmodel + fetch_prettysubmodel (FetchPretty::load_syntax, "FetchPretty", "\ A summary file line."); +} // fetch_pretty.C ends here. diff --git a/src/daisy/output/harvest.C b/src/daisy/output/harvest.C index ea199c4d6..b258f226e 100644 --- a/src/daisy/output/harvest.C +++ b/src/daisy/output/harvest.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/output/harvest.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/frame.h" #include "daisy/output/log.h" #include "object_model/librarian.h" @@ -203,8 +204,12 @@ Harvest::Harvest (const symbol col, harvest_index (hi) { } -static DeclareSubmodel -harvest_submodel (Harvest::load_syntax, "Harvest", "\ +void +register_harvest_models () +{ + static DeclareSubmodel + harvest_submodel (Harvest::load_syntax, "Harvest", "\ Log of all harvests during the simulation."); +} // harvest.C ends here. diff --git a/src/daisy/output/log.C b/src/daisy/output/log.C index f927f6c91..722c13f0d 100644 --- a/src/daisy/output/log.C +++ b/src/daisy/output/log.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/output/log.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/library.h" #include "object_model/metalib.h" #include "object_model/block_model.h" @@ -154,13 +155,23 @@ Log::summarize (Treelog&) Log::~Log () { } -static struct LogInit : public DeclareComponent +void +register_log_models () { - LogInit () - : DeclareComponent (Log::component, "\ + static struct LogInit : public DeclareComponent + { + LogInit () + : DeclareComponent (Log::component, "\ Running a simulation is uninteresting, unless you can get access to\n\ the results in one way or another. The purpose of the 'log' component\n\ is to provide this access. Most 'log' models does this by writing a\n\ summary of the state to a log file.") - { } -} Log_init; + { } + } log_init; + + register_log_select_models (); + register_log_checkpoint_models (); + register_log_extern_models (); + register_log_harvest_models (); + register_log_table_models (); +} diff --git a/src/daisy/output/log_checkpoint.C b/src/daisy/output/log_checkpoint.C index bf4cb1c69..f760f1168 100644 --- a/src/daisy/output/log_checkpoint.C +++ b/src/daisy/output/log_checkpoint.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/output/log_alist.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/metalib.h" #include "object_model/block_model.h" #include "daisy/condition.h" @@ -233,27 +234,31 @@ LogCheckpoint::LogCheckpoint (const BlockModel& al) LogCheckpoint::~LogCheckpoint () { } -static struct LogCheckpointSyntax : public DeclareModel +void +register_log_checkpoint_models () { - Model* make (const BlockModel& al) const - { return new LogCheckpoint (al); } + static struct LogCheckpointSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new LogCheckpoint (al); } - LogCheckpointSyntax () - : DeclareModel (Log::component, "checkpoint", "\ + LogCheckpointSyntax () + : DeclareModel (Log::component, "checkpoint", "\ Create a checkpoint of the entire simulation state, suitable for later\n\ hot start.") - { } - void load_frame (Frame& frame) const - { - Model::load_model (frame); - frame.declare_string ("where", Attribute::Const, + { } + void load_frame (Frame& frame) const + { + Model::load_model (frame); + frame.declare_string ("where", Attribute::Const, "File name prefix for the generated checkpoint.\n\ The time will be appended, together with the '.dai' suffix."); - frame.set ("where", "checkpoint"); - frame.declare_object ("when", Condition::component, + frame.set ("where", "checkpoint"); + frame.declare_object ("when", Condition::component, "Make a checkpoint every time this condition is true."); - frame.set ("when", "finished"); - } -} LogCheckpoint_syntax; + frame.set ("when", "finished"); + } + } log_checkpoint_syntax; +} // log_checkpoint.C ends here. diff --git a/src/daisy/output/log_extern.C b/src/daisy/output/log_extern.C index a27e43b3c..b975c0b66 100644 --- a/src/daisy/output/log_extern.C +++ b/src/daisy/output/log_extern.C @@ -23,6 +23,7 @@ #define BUILD_DLL #include "daisy/output/log_extern.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/output/select.h" #include "object_model/block_model.h" #include "util/assertion.h" @@ -308,28 +309,32 @@ LogExtern::LogExtern (const BlockModel& al) LogExtern::~LogExtern () { } -static struct LogExternSyntax : public DeclareModel +void +register_log_extern_models () { - Model* make (const BlockModel& al) const - { return new LogExtern (al); } + static struct LogExternSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new LogExtern (al); } - LogExternSyntax () - : DeclareModel (Log::component, "extern", "select", "\ + LogExternSyntax () + : DeclareModel (Log::component, "extern", "select", "\ Log simulation state for extern use.") - { } - void load_frame (Frame& frame) const - { - frame.declare_submodule_sequence ("numbers", Attribute::OptionalState, "\ + { } + void load_frame (Frame& frame) const + { + frame.declare_submodule_sequence ("numbers", Attribute::OptionalState, "\ Inititial numeric values. By default, none.", LogExtern::NumEntry::load_syntax); - frame.declare_string ("where", Attribute::OptionalConst, + frame.declare_string ("where", Attribute::OptionalConst, "Name of the extern log to use.\n\ By default, use the model name."); - // Disable initial line as it might put "missing" values in - // initialized flux variables. TODO: Make 'numbers' be default - // values, rather than initial values. - frame.set ("print_initial", false); - } -} LogExtern_syntax; + // Disable initial line as it might put "missing" values in + // initialized flux variables. TODO: Make 'numbers' be default + // values, rather than initial values. + frame.set ("print_initial", false); + } + } log_extern_syntax; +} // log_extern.C ends here. diff --git a/src/daisy/output/log_harvest.C b/src/daisy/output/log_harvest.C index ba0988898..b53f4cf13 100644 --- a/src/daisy/output/log_harvest.C +++ b/src/daisy/output/log_harvest.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/output/log.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/daisy.h" #include "daisy/output/harvest.h" #include "daisy/output/dlf.h" @@ -221,62 +222,65 @@ struct LogHarvest : public Log } }; -static struct LogHarvestSyntax : public DeclareModel +void +register_log_harvest_models () { - static void entry (Format& format, const symbol name, const symbol dim, - const symbol description) + static struct LogHarvestSyntax : public DeclareModel { - Format::Item item (format, name); - format.special ("nbsp"); - format.text ("["); - format.bold (dim); - format.text ("]"); - format.hard_linebreak (); - format.text (description); - format.soft_linebreak (); - } - static void document_entries (Format& format, const Metalib&, - Treelog& msg, const symbol name) - { - if (name != "harvest") - return; - - format.bold ("Table columns (common):"); + static void entry (Format& format, const symbol name, const symbol dim, + const symbol description) { - Format::List dummy (format); - entry (format, "stem_DM", "Mg DM/ha", "\ + Format::Item item (format, name); + format.special ("nbsp"); + format.text ("["); + format.bold (dim); + format.text ("]"); + format.hard_linebreak (); + format.text (description); + format.soft_linebreak (); + } + static void document_entries (Format& format, const Metalib&, + Treelog& msg, const symbol name) + { + if (name != "harvest") + return; + + format.bold ("Table columns (common):"); + { + Format::List dummy (format); + entry (format, "stem_DM", "Mg DM/ha", "\ Stem dry matter removed by harvest."); - entry (format, "dead_DM", "Mg DM/ha", "\ + entry (format, "dead_DM", "Mg DM/ha", "\ Yeallow leaves dry matter removed by harvest."); - entry (format, "leaf_DM", "Mg DM/ha", "\ + entry (format, "leaf_DM", "Mg DM/ha", "\ Green leaves dry matter removed by harvest."); - entry (format, "sorg_DM", "Mg DM/ha", "\ + entry (format, "sorg_DM", "Mg DM/ha", "\ Storage organ (grains or tuber) dry matter removed by harvest.\n\ For some crops, only the economicly important part of the storage organ\n\ is counted."); - } - format.soft_linebreak (); + } + format.soft_linebreak (); - format.bold ("Table columns (if print_N is set):"); - { - Format::List dummy (format); - entry (format, "stem_N", "kg N/ha", "\ + format.bold ("Table columns (if print_N is set):"); + { + Format::List dummy (format); + entry (format, "stem_N", "kg N/ha", "\ Stem nitrogen removed by harvest."); - entry (format, "dead_N", "kg N/ha", "\ + entry (format, "dead_N", "kg N/ha", "\ Yeallow leaves nitrogen removed by harvest."); - entry (format, "leaf_N", "kg N/ha", "\ + entry (format, "leaf_N", "kg N/ha", "\ Green leaves nitrogen removed by harvest."); - entry (format, "sorg_N", "kg N/ha", "\ + entry (format, "sorg_N", "kg N/ha", "\ Storage organ (grains or tuber) nitrogen removed by harvest."); - } - format.soft_linebreak (); - - format.bold ("Table columns (if print_C is set):"); - { - Format::List dummy (format); - entry (format, "stem_C", "kg C/ha", "\ + } + format.soft_linebreak (); + + format.bold ("Table columns (if print_C is set):"); + { + Format::List dummy (format); + entry (format, "stem_C", "kg C/ha", "\ Stem carbon removed by harvest."); - entry (format, "dead_C", "kg C/ha", "\ + entry (format, "dead_C", "kg C/ha", "\ Yeallow leaves carbon removed by harvest."); entry (format, "leaf_C", "kg C/ha", "\ Green leaves carbon removed by harvest."); @@ -342,6 +346,6 @@ harvest."); frame.set ("print_C", false); frame.set ("print_dimension", true); Librarian::add_doc_fun (Log::component, document_entries); - } -} LogHarvest_syntax; - + } + } log_harvest_syntax; +} diff --git a/src/daisy/output/log_select.C b/src/daisy/output/log_select.C index 00dffbf42..6fcf8e4c9 100644 --- a/src/daisy/output/log_select.C +++ b/src/daisy/output/log_select.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/output/log_select.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/output/select.h" #include "daisy/condition.h" #include "object_model/metalib.h" @@ -464,56 +465,60 @@ LogSelect::document_entries (Format& format, const Metalib& metalib, entries[i]->document (format); } -static struct LogSelectSyntax : public DeclareBase +void +register_log_select_models () { - LogSelectSyntax () - : DeclareBase (Log::component, "select", "Select variables to log.") - { } - void load_frame (Frame& frame) const + static struct LogSelectSyntax : public DeclareBase { - Model::load_model (frame); - frame.declare_string ("parameter_names", + LogSelectSyntax () + : DeclareBase (Log::component, "select", "Select variables to log.") + { } + void load_frame (Frame& frame) const + { + Model::load_model (frame); + frame.declare_string ("parameter_names", Attribute::Const, Attribute::Variable, "\ List of string parameters to print to the table header.\n\ \n\ For example, if you have defined 'column' and 'crop' parameters for\n\ this table log parameterization, you can print them to the log file\n\ header by specifying '(parameter_names column crop)'."); - frame.set_empty ("parameter_names"); - frame.declare_object ("when", Condition::component, "\ + frame.set_empty ("parameter_names"); + frame.declare_object ("when", Condition::component, "\ Add entries to the log file when this condition is true."); - frame.declare_object ("active", Condition::component, "\ + frame.declare_object ("active", Condition::component, "\ Add data when this condition is true.\n\ E.g. count percolation only when there is no crop."); - frame.set ("active", "true"); - frame.declare_object ("entries", Select::component, + frame.set ("active", "true"); + frame.declare_object ("entries", Select::component, Attribute::State, Attribute::Variable, "What to log in each column."); - frame.declare_boolean ("time_columns", Attribute::OptionalConst, "\ + frame.declare_boolean ("time_columns", Attribute::OptionalConst, "\ Iff true, add columns for year, month, mday and hour in the begining of\n\ the lines. By default, this will be true of you have not specified any\n\ time entries yourself."); - frame.declare_object ("volume", Volume::component, + frame.declare_object ("volume", Volume::component, Attribute::Const, Attribute::Singleton, "Soil volume to log."); - frame.set ("volume", "box"); - frame.declare ("from", "cm", Attribute::OptionalConst, + frame.set ("volume", "box"); + frame.declare ("from", "cm", Attribute::OptionalConst, "Default 'from' value for all entries.\n\ By default, use the top of the soil.\n\ OBSOLETE: Use (volume box (top FROM)) instead."); - frame.declare ("to", "cm", Attribute::OptionalConst, + frame.declare ("to", "cm", Attribute::OptionalConst, "Default 'to' value for all entries.\n\ By default, use the bottom of the soil.\n\ OBSOLETE: Use (volume box (bottom TO)) instead."); - frame.declare_boolean ("print_initial", Attribute::OptionalConst, "\ + frame.declare_boolean ("print_initial", Attribute::OptionalConst, "\ Print a line with initial values when logging starts.\n\ By default, an initial line will be printed if any entry has 'handle'\n\ set to 'current'."); - frame.declare_object ("summary", Summary::component, + frame.declare_object ("summary", Summary::component, Attribute::Const, Attribute::Variable, "Summaries for this log file."); - frame.set_empty ("summary"); - } -} LogSelect_syntax; + frame.set_empty ("summary"); + } + } log_select_syntax; +} // log_select.C ends here. diff --git a/src/daisy/output/log_table.C b/src/daisy/output/log_table.C index 0c61eb0a9..e15366968 100644 --- a/src/daisy/output/log_table.C +++ b/src/daisy/output/log_table.C @@ -23,6 +23,7 @@ #define BUILD_DLL #include "daisy/output/log_select.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/output/dlf.h" #include "object_model/symbol.h" #include "daisy/output/select.h" @@ -538,45 +539,49 @@ LogTable::LogTable (const BlockModel& al) LogTable::~LogTable () { } -static struct LogTableSyntax : public DeclareModel +void +register_log_table_models () { - Model* make (const BlockModel& al) const - { return new LogTable (al); } + static struct LogTableSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new LogTable (al); } - LogTableSyntax () - : DeclareModel (Log::component, "table", "select", "\ + LogTableSyntax () + : DeclareModel (Log::component, "table", "select", "\ Write results in a tabular Daisy log file.") - { } - void load_frame (Frame& frame) const - { - frame.declare_string ("where", Attribute::Const, + { } + void load_frame (Frame& frame) const + { + frame.declare_string ("where", Attribute::Const, "Name of the log file to create."); - DLF::add_syntax (frame, "print_header"); - frame.declare_boolean ("print_tags", Attribute::Const, + DLF::add_syntax (frame, "print_header"); + frame.declare_boolean ("print_tags", Attribute::Const, "Print a tag line in the file."); - frame.set ("print_tags", true); - frame.declare_boolean ("print_dimension", Attribute::Const, + frame.set ("print_tags", true); + frame.declare_boolean ("print_dimension", Attribute::Const, "Print a line with units after the tag line."); - frame.set ("print_dimension", true); - frame.declare_boolean ("flush", Attribute::Const, + frame.set ("print_dimension", true); + frame.declare_boolean ("flush", Attribute::Const, "Flush to disk after each entry (for debugging)."); - frame.set ("flush", false); - frame.declare_string ("record_separator", Attribute::Const, "\ + frame.set ("flush", false); + frame.declare_string ("record_separator", Attribute::Const, "\ String to print between records (time steps)."); - frame.set ("record_separator", "\n"); - frame.declare_string ("field_separator", Attribute::Const, "\ + frame.set ("record_separator", "\n"); + frame.declare_string ("field_separator", Attribute::Const, "\ String to print between fields."); - frame.set ("field_separator", "\t"); - frame.declare_string ("missing_value", Attribute::Const, "\ + frame.set ("field_separator", "\t"); + frame.declare_string ("missing_value", Attribute::Const, "\ String to print when the path doesn't match anything.\n\ This can be relevant for example if you are logging a crop, and there are\n\ no crops on the field."); - frame.set ("missing_value", "00.00"); - frame.declare_string ("array_separator", Attribute::Const, "\ + frame.set ("missing_value", "00.00"); + frame.declare_string ("array_separator", Attribute::Const, "\ String to print between array entries."); - frame.set ("array_separator", "\t"); - Librarian::add_doc_fun (Log::component, LogSelect::document_entries); - } -} LogTable_syntax; + frame.set ("array_separator", "\t"); + Librarian::add_doc_fun (Log::component, LogSelect::document_entries); + } + } log_table_syntax; +} // log_table.C ends here. diff --git a/src/daisy/output/output.C b/src/daisy/output/output.C index ef92e0a83..02b717346 100644 --- a/src/daisy/output/output.C +++ b/src/daisy/output/output.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/output/output.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/daisy.h" #include "daisy/output/log_all.h" #include "object_model/treelog.h" @@ -234,4 +235,15 @@ Suffix for log file names. Set it to '.csv' to make Excel happy."); frame.set ("log_suffix", ""); } +void +register_output_models () +{ + register_fetch_models (); + register_fetch_pretty_models (); + register_harvest_models (); + register_select_models (); + register_summary_models (); + register_log_models (); +} + // output.C ends here. diff --git a/src/daisy/output/select.C b/src/daisy/output/select.C index 1a2cccced..73222d6ca 100644 --- a/src/daisy/output/select.C +++ b/src/daisy/output/select.C @@ -22,6 +22,7 @@ #define BUILD_DLL #include "daisy/output/select.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/condition.h" #include "object_model/block_model.h" #include "daisy/column.h" @@ -723,62 +724,65 @@ Select::Select (const BlockModel& al) Select::~Select () { } -static struct SelectInit : public DeclareComponent +void +register_select_models () { - SelectInit () - : DeclareComponent (Select::component, Select::description) - { } - static bool check_alist (const Metalib&, const Frame& al, Treelog& err) + static struct SelectInit : public DeclareComponent { - bool ok = true; - if (al.check ("spec")) - { - if (!approximate (al.number ("factor"), 1.0, 1e-7)) - err.warning ("Specifying both 'spec' and 'factor' may conflict"); - else if (std::isnormal (al.number ("offset"))) - err.warning ("Specifying both 'spec' and 'offset' may conflict"); - } - if (al.check ("expr")) - { - if (!approximate (al.number ("factor"), 1.0, 1e-7)) - { - err.error ("Can't specify both 'expr' and 'factor'"); - ok = false; - } - else if (std::isnormal (al.number ("offset"))) - { - err.error ("Can't specify both 'expr' and 'offset'"); - ok = false; - } - } + SelectInit () + : DeclareComponent (Select::component, Select::description) + { } + static bool check_alist (const Metalib&, const Frame& al, Treelog& err) + { + bool ok = true; + if (al.check ("spec")) + { + if (!approximate (al.number ("factor"), 1.0, 1e-7)) + err.warning ("Specifying both 'spec' and 'factor' may conflict"); + else if (std::isnormal (al.number ("offset"))) + err.warning ("Specifying both 'spec' and 'offset' may conflict"); + } + if (al.check ("expr")) + { + if (!approximate (al.number ("factor"), 1.0, 1e-7)) + { + err.error ("Can't specify both 'expr' and 'factor'"); + ok = false; + } + else if (std::isnormal (al.number ("offset"))) + { + err.error ("Can't specify both 'expr' and 'offset'"); + ok = false; + } + } - static bool has_warned_about_when = false; - if (!has_warned_about_when && al.check ("when")) - { - err.warning ("The 'when' select parametere is obsolete.\n\ + static bool has_warned_about_when = false; + if (!has_warned_about_when && al.check ("when")) + { + err.warning ("The 'when' select parametere is obsolete.\n\ Set the 'handle' parameter instead."); - has_warned_about_when = true; - } - return ok; - } + has_warned_about_when = true; + } + return ok; + } - void load_frame (Frame& frame) const - { - Model::load_model (frame); - frame.add_check (check_alist); - frame.declare_string ("documentation", Attribute::OptionalConst, "\ + void load_frame (Frame& frame) const + { + Model::load_model (frame); + frame.add_check (check_alist); + frame.declare_string ("documentation", Attribute::OptionalConst, "\ Documentation for this entry."); - frame.declare_string ("tag", Attribute::OptionalConst, + frame.declare_string ("tag", Attribute::OptionalConst, "Tag to identify the column.\n\ These will be printed in the first line of the log file.\n\ The default tag is the last element in the path."); - frame.declare_string ("dimension", Attribute::OptionalConst, + frame.declare_string ("dimension", Attribute::OptionalConst, "The unit for numbers in this column.\n\ These will be printed in the second line of the log file.\n\ The character '&' will be replaced with the log timestep.\n\ If you do not specify the dimension explicitly, a value will\n\ be interfered from 'spec' if available."); - frame.declare_string ("path", Attribute::Const, Attribute::Variable, "\ + frame.declare_string ("path", Attribute::Const, Attribute::Variable, "\ Sequence of attribute names leading to the variable you want to log in\n\ this column. The first name should be one of the attributes of the\n\ daisy component itself. What to specify as the next name depends on\n\ @@ -811,15 +815,15 @@ simulation, if the model is used at several places. Also, there is no\n\ wildcards, so only a single model can be matches. The spec is used for\n\ helping Daisy establish a unique dimension and description for the\n\ attribute.", Select::Implementation::Spec::load_syntax); - frame.declare_object ("when", Condition::component, + frame.declare_object ("when", Condition::component, Attribute::OptionalConst, Attribute::Singleton, "\ OBSOLETE. If you set this variable, 'flux' will be set to true.\n\ This overwrites any direct setting of 'flux'."); - frame.declare_boolean ("flux", Attribute::OptionalConst, "\ + frame.declare_boolean ("flux", Attribute::OptionalConst, "\ OBSOLETE. This value will be used if 'handle' is not specified.\ A value of true then means 'sum', and false means 'current'."); - frame.declare_string ("handle", Attribute::OptionalConst, "\ + frame.declare_string ("handle", Attribute::OptionalConst, "\ This option determine how the specified variable should be logged. \n\ \n\ min: Log the smallest value seen since last time the variable was logged.\n\ @@ -840,10 +844,10 @@ If 'accumulate' is true, accumulate since the start of the log.\n\ \n\ current: Log the current value for the variable.\n\ If 'accumulate' is true, the printed values will be accumulated."); - static VCheck::Enum handle_check ("min", "max", "average", + static VCheck::Enum handle_check ("min", "max", "average", "sum", "content_sum", "current"); - frame.set_check ("handle", handle_check); - frame.declare_string ("multi", Attribute::OptionalConst, "\ + frame.set_check ("handle", handle_check); + frame.declare_string ("multi", Attribute::OptionalConst, "\ This option determine how to handle mutiple matches within a timestep.\n\ This could be two crops on the same column, or one crop on two columns.\n \ \n\ @@ -853,32 +857,42 @@ max: Use largest value\n\ \n\ sum: Use the sum of all matches, weighted by relative column area if\n\ the matches are from different columns."); - frame.set_check ("multi", Select::multi_check ()); - frame.set ("multi", "sum"); - frame.declare_boolean ("interesting_content", Attribute::OptionalConst, "\ + frame.set_check ("multi", Select::multi_check ()); + frame.set ("multi", "sum"); + frame.declare_boolean ("interesting_content", Attribute::OptionalConst, "\ True if the content of this column is interesting enough to warrent an\n\ initial line in the log file.\n\ By default, this is true iff 'handle' is 'current'."); - frame.declare_object ("expr", Number::component, + frame.declare_object ("expr", Number::component, Attribute::OptionalConst, Attribute::Singleton, "\ Expression for findig the value for the log file, given the internal\n\ value 'x'. For example '(expr (ln x))' will give you the natural\n\ logarithm of the value."); - frame.declare ("factor", Attribute::Unknown (), Check::none (), Attribute::Const, "\ + frame.declare ("factor", Attribute::Unknown (), Check::none (), Attribute::Const, "\ Factor to multiply the calculated value with, before logging.\n\ OBSOLETE: Use 'expr' instead."); - frame.set ("factor", 1.0); - frame.declare ("offset", Attribute::Unknown (), Check::none (), Attribute::Const, "\ + frame.set ("factor", 1.0); + frame.declare ("offset", Attribute::Unknown (), Check::none (), Attribute::Const, "\ Offset to add to the calculated value, before logging.\n\ OBSOLETE: Use 'expr' instead."); - frame.set ("offset", 0.0); - frame.declare_boolean ("negate", Attribute::Const, "\ + frame.set ("offset", 0.0); + frame.declare_boolean ("negate", Attribute::Const, "\ Switch sign of value. I.e. upward fluxes become downward fluxes."); - frame.set ("negate", false); - frame.declare_boolean ("accumulate", Attribute::Const, + frame.set ("negate", false); + frame.declare_boolean ("accumulate", Attribute::Const, "Log accumulated values."); - frame.set ("accumulate", false); - } -} Select_init; + frame.set ("accumulate", false); + } + } select_init; + + register_select_value_models (); + register_select_content_models (); + register_select_number_models (); + register_select_index_models (); + register_select_array_models (); + register_select_quiver_models (); + register_select_flow_models (); + register_select_volume_models (); +} // select.C ends here. diff --git a/src/daisy/output/select_array.C b/src/daisy/output/select_array.C index 12a1e258c..393d6cfa2 100644 --- a/src/daisy/output/select_array.C +++ b/src/daisy/output/select_array.C @@ -23,6 +23,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/output/select.h" #include "daisy/soil/soil.h" #include "daisy/output/bdconv.h" @@ -359,15 +360,20 @@ The 'array' select model only handle bulk density for soil sized variables"; { } }; -static struct SelectArraySyntax : public DeclareModel +void +register_select_array_models () { - Model* make (const BlockModel& al) const - { return new SelectArray (al); } - SelectArraySyntax () - : DeclareModel (Select::component, "array", "Log all members of an array.") - { } - void load_frame (Frame& frame) const - { } -} SelectArray_syntax; + static struct SelectArraySyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new SelectArray (al); } + SelectArraySyntax () + : DeclareModel (Select::component, "array", + "Log all members of an array.") + { } + void load_frame (Frame& frame) const + { } + } select_array_syntax; +} // select_array.C ends here. diff --git a/src/daisy/output/select_content.C b/src/daisy/output/select_content.C index 06d6a545d..9a712aa3f 100644 --- a/src/daisy/output/select_content.C +++ b/src/daisy/output/select_content.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/output/select_value.h" #include "object_model/block_model.h" #include "daisy/soil/transport/geometry.h" @@ -135,43 +136,47 @@ struct SelectContent : public SelectValue { } }; -static struct SelectContentSyntax : public DeclareModel +void +register_select_content_models () { - Model* make (const BlockModel& al) const - { return new SelectContent (al); } - static bool check_alist (const Metalib&, const Frame& al, Treelog& msg) + static struct SelectContentSyntax : public DeclareModel { - if (al.check ("z") && al.check ("height")) - msg.warning ("Paramater 'z' overwrites 'height'"); - - return true; - } - SelectContentSyntax () - : DeclareModel (Select::component, "content", "value", "\ + Model* make (const BlockModel& al) const + { return new SelectContent (al); } + static bool check_alist (const Metalib&, const Frame& al, Treelog& msg) + { + if (al.check ("z") && al.check ("height")) + msg.warning ("Paramater 'z' overwrites 'height'"); + + return true; + } + SelectContentSyntax () + : DeclareModel (Select::component, "content", "value", "\ Extract content at specified location.\n\ The \"location\" may be a line, plane or volume if one or more dimension\n\ parameters are left out. In that case, the weighted average is used.") - { } - void load_frame (Frame& frame) const - { - frame.add_check (check_alist); - - frame.declare ("height", "cm", Check::non_positive (), Attribute::OptionalConst, - "OBSOLETE: Use 'z' instead."); - frame.declare ("z", "cm", Attribute::OptionalConst, - "Specify height (negative below surface) to measure content.\n\ + { } + void load_frame (Frame& frame) const + { + frame.add_check (check_alist); + + frame.declare ("height", "cm", Check::non_positive (), + Attribute::OptionalConst, + "OBSOLETE: Use 'z' instead."); + frame.declare ("z", "cm", Attribute::OptionalConst, + "Specify height (negative below surface) to measure content.\n\ The value will be a weighted average of all cells containing height.\n\ By default, cell in all heights will be included."); - frame.declare ("x", "cm", Attribute::OptionalConst, - "Specify width (distance from left side) to measure content.\n\ + frame.declare ("x", "cm", Attribute::OptionalConst, + "Specify width (distance from left side) to measure content.\n\ The value will be a weighted average of all cells containing width.\n\ By default, cell in all widths will be included."); - frame.declare ("y", "cm", Attribute::OptionalConst, - "Specify length (distance from front) to measure content.\n\ + frame.declare ("y", "cm", Attribute::OptionalConst, + "Specify length (distance from front) to measure content.\n\ The value will be a weighted average of all cells containing length.\n\ By default, cell in all lengths will be included."); - } -} SelectContent_syntax; + } + } select_content_syntax; +} // select_content.C ends here. - diff --git a/src/daisy/output/select_flow.C b/src/daisy/output/select_flow.C index 1fdabbbd6..5c4e09862 100644 --- a/src/daisy/output/select_flow.C +++ b/src/daisy/output/select_flow.C @@ -19,6 +19,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/output/select_value.h" #include "object_model/block_model.h" #include "daisy/soil/transport/volume.h" @@ -212,24 +213,6 @@ SelectFlow::SelectFlow (const BlockModel& al) active (colcache.end ()) { } -static struct SelectFlowSyntax : public DeclareBase -{ - SelectFlowSyntax () - : DeclareBase (Select::component, "flow", "value", "\ -Common base for logging flow through a specific plane.") - { } - void load_frame (Frame& frame) const - { - frame.declare_boolean ("density", Attribute::Const, - "If true, divide value with volume height."); - frame.set ("density", false); - frame.declare_object ("volume", Volume::component, - Attribute::Const, Attribute::Singleton, - "Soil volume to log flow into."); - frame.set ("volume", "box"); - } -} SelectFlow_syntax; - struct SelectFlowTop : public SelectFlow { bool use_edge (const Geometry& geo, int outside, int inside) const @@ -248,35 +231,6 @@ struct SelectFlowTop : public SelectFlow { } }; -static struct SelectFlowTopSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new SelectFlowTop (al); } - - SelectFlowTopSyntax () - : DeclareModel (Select::component, "flow_top", "flow", "\ -Extract flow from top of specified volume.") - { } - void load_frame (Frame& frame) const - { - frame.declare ("from", "cm", Attribute::OptionalConst, - "Specify height (negative) to measure from.\n\ -By default, measure from the top.\n\ -OBSOLETE: Use (volume box (top FROM)) instead."); - } -} Select_flow_top_syntax; - -static struct SelectFluxTopSyntax : public DeclareParam -{ - SelectFluxTopSyntax () - : DeclareParam (Select::component, "flux_top", "flow_top", "\ -Flux leaving top of specified volume.\n\ -OBSOLETE: Use '(flow_top (negate true) (density true))' instead.") - { } - void load_frame (Frame& frame) const - { frame.set ("density", true); } -} Select_flux_top_syntax; - struct SelectFlowBottom : public SelectFlow { bool use_edge (const Geometry& geo, int outside, int inside) const @@ -295,38 +249,6 @@ struct SelectFlowBottom : public SelectFlow { } }; -static struct SelectFlowBottomSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new SelectFlowBottom (al); } - - SelectFlowBottomSyntax () - : DeclareModel (Select::component, "flow_bottom", "flow", "\ -Extract flow from bottom of specified volume.") - { } - void load_frame (Frame& frame) const - { - frame.declare ("to", "cm", Attribute::OptionalConst, - "Specify height (negative) to measure interval.\n\ -By default, measure to the bottom.\n\ -OBSOLETE: Use (volume box (bottom TO)) instead."); - - } -} Select_flow_bottom_syntax; - -static struct SelectFluxBottomSyntax : public DeclareParam -{ - SelectFluxBottomSyntax () - : DeclareParam (Select::component, "flux_bottom", "flow_bottom", "\ -Flux entering bottom of specified volume.\n\ -OBSOLETE: Use '(flow_bottom (density true))' instead.") - { } - void load_frame (Frame& frame) const - { - frame.set ("density", true); - } -} Select_flux_bottom_syntax; - struct SelectFlowLeft : public SelectFlow { bool use_edge (const Geometry& geo, int outside, int inside) const @@ -345,19 +267,6 @@ struct SelectFlowLeft : public SelectFlow { } }; -static struct SelectFlowLeftSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new SelectFlowLeft (al); } - - SelectFlowLeftSyntax () - : DeclareModel (Select::component, "flow_left", "flow", "\ -Extract flow from left of specified volume.") - { } - void load_frame (Frame&) const - { } -} Select_flow_left_syntax; - struct SelectFlowRight : public SelectFlow { bool use_edge (const Geometry& geo, int outside, int inside) const @@ -376,19 +285,6 @@ struct SelectFlowRight : public SelectFlow { } }; -static struct SelectFlowRightSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new SelectFlowRight (al); } - - SelectFlowRightSyntax () - : DeclareModel (Select::component, "flow_right", "flow", "\ -Extract flow from right of specified volume.") - { } - void load_frame (Frame& frame) const - { } -} Select_flow_right_syntax; - struct SelectFlowFront : public SelectFlow { bool use_edge (const Geometry& geo, int outside, int inside) const @@ -407,19 +303,6 @@ struct SelectFlowFront : public SelectFlow { } }; -static struct SelectFlowFrontSyntax : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new SelectFlowFront (al); } - - SelectFlowFrontSyntax () - : DeclareModel (Select::component, "flow_front", "flow", "\ -Extract flow from front of specified volume.") - { } - void load_frame (Frame&) const - { } -} Select_flow_front_syntax; - struct SelectFlowBack : public SelectFlow { bool use_edge (const Geometry& geo, int outside, int inside) const @@ -438,17 +321,138 @@ struct SelectFlowBack : public SelectFlow { } }; -static struct SelectFlowBackSyntax : public DeclareModel +void +register_select_flow_models () { - Model* make (const BlockModel& al) const - { return new SelectFlowBack (al); } + static struct SelectFlowSyntax : public DeclareBase + { + SelectFlowSyntax () + : DeclareBase (Select::component, "flow", "value", "\ +Common base for logging flow through a specific plane.") + { } + void load_frame (Frame& frame) const + { + frame.declare_boolean ("density", Attribute::Const, + "If true, divide value with volume height."); + frame.set ("density", false); + frame.declare_object ("volume", Volume::component, + Attribute::Const, Attribute::Singleton, + "Soil volume to log flow into."); + frame.set ("volume", "box"); + } + } select_flow_syntax; + + static struct SelectFlowTopSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new SelectFlowTop (al); } + + SelectFlowTopSyntax () + : DeclareModel (Select::component, "flow_top", "flow", "\ +Extract flow from top of specified volume.") + { } + void load_frame (Frame& frame) const + { + frame.declare ("from", "cm", Attribute::OptionalConst, + "Specify height (negative) to measure from.\n\ +By default, measure from the top.\n\ +OBSOLETE: Use (volume box (top FROM)) instead."); + } + } select_flow_top_syntax; + + static struct SelectFluxTopSyntax : public DeclareParam + { + SelectFluxTopSyntax () + : DeclareParam (Select::component, "flux_top", "flow_top", "\ +Flux leaving top of specified volume.\n\ +OBSOLETE: Use '(flow_top (negate true) (density true))' instead.") + { } + void load_frame (Frame& frame) const + { frame.set ("density", true); } + } select_flux_top_syntax; - SelectFlowBackSyntax () - : DeclareModel (Select::component, "flow_back", "flow", "\ + static struct SelectFlowBottomSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new SelectFlowBottom (al); } + + SelectFlowBottomSyntax () + : DeclareModel (Select::component, "flow_bottom", "flow", "\ +Extract flow from bottom of specified volume.") + { } + void load_frame (Frame& frame) const + { + frame.declare ("to", "cm", Attribute::OptionalConst, + "Specify height (negative) to measure interval.\n\ +By default, measure to the bottom.\n\ +OBSOLETE: Use (volume box (bottom TO)) instead."); + } + } select_flow_bottom_syntax; + + static struct SelectFluxBottomSyntax : public DeclareParam + { + SelectFluxBottomSyntax () + : DeclareParam (Select::component, "flux_bottom", "flow_bottom", "\ +Flux entering bottom of specified volume.\n\ +OBSOLETE: Use '(flow_bottom (density true))' instead.") + { } + void load_frame (Frame& frame) const + { + frame.set ("density", true); + } + } select_flux_bottom_syntax; + + static struct SelectFlowLeftSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new SelectFlowLeft (al); } + + SelectFlowLeftSyntax () + : DeclareModel (Select::component, "flow_left", "flow", "\ +Extract flow from left of specified volume.") + { } + void load_frame (Frame&) const + { } + } select_flow_left_syntax; + + static struct SelectFlowRightSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new SelectFlowRight (al); } + + SelectFlowRightSyntax () + : DeclareModel (Select::component, "flow_right", "flow", "\ +Extract flow from right of specified volume.") + { } + void load_frame (Frame&) const + { } + } select_flow_right_syntax; + + static struct SelectFlowFrontSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new SelectFlowFront (al); } + + SelectFlowFrontSyntax () + : DeclareModel (Select::component, "flow_front", "flow", "\ +Extract flow from front of specified volume.") + { } + void load_frame (Frame&) const + { } + } select_flow_front_syntax; + + static struct SelectFlowBackSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new SelectFlowBack (al); } + + SelectFlowBackSyntax () + : DeclareModel (Select::component, "flow_back", "flow", "\ Extract flow from back of specified volume.") - { } - void load_frame (Frame&) const - { } -} Select_flow_back_syntax; + { } + void load_frame (Frame&) const + { } + } select_flow_back_syntax; +} // select_flow.C ends here. diff --git a/src/daisy/output/select_index.C b/src/daisy/output/select_index.C index f993497bf..e61c8b5c0 100644 --- a/src/daisy/output/select_index.C +++ b/src/daisy/output/select_index.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/output/select_value.h" #include "object_model/block_model.h" #include "object_model/librarian.h" @@ -48,20 +49,24 @@ struct SelectIndex : public SelectValue { } }; -static struct SelectIndexSyntax : public DeclareModel +void +register_select_index_models () { - Model* make (const BlockModel& al) const - { return new SelectIndex (al); } - SelectIndexSyntax () - : DeclareModel (Select::component, "index", "value", "\ + static struct SelectIndexSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new SelectIndex (al); } + SelectIndexSyntax () + : DeclareModel (Select::component, "index", "value", "\ Extract content at specified array index.") - { } - void load_frame (Frame& frame) const - { - frame.declare_integer ("index", Attribute::Const, - "Specify array index to select."); - frame.set_check ("index", VCheck::non_negative ()); - } -} SelectIndex_syntax; + { } + void load_frame (Frame& frame) const + { + frame.declare_integer ("index", Attribute::Const, + "Specify array index to select."); + frame.set_check ("index", VCheck::non_negative ()); + } + } select_index_syntax; +} // select_index.C ends here. diff --git a/src/daisy/output/select_number.C b/src/daisy/output/select_number.C index 659a6d0a4..3d0e55d21 100644 --- a/src/daisy/output/select_number.C +++ b/src/daisy/output/select_number.C @@ -21,6 +21,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/output/select_value.h" #include "object_model/librarian.h" #include "object_model/frame.h" @@ -45,19 +46,23 @@ struct SelectNumber : public SelectValue { } }; -static struct SelectNumberSyntax : public DeclareModel +void +register_select_number_models () { - Model* make (const BlockModel& al) const - { return new SelectNumber (al); } + static struct SelectNumberSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new SelectNumber (al); } - SelectNumberSyntax () - : DeclareModel (Select::component, "number", "value", "\ + SelectNumberSyntax () + : DeclareModel (Select::component, "number", "value", "\ Extract specified number.\n\ If used on an array, it will treat them as individual numbers as\n\ specified by the 'handle' parameter.") - { } - void load_frame (Frame&) const - { } -} SelectNumber_syntax; + { } + void load_frame (Frame&) const + { } + } select_number_syntax; +} // select_number.C ends here. diff --git a/src/daisy/output/select_quiver.C b/src/daisy/output/select_quiver.C index 23ecac574..0a66b1eb2 100644 --- a/src/daisy/output/select_quiver.C +++ b/src/daisy/output/select_quiver.C @@ -23,6 +23,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/output/select.h" #include "daisy/soil/soil.h" #include "daisy/output/bdconv.h" @@ -321,16 +322,20 @@ struct SelectQuiver : public Select { } }; -static struct SelectQuiverSyntax : public DeclareModel +void +register_select_quiver_models () { - Model* make (const BlockModel& al) const - { return new SelectQuiver (al); } - SelectQuiverSyntax () - : DeclareModel (Select::component, "quiver", "\ + static struct SelectQuiverSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new SelectQuiver (al); } + SelectQuiverSyntax () + : DeclareModel (Select::component, "quiver", "\ Convert edge flow to node based flow vectors.") - { } - void load_frame (Frame& frame) const - { } -} SelectQuiver_syntax; + { } + void load_frame (Frame& frame) const + { } + } select_quiver_syntax; +} // select_quiver.C ends here. diff --git a/src/daisy/output/select_value.C b/src/daisy/output/select_value.C index a20dae85d..90ca27848 100644 --- a/src/daisy/output/select_value.C +++ b/src/daisy/output/select_value.C @@ -22,6 +22,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/output/select_value.h" #include "object_model/block_model.h" #include "object_model/frame.h" @@ -183,14 +184,18 @@ SelectValue::SelectValue (const BlockModel& al) value (0.0) { } -static struct SelectValueSyntax : public DeclareBase +void +register_select_value_models () { - SelectValueSyntax () - : DeclareBase (Select::component, "value", "\ + static struct SelectValueSyntax : public DeclareBase + { + SelectValueSyntax () + : DeclareBase (Select::component, "value", "\ Log a single numeric value.") - { } - void load_frame (Frame& frame) const - { } -} SelectValue_syntax; + { } + void load_frame (Frame& frame) const + { } + } select_value_syntax; +} // select_value.C ends here. diff --git a/src/daisy/output/select_volume.C b/src/daisy/output/select_volume.C index e1f0d9434..8f5b86d49 100644 --- a/src/daisy/output/select_volume.C +++ b/src/daisy/output/select_volume.C @@ -22,6 +22,7 @@ #define BUILD_DLL +#include "daisy/daisy_registration_internal.h" #include "daisy/output/select_value.h" #include "daisy/output/bdconv.h" #include "object_model/block_model.h" @@ -376,107 +377,6 @@ SelectVolume::SelectVolume (const BlockModel& al) SelectVolume::~SelectVolume () { } -static struct SelectVolumeBase : public DeclareModel -{ - Model* make (const BlockModel& al) const - { return new SelectVolume (al); } - SelectVolumeBase () - : DeclareModel (Select::component, "volume_base", "value", "\ -Shared parameters for volume based logs.") - { } - void load_frame (Frame& frame) const - { - frame.declare_string ("space", Attribute::OptionalConst, "\ -This option determine how to handle mutiple cells within the volume.\n\ -\n\ -min: Use smallest value\n\ -\n\ -max: Use largest value\n\ -\n\ -sum: Use the weighted sum of all cells.\n\ -If this is set, the 'density_z', 'density_x', and 'density_y' parameters\n\ -take effect."); - frame.set_check ("space", Select::multi_check ()); - frame.set ("space", "sum"); - frame.declare_boolean ("density", Attribute::Const, - "If true, divide total content with volume.\n\ -Otherwise, obey 'density_z', 'density_x', and 'density_y'.\n\ -Unly used if 'space' is 'sum'."); - frame.set ("density", false); - frame.declare_boolean ("density_z", Attribute::Const, - "If true, divide total content with volume height.\n\ -This parameter is ignored if 'density' is true.\n\ -Unly used if 'space' is 'sum'."); - frame.declare_boolean ("density_x", Attribute::Const, - "If true, divide total content with volume width.\n\ -This parameter is ignored if 'density' is true.\n\ -Unly used if 'space' is 'sum'."); - frame.declare_boolean ("density_y", Attribute::Const, - "If true, divide total content with volume depth.\n\ -This parameter is ignored if 'density' is true.\n\ -Unly used if 'space' is 'sum'."); - frame.declare_object ("volume", Volume::component, - Attribute::Const, Attribute::Singleton, - "Soil volume to log."); - frame.set ("volume", "box"); - - frame.declare ("min_root_density", "cm/cm^3", Attribute::Const, "\ -Minimum root density in cells.\n\ -\n\ -Set this paramater to a positive amount in order to log only cells\n\ -within the (dynamic) root zone. If the root density in the cell is\n\ -above this amount, the full amount of the data being logged will be\n\ -included. If the root density is below, the amount included will be\n\ -scaled down accordingly. That is, if there are no roots, the data for\n\ -the cell will be scaled to zero, while if there is only half the\n\ -specified minimum root density, the data for the cell will be scaled\n\ -to 0.5."); - frame.set ("min_root_density", -1.0); - frame.declare_string ("min_root_crop", Attribute::Const, "\ -Name of crop whose roots scould be used for the root density requirements.\n\ -Set this to \"*\" to use all roots."); - frame.set ("min_root_crop", "*"); // Select::wildcard may not be initialized. - } -} SelectVolume_base; - -static struct SelectVolumeSyntax : public DeclareParam -{ - SelectVolumeSyntax () - : DeclareParam (Select::component, "volume", "volume_base", "\ -Summarize specified volume.") - { } - void load_frame (Frame& frame) const - { - frame.set ("density_z", false); - frame.set ("density_x", false); - frame.set ("density_y", false); - } -} Select_volume_syntax; - -static struct SelectIntervalSyntax : public DeclareParam -{ - SelectIntervalSyntax () - : DeclareParam (Select::component, "interval", "volume_base", - "Summarize specified interval.\n\ -This is similar to 'volume', except for the default values of\n \ -'density_x' and 'density_y', and the unqiue 'from' and 'to' parameters.") - { } - void load_frame (Frame& frame) const - { - frame.set ("density_z", false); - frame.set ("density_x", true); - frame.set ("density_y", true); - frame.declare ("from", "cm", Attribute::OptionalConst, - "Specify height (negative) to measure from.\n\ -By default, measure from the top.\n\ -OBSOLETE: Use (volume box (top FROM)) instead."); - frame.declare ("to", "cm", Attribute::OptionalConst, - "Specify height (negative) to measure interval.\n\ -By default, measure to the bottom.\n\ -OBSOLETE: Use (volume box (bottom TO)) instead."); - } -} Select_interval_syntax; - // Here follows a hack to log the water content at fixed pressure. struct SelectWater : public SelectVolume @@ -533,63 +433,168 @@ struct SelectWater : public SelectVolume { } }; -static struct SelectWaterSyntax : public DeclareModel +void +register_select_volume_models () { - Model* make (const BlockModel& al) const - { return new SelectWater (al); } + static struct SelectVolumeBase : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new SelectVolume (al); } + SelectVolumeBase () + : DeclareModel (Select::component, "volume_base", "value", "\ +Shared parameters for volume based logs.") + { } + void load_frame (Frame& frame) const + { + frame.declare_string ("space", Attribute::OptionalConst, "\ +This option determine how to handle mutiple cells within the volume.\n\ +\n\ +min: Use smallest value\n\ +\n\ +max: Use largest value\n\ +\n\ +sum: Use the weighted sum of all cells.\n\ +If this is set, the 'density_z', 'density_x', and 'density_y' parameters\n\ +take effect."); + frame.set_check ("space", Select::multi_check ()); + frame.set ("space", "sum"); + frame.declare_boolean ("density", Attribute::Const, + "If true, divide total content with volume.\n\ +Otherwise, obey 'density_z', 'density_x', and 'density_y'.\n\ +Unly used if 'space' is 'sum'."); + frame.set ("density", false); + frame.declare_boolean ("density_z", Attribute::Const, + "If true, divide total content with volume height.\n\ +This parameter is ignored if 'density' is true.\n\ +Unly used if 'space' is 'sum'."); + frame.declare_boolean ("density_x", Attribute::Const, + "If true, divide total content with volume width.\n\ +This parameter is ignored if 'density' is true.\n\ +Unly used if 'space' is 'sum'."); + frame.declare_boolean ("density_y", Attribute::Const, + "If true, divide total content with volume depth.\n\ +This parameter is ignored if 'density' is true.\n\ +Unly used if 'space' is 'sum'."); + frame.declare_object ("volume", Volume::component, + Attribute::Const, Attribute::Singleton, + "Soil volume to log."); + frame.set ("volume", "box"); - SelectWaterSyntax () - : DeclareModel (Select::component, "water", "volume_base", "\ -Shared parameters for water limited volumn logging.") - { } - void load_frame (Frame& frame) const + frame.declare ("min_root_density", "cm/cm^3", Attribute::Const, "\ +Minimum root density in cells.\n\ +\n\ +Set this paramater to a positive amount in order to log only cells\n\ +within the (dynamic) root zone. If the root density in the cell is\n\ +above this amount, the full amount of the data being logged will be\n\ +included. If the root density is below, the amount included will be\n\ +scaled down accordingly. That is, if there are no roots, the data for\n\ +the cell will be scaled to zero, while if there is only half the\n\ +specified minimum root density, the data for the cell will be scaled\n\ +to 0.5."); + frame.set ("min_root_density", -1.0); + frame.declare_string ("min_root_crop", Attribute::Const, "\ +Name of crop whose roots scould be used for the root density requirements.\n\ +Set this to \"*\" to use all roots."); + frame.set ("min_root_crop", "*"); // Select::wildcard may not be initialized. + } + } select_volume_base; + + static struct SelectVolumeSyntax : public DeclareParam { - frame.declare ("h", "cm", Check::non_positive (), Attribute::Const, - "Pressure to log water content for."); - frame.declare ("h_ice", "cm", Check::non_positive (), Attribute::Const, - "Pressure at which all air is out of the matrix.\n\ + SelectVolumeSyntax () + : DeclareParam (Select::component, "volume", "volume_base", "\ +Summarize specified volume.") + { } + void load_frame (Frame& frame) const + { + frame.set ("density_z", false); + frame.set ("density_x", false); + frame.set ("density_y", false); + } + } select_volume_syntax; + + static struct SelectIntervalSyntax : public DeclareParam + { + SelectIntervalSyntax () + : DeclareParam (Select::component, "interval", "volume_base", + "Summarize specified interval.\n\ +This is similar to 'volume', except for the default values of\n \ +'density_x' and 'density_y', and the unqiue 'from' and 'to' parameters.") + { } + void load_frame (Frame& frame) const + { + frame.set ("density_z", false); + frame.set ("density_x", true); + frame.set ("density_y", true); + frame.declare ("from", "cm", Attribute::OptionalConst, + "Specify height (negative) to measure from.\n\ +By default, measure from the top.\n\ +OBSOLETE: Use (volume box (top FROM)) instead."); + frame.declare ("to", "cm", Attribute::OptionalConst, + "Specify height (negative) to measure interval.\n\ +By default, measure to the bottom.\n\ +OBSOLETE: Use (volume box (bottom TO)) instead."); + } + } select_interval_syntax; + + static struct SelectWaterSyntax : public DeclareModel + { + Model* make (const BlockModel& al) const + { return new SelectWater (al); } + + SelectWaterSyntax () + : DeclareModel (Select::component, "water", "volume_base", "\ +Shared parameters for water limited volumn logging.") + { } + void load_frame (Frame& frame) const + { + frame.declare ("h", "cm", Check::non_positive (), Attribute::Const, + "Pressure to log water content for."); + frame.declare ("h_ice", "cm", Check::non_positive (), Attribute::Const, + "Pressure at which all air is out of the matrix.\n\ When there are no ice, this is 0.0. When there are ice, the ice is\n\ presumed to occupy the large pores, so it is h (Theta_sat - X_ice)."); - frame.set ("h_ice", 0.0); - } -} SelectWater_syntax; - -static struct SelectWaterVolumeParam : public DeclareParam -{ - SelectWaterVolumeParam () - : DeclareParam (Select::component, "water_volume", "water", "\ -Summarize water content in the specified volume.") - { } - void load_frame (Frame& frame) const + frame.set ("h_ice", 0.0); + } + } select_water_syntax; + + static struct SelectWaterVolumeParam : public DeclareParam { - frame.set ("density_z", false); - frame.set ("density_x", false); - frame.set ("density_y", false); - } -} Select_water_volume_syntax; + SelectWaterVolumeParam () + : DeclareParam (Select::component, "water_volume", "water", "\ +Summarize water content in the specified volume.") + { } + void load_frame (Frame& frame) const + { + frame.set ("density_z", false); + frame.set ("density_x", false); + frame.set ("density_y", false); + } + } select_water_volume_syntax; -static struct SelectWaterIntervalParam : public DeclareParam -{ - void load_frame (Frame& frame) const + static struct SelectWaterIntervalParam : public DeclareParam { - frame.set ("density_z", false); - frame.set ("density_x", true); - frame.set ("density_y", true); - frame.declare ("from", "cm", Attribute::OptionalConst, - "Specify height (negative) to measure from.\n\ + void load_frame (Frame& frame) const + { + frame.set ("density_z", false); + frame.set ("density_x", true); + frame.set ("density_y", true); + frame.declare ("from", "cm", Attribute::OptionalConst, + "Specify height (negative) to measure from.\n\ By default, measure from the top.\n\ OBSOLETE: Use (volume box (top FROM)) instead."); - frame.declare ("to", "cm", Attribute::OptionalConst, - "Specify height (negative) to measure interval.\n\ + frame.declare ("to", "cm", Attribute::OptionalConst, + "Specify height (negative) to measure interval.\n\ By default, measure to the bottom.\n\ OBSOLETE: Use (volume box (bottom TO)) instead."); - } - SelectWaterIntervalParam () - : DeclareParam (Select::component, "water_interval", "water", "\ + } + SelectWaterIntervalParam () + : DeclareParam (Select::component, "water_interval", "water", "\ Summarize water content in the specified interval.\n\ This is similar to 'water_volume', except for the default values of\n\ 'density_x' and 'density_y', and the unqiue 'from' and 'to' parameters.") - { } -} Select_water_interval_syntax; + { } + } select_water_interval_syntax; +} // select_volumne.C ends here diff --git a/src/daisy/output/summary.C b/src/daisy/output/summary.C index 560b9f537..fcc9e1c9e 100644 --- a/src/daisy/output/summary.C +++ b/src/daisy/output/summary.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/output/summary.h" +#include "daisy/daisy_registration_internal.h" #include "object_model/block_model.h" #include "object_model/librarian.h" @@ -49,18 +50,27 @@ Summary::Summary (const BlockModel& al) Summary::~Summary () { } -static struct SummaryInit : public DeclareComponent +void +register_summary_models () { - SummaryInit () - : DeclareComponent (Summary::component, "\ + static struct SummaryInit : public DeclareComponent + { + SummaryInit () + : DeclareComponent (Summary::component, "\ Summary reports for log parameterizations.") - { } - void load_frame (Frame& frame) const - { - Model::load_model (frame); - frame.declare_string ("title", Attribute::OptionalConst, + { } + void load_frame (Frame& frame) const + { + Model::load_model (frame); + frame.declare_string ("title", Attribute::OptionalConst, "Title of this summary.\n\ By default, use the name of the parameterization."); - } -} Summary_init; + } + } summary_init; + register_summary_simple_models (); + register_summary_balance_models (); + register_summary_Rsqr_models (); + register_summary_RsqrW_models (); + register_summary_fractiles_models (); +} diff --git a/src/daisy/output/summary_Rsqr.C b/src/daisy/output/summary_Rsqr.C index 3f0142bed..199c6c273 100644 --- a/src/daisy/output/summary_Rsqr.C +++ b/src/daisy/output/summary_Rsqr.C @@ -21,6 +21,7 @@ #define BUILD_DLL #include "daisy/output/summary.h" +#include "daisy/daisy_registration_internal.h" #include "daisy/output/destination.h" #include "daisy/output/select.h" #include "object_model/block_submodel.h" @@ -387,51 +388,55 @@ SummaryRsqr::summarize (Treelog& msg) const msg.message (pds.str ()); } -static struct SummaryRsqrSyntax : public DeclareModel +void +register_summary_Rsqr_models () { - Model* make (const BlockModel& al) const - { return new SummaryRsqr (al); } - SummaryRsqrSyntax () - : DeclareModel (Summary::component, "Rsqr", "\ -Calculate coefficient of determination.") - { } - static bool check_alist (const Metalib&, const Frame& frame, Treelog& msg) + static struct SummaryRsqrSyntax : public DeclareModel { - bool ok = true; + Model* make (const BlockModel& al) const + { return new SummaryRsqr (al); } + SummaryRsqrSyntax () + : DeclareModel (Summary::component, "Rsqr", "\ +Calculate coefficient of determination.") + { } + static bool check_alist (const Metalib&, const Frame& frame, Treelog& msg) + { + bool ok = true; - const std::vector/**/>& measure - = frame.submodel_sequence ("measure"); - std::set