1 Introduction

This R Markdown script is for reproducing the analysis and graphs from the journal paper:

Alghamdi, A.; Blunden, L.S.; Alam, M.; Bahaj, A.S.; James, P.A.B. “Evaluating the Opportunities and Challenges of Domestic PV Installation in Saudi Arabia Based on Field Deployment in Jeddah”. Energies 2025, 18, x. https://doi.org/10.3390/xxxxx

Included along with this file are the data files and a compiled html version of this script.

2 Load libraries

library(readxl)
library(dplyr)
library(magrittr)
library(ggplot2)
library(purrr)
library(lubridate)
library(tidyr)
library(plotly)
library(paletteer)
library(stargazer)
library(htmltools)
library(scales)
library(FinancialMath)
library(sjPlot)
library(kableExtra)

3 Assign parameters

# change filepath as appropriate
path_to_data <- ""
top_string <- as_labeller(c(`1` = "Villa 1", `2` = "Villa 2"))
TFA_1st <- 300 # first floor area, sq. m.
PV_area <- 70.6 # sq.m PV array
base_temp <- 18.0 # degC, for calculating CDDs

4 Load data

4.1 PV performance data

4.2 Billing data

4.3 Weather data from KAU

4.4 Weather data from rooftop mounted weather station

5 Aggregate PV data to monthly to compare with bill data

6 Join the bill data to the aggregated electrical data

7 Aggregate weather data

8 Composite temperature dataset

9 Generate plots

9.1 Composite temperature dataset

Dependent variable:
avta.cp
avta.fr0.923***
(0.921, 0.925)
Observations221
R21.000
Adjusted R21.000
Residual Std. Error0.596 (df = 220)
F Statistic626,731.000*** (df = 1; 220)
Note:*p<0.1; **p<0.05; ***p<0.01

9.2 Whole house electrical demand profiles 2019

9.3 Comparison of billing data with monitoring data

9.4 PV generation, demand and CDD

## Warning: Removed 130 rows containing missing values or values outside the scale range
## (`geom_col()`).

9.5 Variation of electrical demand with temperature

Dependent variable:
cons2
(1)(2)
cdd.adj0.019***0.016***
(0.015, 0.024)(0.011, 0.021)
Constant0.4855.392***
(-1.674, 2.643)(2.906, 7.878)
Observations6565
R20.5290.359
Adjusted R20.5210.349
Residual Std. Error (df = 63)2.2312.570
F Statistic (df = 1; 63)70.703***35.246***
Note:*p<0.1; **p<0.05; ***p<0.01

9.6 PV performance

## 
##  Wilcoxon signed rank test with continuity correction
## 
## data:  p1 and p2
## V = 30580, p-value = 0.1626
## alternative hypothesis: true location shift is not equal to 0

10 Financial analysis

10.1 Parameters

discount_rate <- 0.15 # decimal
usd <- 3.75 # usd sar exchange rate 22 Nov 2024 (pegged to dollar)
tariff_exp <- 0.07/usd # current export tariff where applicable
tariff_low <- 0.18/usd # low rate import tariff (<6000kWh/month)
tariff_hi  <- 0.30/usd # high rate import tariff (>6000kWh/month)
tariff_eco <- 1.00/usd # theoretical 'economic' export tariff
tariff_vhi <- 1.50/usd # theoretical economic export tariff without other changes
oandm <- 150 # annual maintenance cost usd
cost_kWp <- 1250 # installed
capacity <- 15 # kWp
initial_capital <- cost_kWp * capacity
econ_scale <- 0.8 # 20% reduction in cost
tariff_increase <- 1.0 # i.e. NO increase
n_years <- 7 # 

10.2 Consumption, generation and import

## [1] "2022-07-27 +03"
## [1] 0.172952
## New names:
## • `mon` -> `mon...1`
## • `mon` -> `mon...4`
## • `mon` -> `mon...8`

10.3 Cashflow, NPV and IRR

Case NPV IRR
BAU -16285.69 NA
I -15525.55 NA
II -10581.03 NA
III -9277.93 NA
IV -1676.48 11.19
V -811.12 13.18
VI 767.57 16.69