-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unused space is not always correctly redistributed #368
Comments
- fix function `rgroup_Establish` so that input values of `space` do not need to sum to exactly 1 (based on activated resource groups), i.e., make inputs `space` and `on` in file `rgroup.in` independent from each other --> calculate "used_space" instead of "unused_space" which missed values from de-activated resource groups and didn't adjust if the sum of space (`min_res_req`) was larger than 1 - I'm not sure what to do if `used_space = 0`: currently, the code sends a fatal signal (@kpalmqui - any suggestions?)
@dschlaep thank you for documenting this carefully and correcting the code so this implementation works if space values do not sum to 1. @chaukap take a look at Daniel's commit and explanation - just wanted you to be aware of this commit. With regard to used_space = 0, it seems this condition could occur if no rgroups are established in the current year (the way the new code is now set up). This seems unlikely to occur, but could if you are only simulating a few rgroups. I then checked the outcome of no established plants (used_space=0 and g->min_res_req = 0 for every rgroup) in the resource partitioning code and everything looks like it should work as expected. When use_space=0 and g->min_res_req=0,
And the following should never be hit:
So it seems that Logerror is not needed? We should try and test extensively with just a few rgroups turned on, low pestab values, and low eind to see if we can trigger this condition and assess if everything is working as expected when This also makes me feel that we ought to re-evaluate the whole code base and identify if there are places where we could skip functions/modules if no individuals are established.... |
@kpalmqui I agree that the |
@dschlaep but shouldn't the following prevent the division by used_space when it is 0? Line 698:
|
Yes, you are correct! Sorry!
And `g->min_res_req = 0;` on line 678 in that case.
We should remove
```
if (ZRO(used_space)) {
// We shouldn't have arrived here
LogError(stderr, LOGFATAL, "Invalid space values");
}
```
altogether!
… On Aug 2, 2019, at 23:03, Kyle Palmquist ***@***.***> wrote:
@dschlaep <https://github.com/dschlaep> but shouldn't the following prevent the division by used_space when it is 0? Line 698:
if (g->est_count > 0) {
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#368?email_source=notifications&email_token=ABACTW5CZLP7QQSO24YUDALQCSOKLA5CNFSM4IH5563KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3O2VRQ#issuecomment-517843654>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ABACTW26EVYRJSFBLKDEOJLQCSOKLANCNFSM4IH5563A>.
|
@dschlaep agreed. I think we are good to go and I will remove the logerror. thanks! |
Issue resolved by above commits and by a3874f4 |
Function
rgroup_Establish
is called at the start of each simulated year. After determining establishment, the function adjusts thespace
parameter among currently established resource groups so that it sums to 1. The parameterspace
is a user input via the filergroup.in
and is used in the function_transp_contribution_by_group
to distribute total resources (from SOILWAT2) among currently established resource groups. The function_transp_contribution_by_group
relies thatspace
sums to 1 -- otherwise resources are annihilated or created ex nihilo.If the
space
input values of activated (on = 1
) resource groups sums to 1; then the current implementation works correctly. If the input sum is not 1, then the current implementation fails: examples based on commit 43f180f on the branch "feature_space" and default values in "testing.sagebrush.master/Stepwat_Inputs/" except for changes inspace
andon
as below. The first set of values for the year 1 and 300 of simulation runs that start withused_space = ...
are from my suggested fix; the second set of values that start withunused_space = ...
are from the current implementation:sum of input space = 1: space = 0.01, but space of a.cool.grass = 0.91 and turned on
Year 1: used_space = 0.940000
sagebrush before: 0.010000 -- sagebrush after: 0.010638
a.cool.forb before: 0.010000 -- a.cool.forb after: 0.010638
a.warm.forb before: 0.010000 -- a.warm.forb after: 0.010638
a.cool.grass before: 0.910000 -- a.cool.grass after: 0.968085
Sum of space after adjustment = 1.000000
Year 1: unused_space = 0.060000
sagebrush before: 0.010000 --sagebrush after: 0.010638
a.cool.forb before: 0.010000 --a.cool.forb after: 0.010638
a.warm.forb before: 0.010000 --a.warm.forb after: 0.010638
a.cool.grass before: 0.910000 --a.cool.grass after: 0.968085
Sum of space after adjustment = 1.000000
...
Year 300: used_space = 0.970000
sagebrush before: 0.010000 -- sagebrush after: 0.010309
a.cool.forb before: 0.010000 -- a.cool.forb after: 0.010309
a.warm.forb before: 0.010000 -- a.warm.forb after: 0.010309
a.cool.grass before: 0.910000 -- a.cool.grass after: 0.938144
p.cool.grass before: 0.010000 -- p.cool.grass after: 0.010309
shrub before: 0.010000 -- shrub after: 0.010309
succulents before: 0.010000 -- succulents after: 0.010309
Sum of space after adjustment = 1.000000
Year 300: unused_space = 0.030000
sagebrush before: 0.010000 --sagebrush after: 0.010309
a.cool.forb before: 0.010000 --a.cool.forb after: 0.010309
a.warm.forb before: 0.010000 --a.warm.forb after: 0.010309
a.cool.grass before: 0.910000 --a.cool.grass after: 0.938144
p.cool.grass before: 0.010000 --p.cool.grass after: 0.010309
shrub before: 0.010000 --shrub after: 0.010309
succulents before: 0.010000 --succulents after: 0.010309
Sum of space after adjustment = 1.000000
sum of input space < 1: space = 0.01, but space of a.cool.grass = 0.91 and turned off
Year 1: used_space = 0.030000
sagebrush before: 0.010000 -- sagebrush after: 0.333333
a.cool.forb before: 0.010000 -- a.cool.forb after: 0.333333
a.warm.forb before: 0.010000 -- a.warm.forb after: 0.333333
Sum of space after adjustment = 1.000000
Year 1: unused_space = 0.060000
sagebrush before: 0.010000 --sagebrush after: 0.010638
a.cool.forb before: 0.010000 --a.cool.forb after: 0.010638
a.warm.forb before: 0.010000 --a.warm.forb after: 0.010638
Sum of space after adjustment = 0.031915
--> failed to sum to 1
...
Year 300: used_space = 0.060000
sagebrush before: 0.010000 -- sagebrush after: 0.166667
a.cool.forb before: 0.010000 -- a.cool.forb after: 0.166667
a.warm.forb before: 0.010000 -- a.warm.forb after: 0.166667
p.cool.grass before: 0.010000 -- p.cool.grass after: 0.166667
shrub before: 0.010000 -- shrub after: 0.166667
succulents before: 0.010000 -- succulents after: 0.166667
Sum of space after adjustment = 1.000000
Year 300: unused_space = 0.030000
sagebrush before: 0.010000 --sagebrush after: 0.010309
a.cool.forb before: 0.010000 --a.cool.forb after: 0.010309
a.warm.forb before: 0.010000 --a.warm.forb after: 0.010309
p.cool.grass before: 0.010000 --p.cool.grass after: 0.010309
shrub before: 0.010000 --shrub after: 0.010309
succulents before: 0.010000 --succulents after: 0.010309
Sum of space after adjustment = 0.061856
--> failed to sum to 1
sum of input space > 1: space = 0.01, but space of a.cool.grass and p.cool.grass = 0.91 and turned on
Year 1: used_space = 0.940000
sagebrush before: 0.010000 -- sagebrush after: 0.010638
a.cool.forb before: 0.010000 -- a.cool.forb after: 0.010638
a.warm.forb before: 0.010000 -- a.warm.forb after: 0.010638
a.cool.grass before: 0.910000 -- a.cool.grass after: 0.968085
Sum of space after adjustment = 1.000000
Year 1: unused_space = 0.960000
sagebrush before: 0.010000 --sagebrush after: 0.250000
a.cool.forb before: 0.010000 --a.cool.forb after: 0.250000
a.warm.forb before: 0.010000 --a.warm.forb after: 0.250000
a.cool.grass before: 0.910000 --a.cool.grass after: 22.749989
Sum of space after adjustment = 23.499989
--> failed to sum to 1
...
Year 300: used_space = 1.870000
sagebrush before: 0.010000 -- sagebrush after: 0.005348
a.cool.forb before: 0.010000 -- a.cool.forb after: 0.005348
a.warm.forb before: 0.010000 -- a.warm.forb after: 0.005348
a.cool.grass before: 0.910000 -- a.cool.grass after: 0.486631
p.cool.grass before: 0.910000 -- p.cool.grass after: 0.486631
shrub before: 0.010000 -- shrub after: 0.005348
succulents before: 0.010000 -- succulents after: 0.005348
Sum of space after adjustment = 1.000000
Year 300: unused_space = 0.030000
sagebrush before: 0.010000 --sagebrush after: 0.010309
a.cool.forb before: 0.010000 --a.cool.forb after: 0.010309
a.warm.forb before: 0.010000 --a.warm.forb after: 0.010309
a.cool.grass before: 0.910000 --a.cool.grass after: 0.938144
p.cool.grass before: 0.910000 --p.cool.grass after: 0.938144
shrub before: 0.010000 --shrub after: 0.010309
succulents before: 0.010000 --succulents after: 0.010309
Sum of space after adjustment = 1.927835
--> failed to sum to 1
The text was updated successfully, but these errors were encountered: