Modeling Solar Panel Output and Battery Storage Using Real World Data in Matlab

Jason Smith, Michigan State University, Engineering - First Year

Author Profile

Summary

Activity Description:

This project involves designing and analyzing a home solar panel system using MATLAB. Students are tasked with calculating energy output, battery storage levels, and energy needs over time based on real-world data collected in Lansing, Michigan. They are provided with a .mat file containing three years of hourly data for solar flux, air temperature, and standard home energy use. The students use these data, combined with several assumptions, to build an energy model. This project introduces students to fundamental concepts in renewable energy systems and data-driven decision-making using MATLAB.

Key Outcomes:

  • Ability to process and analyze time-series data using MATLAB.
  • Calculation of temperature-adjusted solar panel efficiency.
  • Determination of energy storage in batteries and energy shortfalls.
  • Estimation of cost savings from using solar energy over a 3-year period compared to conventional grid power.

Key Terms:

  • Home solar panels
  • Renewable energy system modeling
  • MATLAB time-series analysis
  • Solar flux 
  • Battery storage calculation

Share your modifications and improvements to this activity through the Community Contribution Tool »

Learning Goals

Goals of the Activity or Assignment:

Concepts and Content:

Renewable Energy Systems: Students learn the basics of solar panel systems, including key components like solar arrays, inverters, and batteries. They also explore how solar energy can be captured, transformed, and stored, gaining an understanding of how inefficiencies impact energy availability.
Energy Efficiency & Cost Analysis: The project introduces students to the concepts of energy efficiency and performance ratio, helping them calculate real-world energy output and savings potential when using solar power versus traditional grid electricity.
Impact of Environmental Factors: Students gain insights into how environmental variables, such as solar radiation and air temperature, affect the performance of renewable energy systems.

MATLAB Utilization and Learning Enhancement:

Data Processing & Time-Series Analysis: MATLAB is used extensively to process large time-series datasets of solar flux, temperature, and home energy use. This allows students to engage with real-world data in a computational environment, improving their ability to manipulate and analyze complex datasets.
Algorithm Development: Students write custom MATLAB scripts to calculate temperature-adjusted solar panel efficiency, track battery storage, and determine energy needs. This helps develop their problem-solving and coding skills, teaching them how to model physical systems using code.
Simulation & Modeling: MATLAB enables students to simulate various scenarios (e.g., varying temperatures and energy usage patterns) and calculate energy savings, giving them the tools to model and analyze real-world engineering problems.
Higher-Order Thinking Skills:

Critical Thinking & Problem Solving:

Students must evaluate how environmental and system variables influence energy output and develop algorithms to manage these variables. They apply critical thinking to assess how best to store energy and manage home energy needs, adapting models to fit complex scenarios.

Computation & Data Analysis: 

Students engage in in-depth computational analysis, using MATLAB to manipulate time-series data and compute energy usage and savings. This enhances their ability to analyze data and make informed decisions based on their results.

Model Development:

By building models of a solar energy system that integrate multiple variables (e.g., temperature, solar radiation, battery storage), students synthesize ideas from different areas of study (physics, engineering, economics) to develop an integrated energy model.

Technical Writing: 

Students are required to submit a brief report summarizing their methods, results, and conclusions, honing their ability to communicate complex technical ideas in a clear, concise manner.

Quantitative Reasoning: 

Through financial calculations related to energy savings, students practice quantitative reasoning, learning to translate technical data into economic impact.

Algorithmic Thinking: 

The development of logical flow charts or diagrams to design battery management algorithms reinforces algorithmic thinking, a skill critical for engineers and scientists.

Context for Use

Contextual Information:

Educational Level, Class Size, and Institution Type:

This project is designed for undergraduate engineering students, ideally in their first or second year, as part of an introductory course in engineering or renewable energy systems.
The project is appropriate for medium-sized classes (25-50 students) but can be adapted for larger or smaller groups. It is intended for institutions offering engineering, technical, or sustainability-focused programs, like universities or community colleges.
Type of Activity and Duration:

This is a longer-term project, typically assigned as a final individual project for the course. It would span approximately 2-3 weeks, allowing students to digest the technical concepts, work with MATLAB, and develop their reports.
It could also be adapted as a lab or a series of lab sessions for courses emphasizing hands-on problem-solving with MATLAB.
Technical Skills and MATLAB Experience Required:

Students should have basic familiarity with MATLAB, including the ability to import and manipulate data, use basic plotting functions, and write simple algorithms. They should also be comfortable performing calculations and logic operations based on conditions.
Experience with time-series data handling and basic programming concepts (such as loops and conditionals) is necessary. A few introductory MATLAB labs earlier in the course would be sufficient preparation.
Disciplinary Concepts and Skills:

Students should already have an understanding of basic physics concepts, such as energy, power, and efficiency, as well as introductory knowledge of renewable energy systems (particularly solar panels and their components).
Familiarity with basic mathematical concepts (algebra and calculus), especially working with equations and unit conversions, is essential.
Course Placement and Adaptability:

This project is typically placed near the end of a course to integrate and apply previously learned concepts from renewable energy systems and MATLAB programming.
It is relatively easy to adapt to different contexts, especially in other engineering or sustainability programs, as long as the students have a similar level of MATLAB experience. The datasets could also be swapped for relevant data from other regions or energy sources, allowing for flexibility in application.
Adaptability:

The assignment can be simplified for less experienced students by providing more guidance on the MATLAB algorithms or making assumptions more explicit.
For more advanced students, the project could be extended to include more sophisticated calculations, such as considering more complex energy usage patterns, additional solar system components, or even financial modeling based on varying electricity prices.

Description and Teaching Materials

Activity Description and Teaching Materials

Narrative: This project tasks students with analyzing and designing a home solar panel system using MATLAB. The key learning objectives involve modeling energy production, managing energy storage, and determining cost savings compared to traditional grid electricity. The project makes use of real-world data from Lansing, Michigan, over a period of three years, and students are required to process this data to make informed decisions about system design and performance.

Mechanics of the Activity:

Data Acquisition: Students load time-series data on solar flux, air temperature, and home energy use into MATLAB. This data is provided in a .mat file and must be processed to calculate key metrics like energy output and battery levels.

Solar Panel Efficiency Calculation: Students adjust the baseline solar panel efficiency based on temperature variations using a provided formula. This step teaches them how to incorporate environmental conditions into energy system modeling.

Energy Output Calculation: Using MATLAB, students calculate the hourly energy output from the solar panels based on real-time data, incorporating inefficiencies in the system and temperature effects.

Battery Storage and Energy Usage: Students write an algorithm in MATLAB to track the energy stored in a home battery. This involves logic-based decision-making about when energy is stored, used, or pulled from the grid, reinforcing skills in algorithm design.

Energy Shortfall Calculation: MATLAB is also used to calculate the shortfall when energy from solar panels and battery storage is insufficient, and students determine how much energy must be bought from the grid.

Cost Savings Calculation: Students estimate how much money could be saved by using solar panels, compared to relying entirely on grid power, by calculating energy use over the 3-year period at a rate of $0.16/kWh.

Materials Needed:

Dataset: A .mat file containing time-series data on solar flux, air temperature, and home energy use. This data can be downloaded directly from the course site or provided by the instructor.
MATLAB Script Template: A MATLAB script to help students get started. This script should contain skeleton code for loading the data, applying the temperature-adjustment formula, and calculating energy output.
Project Instructions: Detailed written instructions explaining each step of the project, from loading data to calculating energy costs. These should include a step-by-step breakdown of the required tasks and formulas (e.g., solar panel efficiency adjustment, battery storage calculations).

Materials Provided:

Project Instructions Document (Word/PDF): A comprehensive guide for students, including problem statement, assumptions, and required calculations.
MATLAB Starter Code (optional): Basic MATLAB script that students can use as a foundation for the assignment. This code provides the structure for loading the .mat file and performing the initial calculations.


Use of MATLAB:

MATLAB is integral to the activity because it allows students to handle large time-series datasets, perform calculations efficiently, and visualize the results. It provides a robust platform for numerical analysis, particularly with its ability to work with matrices and vectors, which makes it ideal for processing data in this type of project.

Could other software be used? While this project could technically be adapted to other platforms like Python or Excel, MATLAB's matrix operations and built-in functions make it the most suitable choice. Excel, for example, might not handle the dataset's size or complex calculations as efficiently. Python could be an alternative for more advanced students familiar with libraries like NumPy and Pandas, but MATLAB was chosen for its accessibility to engineering students and its use in educational settings.

Individual Project Explaination.pdf (Acrobat (PDF) 369kB Oct28 24)

IndividualProjectData.mat (Matlab .MAT File 681kB Oct28 24)

ProjectTemplate_PleaseRename.m (Matlab File 827bytes Oct28 24)

Teaching Notes and Tips

Sample solution provided here:

SampleFinalSolution.m (Matlab File 2kB Oct28 24)


Assessment

MATLAB Script Evaluation:

Correctness and Functionality: The primary focus is on whether the MATLAB script works as expected. This includes checking if the script correctly loads the data, applies the temperature adjustment formula, calculates energy output, tracks battery storage, and determines energy shortfalls. The script should produce accurate, logical results when run with the provided dataset.
Algorithm Design: Evaluate the structure and logic of the algorithms used, especially for energy storage and battery management. Students should demonstrate clear decision-making processes (e.g., when to store or use energy), which can be evaluated by reviewing both their code and any flowcharts or pseudocode they submit.

Code Organization and Readability: The script should be well-documented with comments explaining key sections. Good coding practices, such as clear variable names and proper use of functions, are also assessed to ensure students understand the importance of code clarity in engineering.

Report Assessment:

Explanation of Methods: The report should include a clear, concise explanation of the steps students took to complete the project, especially how they approached calculating energy output and managing battery storage. This assesses their ability to communicate technical methods effectively.
Data Analysis and Interpretation: Evaluate how well students interpret the results of their model, particularly when comparing the solar panel system's performance with and without a battery. Look for logical conclusions based on the data, such as insights into when and why energy shortfalls occur or how temperature impacts solar panel efficiency.
Cost Savings Calculation: Check the accuracy of their cost savings calculations over the 3-year period. Students should be able to compare the financial benefits of using solar panels versus purchasing all energy from the grid and explain these differences clearly.

Sample - Final Individual Project Grading Rubric.xlsx (Excel 2007 (.xlsx) 11kB Oct28 24)