Skip to content
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

[Bug]: Error calculating overnight capital cost when CRP is 0 #665

Closed
gschivley opened this issue Mar 21, 2024 · 2 comments · Fixed by #666
Closed

[Bug]: Error calculating overnight capital cost when CRP is 0 #665

gschivley opened this issue Mar 21, 2024 · 2 comments · Fixed by #666
Labels
bug Something isn't working

Comments

@gschivley
Copy link
Contributor

Bug description

When running multi-period foresight, GenX throws an error when calculating the overnight capital cost if the Capital_Recovery_Period value is 0 for any resources. The parameter payment_yrs_remaining has a value of 0 for those resources and the code is unable to iterate over p=1:payment_yrs_remaining[I]. The error given is ERROR: LoadError: MethodError: reducing over an empty collection is not allowed; consider supplying init to the reducer.

Since existing resources usually don't have an investment cost in GenX inputs, it doesn't make sense to require that they have a non-zero Capital_Recovery_Period. A blunt fix would be to change zeros to ones.

	payment_yrs_remaining = min.(crp, model_yrs_remaining)
	payment_yrs_remaining = max.(payment_yrs_remaining, 1)

Another possible fix would be to only calculate occ if investment costs are non-zero.

	occ = zeros(length(inv_costs_yr))
	for i in 1:length(occ)
		if inv_costs_yr[i] > 0
			occ[i] = sum(inv_costs_yr[i]/(1+tech_wacc[i]) .^ (p) for p=1:payment_yrs_remaining[i])
		end
	end

This would still raise an error if a resource with non-zero investment costs has a crp of 0. Either way, it would be helpful if the code checked for this sort of condition and alerted the user that there might be a problem.

Environment and Version

MacOS, Julia 1.9, GenX 3.6

Relevant error messages

No response

Additional context

No response

@gschivley gschivley added the bug Something isn't working label Mar 21, 2024
@gschivley gschivley changed the title [Bug]: [Bug]: Error calculating overnight capital cost when CRP is 0 Mar 21, 2024
@sambuddhac sambuddhac linked a pull request Mar 21, 2024 that will close this issue
10 tasks
@sambuddhac
Copy link
Collaborator

@gschivley , the draft PR #666 when completed will fix this. I am bringing in the init=0 in the sum expression to fix the bug. We have dome this elsewhere in the DDP code.

@sambuddhac
Copy link
Collaborator

This is now fixed on the release branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants