Skip to content

Commit

Permalink
CASSYS v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tscansolar committed Dec 21, 2017
1 parent 8459f01 commit 23d62ec
Show file tree
Hide file tree
Showing 17 changed files with 533 additions and 238 deletions.
3 changes: 2 additions & 1 deletion CASSYS Engine/CASSYS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CASSYS</RootNamespace>
<AssemblyName>CASSYS</AssemblyName>
<AssemblyName>CASSYS Engine</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
Expand Down Expand Up @@ -81,6 +81,7 @@
<Compile Include="HorizonShading.cs" />
<Compile Include="Interpolate.cs" />
<Compile Include="Inverter.cs" />
<Compile Include="LossDiagram.cs" />
<Compile Include="MetReader.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PVArray.cs" />
Expand Down
5 changes: 3 additions & 2 deletions CASSYS Engine/CASSYS.csproj.user
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<StartWorkingDirectory>U:\CASS\Engineering\Monitoring\Simulation\Unit Testing\Sample Files\</StartWorkingDirectory>
<StartArguments>"ALF_iteration.csyx" "Toronto_ClimateFile_CWEC.csv" "Toronto_Output.csv"</StartArguments>
<StartWorkingDirectory>C:\Users\tynan.sears\Documents\Work\Dev\Testing\CASSYS\</StartWorkingDirectory>
<StartArguments>"Sample Site - Toronto.csyx" "Toronto_ClimateFile_CWEC.csv" "Toronto_Output.csv"</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<StartWorkingDirectory>U:\CASS\Engineering\Monitoring\Simulation\Far Shading\CASSYS Horizon Shading\</StartWorkingDirectory>
Expand All @@ -17,5 +17,6 @@
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
</Project>
244 changes: 123 additions & 121 deletions CASSYS Engine/GridConnectedSystem.cs

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions CASSYS Engine/HorizonShading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ class HorizonShading
public double TDif; // Diffuse irradiance allowing for horizon effects [W/m^2]
public double TRef; // Ground reflected irradiance allowing for horizon effects [W/m^2]
public double TGlo; // Total irradiance allowing for horizon effects [W/m^2]
public double GloRad; // Total irradiance with no horizon shadin effects [W/m^2]

public double LossDir; // Beam losses due to horizon effects [W/m^2]
public double LossDif; // Diffuse losses due to horizon effects [W/m^2]
public double LossRef; // Ground reflected losses due to horizon effects [W/m^2]
public double LossGlo; // Total losses due to horizon effects [W/m^2]

// Horizon shading constructor
public HorizonShading()
Expand Down Expand Up @@ -169,6 +175,13 @@ double SunZenith // The Zenith position of the
TRef = GRefFactor * POAGRef;
TGlo = TDir + TDif + TRef;
}

// Calculate horizon shading losses
LossDir = POABeam - TDir;
LossDif = POADiff - TDif;
LossRef = POAGRef - TRef;
LossGlo = LossDir + LossDif + LossRef;

}

// This function creates a 361-element length array that extends 180 degrees above and below the Panel Azimuth value
Expand Down
28 changes: 15 additions & 13 deletions CASSYS Engine/Inverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class Inverter
{
// Inverter definition variables
bool itsMPPTracking; // MppTracking flag [TRUE, FALSE]
double itsMppWindowMin; // Minimum value for Mppt window [V]
double itsMppWindowMax; // Maximum value for Mppt window [V]
public double itsMppWindowMin; // Minimum value for Mppt window [V]
public double itsMppWindowMax; // Maximum value for Mppt window [V]
public int itsNumInverters; // Number of same inverters supporting array [#]
public double itsThresholdPwr; // Power below which inverter cuts off [W]
public double itsMinVoltage; // Minimum voltage required for the Inverter to turn ON [V]
Expand All @@ -43,13 +43,13 @@ class Inverter
public int outputPhases; // The number of phases at the inverter output [#]

// Efficiency curves related variables
bool threeCurves; // True if Inverter has three efficiency curves, false if Inverter has one efficiency curve
bool threeCurves; // True if Inverter has three efficiency curves, false if Inverter has one efficiency curve
double itsLowVoltage; // The voltage threshold for low voltage efficiency curve [V]
double itsMedVoltage; // The voltage threshold for medium voltage efficiency curve [V]
double itsHighVoltage; // The voltage threshold for high voltage efficiency curve [V]
double[][] itsPresentEfficiencies = new double[2][];// Current Efficiency curve chosen calculated for different voltage values [%]
public double[][] itsLowEff = new double[2][]; // Low voltage efficiency curve values [P DC in, %]
double[][] itsMedEff = new double[2][]; // Medium voltage efficiency curve values [P DC in, %]
double[][] itsMedEff = new double[2][]; // Medium voltage efficiency curve values [P DC in, %]
double[][] itsHighEff = new double[2][]; // High voltage efficiency curve values [P DC in, %]
public double[][] itsOnlyEff = new double[2][]; // Its only efficiency curve [P DC in, %]
bool effIn;
Expand All @@ -72,9 +72,10 @@ class Inverter
public double itsPNomArrayAC; // Nominal AC Production of the Array [W]
public double LossPMinThreshold; // Loss when the power of the array is not sufficient for starting the inverter.
public double LossClipping; // Produced power before reduction by Inverter (clipping) [W]
public double itsMaxSubArrayACEff; // Initializing the value of the maximum AC power produced by this Sub-Array


public double LossLowVoltage; // Loss due to voltage too low [W]
public double LossHighVoltage; // Loss due to voltage too high [W]
public double itsMaxSubArrayACEff; // Initializing the value of the maximum AC power produced by this Sub-Array

// Inverter constructor
public Inverter
(
Expand Down Expand Up @@ -133,11 +134,12 @@ double DCPwrIn // DC Power in from PVArray
}

// Check if the PV Array voltage is within the MPPT Window of the Inverter
public void GetMPPTStatus(double arrayV, out bool MPPTStatus)
// public void GetMPPTStatus(double arrayV, out bool MPPTStatus)
public void GetMPPTStatus(double arrayV)
{
// Default value for if the Inverter is in the MPPT Window
MPPTStatus = false;

inMPPTWindow = false;
if (itsMPPTracking)
{
if (arrayV < itsMppWindowMin)
Expand All @@ -151,7 +153,7 @@ public void GetMPPTStatus(double arrayV, out bool MPPTStatus)
VInDC = itsMppWindowMin; // Less than or equal to voltage window minimum, fix to voltage minimum
}

MPPTStatus = false;
inMPPTWindow = false;
}
else if (arrayV > itsMppWindowMax)
{
Expand All @@ -164,7 +166,7 @@ public void GetMPPTStatus(double arrayV, out bool MPPTStatus)
VInDC = itsMppWindowMax; // Less than or equal to voltage window minimum, fix to voltage minimum
}

MPPTStatus = false;
inMPPTWindow = false;
}
// If in between the voltage window, the voltage stays as received
else
Expand All @@ -177,7 +179,7 @@ public void GetMPPTStatus(double arrayV, out bool MPPTStatus)
{
VInDC = arrayV;
}
MPPTStatus = true;
inMPPTWindow = true;
}
}
}
Expand Down
165 changes: 165 additions & 0 deletions CASSYS Engine/LossDiagram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
// CASSYS - Grid connected PV system modelling software
// (c) Canadian Solar Solutions Inc.
///////////////////////////////////////////////////////////////////////////////
//
// Title: LossDiagram
//
// Revision History:
// TS - 2017-11-01: Version 1.3.0 First release
//
//
// Description:
// This class calculates the total losses of the system to write them to a temp
// file for the interface to read and update the losses diagram
//
///////////////////////////////////////////////////////////////////////////////
// References and Supporting Documentation or Links
///////////////////////////////////////////////////////////////////////////////
// https://www.dotnetperls.com/xmlwriter: XmlWriter
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Xml;
using System.Collections.Generic;
using System.Windows.Forms;

namespace CASSYS
{
public class LossDiagram
{
// Parameters for config and variables used for calculations
public static Dictionary<String, dynamic> LossOutputs; // Creating a dictionary to hold all output values for the loss diagram;

// Irradiance values [W/m^2]
double horizontalGlobRad = 0; // Sum of horizontal global irradiance
double globRadInPOA = 0; // Sum of global radiation in POA
double horizonShadeLosses = 0; // Sum of radiation loss due to horizon shading factors
double nearShadeLosses = 0; // Sum of radiation loss due to row to row shading fatctors
double soilingLoss = 0; // Sum of radiation loss due to panel soiling
double incidenceAngleLoss = 0; // Sum of radiation loss due to incidence angle
double effectivePOARad = 0; // Sum of effective radiation available for power conversion

// PV array level values [kWh]
double arrayNomEnergy = 0; // Nominal power of the farm
double temperatureLoss = 0; // Energy loss due to module temperature efficiency
double irradianceLevelLoss = 0; // Energy loss due to irradiance level
double qualityLoss = 0; // Energy loss due to module quality
double mismatchLoss = 0; // Energy loss due to module mismatch
double wiringLossDC = 0; // Energy loss due to DC wiring

// Inverter level variables [kWh]
double virtInverterInEnergy = 0; // Virtual energy available to the inverter at the inverter input
double powLowLoss = 0; // Energy loss due to below threshold power at inverter input
double powHighLoss = 0; // Energy loss due to above nominal power at inverter input (Clipping)
double voltageLowLoss = 0; // Energy loss due to below threshold voltage at inverter input
double voltageHighloss = 0; // Energy loss due to above maximum voltage at inverter input
double actualInverterInEnergy = 0; // Actual energy available to the inverter at the inverter input
double DCAC_ConversionLoss = 0; // Energy loss due to power conversion from DC to AC
double inverterOutput = 0; // AC Energy available at the inverter output

// Transformer level variables [kWh]
double wiringLossAC = 0; // Energy loss due to AC wiring
double nightEnergizeLoss = 0; // Energy loss due to transformer energization at night
double transformerLoss = 0; // Energy loss due to transformer energization during day //-----------------------------
double gridEnergy = 0; // Energy injected into the grid

// Blank constructor
public LossDiagram()
{
}

// Calculate will configure and calculate configure necessary values for loss diagram and assign them to dictionary for output
public void Calculate()
{
// Sum loss values for every individual simulation
// Radiation level values
horizontalGlobRad += ReadFarmSettings.Outputlist["Horizontal_Global_Irradiance"];
globRadInPOA += ReadFarmSettings.Outputlist["Global_Irradiance_in_Array_Plane"];
horizonShadeLosses += ReadFarmSettings.Outputlist["FarShading_Global_Loss"];
nearShadeLosses += ReadFarmSettings.Outputlist["Near_Shading_Loss_for_Global"];
soilingLoss += ReadFarmSettings.Outputlist["Radiation_Soiling_Loss"];
incidenceAngleLoss += ReadFarmSettings.Outputlist["Incidence_Loss_for_Global"];
effectivePOARad += ReadFarmSettings.Outputlist["Effective_Irradiance_in_POA"];

// PV array level values [kWh]
arrayNomEnergy += ReadFarmSettings.Outputlist["Array_Nominal_Power"];
temperatureLoss += ReadFarmSettings.Outputlist["Power_Loss_Due_to_Temperature"];
irradianceLevelLoss += ReadFarmSettings.Outputlist["Energy_Loss_Due_to_Irradiance"];
qualityLoss += ReadFarmSettings.Outputlist["Module_Quality_Loss"];
mismatchLoss += ReadFarmSettings.Outputlist["Modules_Array_Mismatch_Loss"];
wiringLossDC += ReadFarmSettings.Outputlist["Ohmic_Wiring_Loss"];

//Inverter level values [kWh]
virtInverterInEnergy += ReadFarmSettings.Outputlist["Virtual_Inverter_Input_Energy"];
powLowLoss += ReadFarmSettings.Outputlist["Inverter_Loss_Due_to_Low_Power_Threshold"];
powHighLoss += ReadFarmSettings.Outputlist["Inverter_Loss_Due_to_High_Power_Threshold"];
voltageLowLoss += ReadFarmSettings.Outputlist["Inverter_Loss_Due_to_Low_Voltage_Threshold"];
voltageHighloss += ReadFarmSettings.Outputlist["Inverter_Loss_Due_to_High_Voltage_Threshold"];
actualInverterInEnergy += ReadFarmSettings.Outputlist["Effective_Energy_at_the_Output_of_the_Array"];
DCAC_ConversionLoss += ReadFarmSettings.Outputlist["DCAC_Conversion_Losses"];
inverterOutput += ReadFarmSettings.Outputlist["Available_Energy_at_Inverter_Output"];

// Transformer level values [kWh]
wiringLossAC += ReadFarmSettings.Outputlist["AC_Ohmic_Loss"];
nightEnergizeLoss += ReadFarmSettings.Outputlist["NightTime_Energizing_Loss"];
transformerLoss += ReadFarmSettings.Outputlist["External_transformer_loss"];
gridEnergy += ReadFarmSettings.Outputlist["Power_Injected_into_Grid"];
}

// Write dictionary values to temp output file
public void AssignLossOutputs()
{
LossOutputs = new Dictionary<String, dynamic>();
// Setting up the xml writer for xml output
XmlWriterSettings writeSettings = new XmlWriterSettings();
writeSettings.Indent = true;
writeSettings.NewLineOnAttributes = true;
XmlWriter OutputFileWriter = XmlWriter.Create(Application.StartupPath + "/LossDiagramOutputs.xml", writeSettings);

// Losses due to radiation
LossOutputs["Horizontal_Global_Radiation"] = horizontalGlobRad * Util.timeStep / 60;
LossOutputs["Global_Radiation_in_POA"] = globRadInPOA * Util.timeStep / 60;
LossOutputs["Horizon_Shading_Losses"] = horizonShadeLosses * Util.timeStep / 60;
LossOutputs["Near_Shading_Losses"] = nearShadeLosses * Util.timeStep / 60;
LossOutputs["Soiling_Losses"] = soilingLoss * Util.timeStep / 60;
LossOutputs["Incidence_Angle_Losses"] = incidenceAngleLoss * Util.timeStep / 60;
LossOutputs["Effective_POA_Radiation"] = effectivePOARad * Util.timeStep / 60;
// PV CONVERSION takes place here
// Losses at PV modules
LossOutputs["PV_Array_Nominal_Energy"] = arrayNomEnergy * Util.timeStep / 60;
LossOutputs["Energy_Loss_Due_to_Temperature"] = temperatureLoss * Util.timeStep / 60;
LossOutputs["Energy_Loss_Due_to_Irradiance_Level"] = irradianceLevelLoss * Util.timeStep / 60;
LossOutputs["Module_Quality_Losses"] = qualityLoss * Util.timeStep / 60;
LossOutputs["Mismatch_Losses"] = mismatchLoss * Util.timeStep / 60;
LossOutputs["DC_Wiring_Losses"] = wiringLossDC * Util.timeStep / 60;
// Losses at inverter
LossOutputs["Virtual_Inverter_Input"] = virtInverterInEnergy * Util.timeStep / 60;
LossOutputs["Energy_Lost_to_Input_Voltage_too_Low"] = voltageLowLoss * Util.timeStep / 60;
LossOutputs["Energy_Lost_to_Input_Voltage_too_High"] = voltageHighloss * Util.timeStep / 60;
LossOutputs["Energy_Lost_to_Input_Power_too_Low"] = powLowLoss * Util.timeStep / 60;
LossOutputs["Energy_Lost_to_Input_Power_too_High"] = powHighLoss * Util.timeStep / 60;
LossOutputs["Actual_Inverter_Input_Energy"] = actualInverterInEnergy * Util.timeStep / 60;
LossOutputs["DCAC_Conversion_Losses"] = DCAC_ConversionLoss * Util.timeStep / 60;
LossOutputs["Inverter_Output"] = inverterOutput * Util.timeStep / 60;
// Losses at transformer
LossOutputs["AC_Wiring_Losses"] = wiringLossAC * Util.timeStep / 60;
LossOutputs["Night-Time_Energization_Losses"] = nightEnergizeLoss * Util.timeStep / 60;
LossOutputs["External_Transformer_Losses"] = transformerLoss * Util.timeStep / 60;
LossOutputs["Power_Injected_into_Grid"] = gridEnergy * Util.timeStep / 60;

// Write to temp file
OutputFileWriter.WriteStartDocument();
OutputFileWriter.WriteStartElement("Losses");

foreach (KeyValuePair<string, dynamic> entry in LossOutputs)
{
// write to xml document
OutputFileWriter.WriteElementString(entry.Key, entry.Value.ToString());
}

OutputFileWriter.WriteEndElement();
OutputFileWriter.WriteEndDocument();
OutputFileWriter.Flush();
}
}
}
Loading

0 comments on commit 23d62ec

Please sign in to comment.