31 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| def initialise_SoC(bess):
 | |
|     """Initialise the state of charge (SoC) for the BESS."""
 | |
|     for i in range(0, len(bess["units"])):  # initially fully charged
 | |
|         bess["units"][i]["SoC"] = 1
 | |
|     return bess
 | |
| 
 | |
| 
 | |
| def initial_site_assignment(c, bess):
 | |
|     """Initialise the site assignment for each BESS."""
 | |
|     k = 0
 | |
|     while k < len(c["site_info"]["sites"]):
 | |
|         bess["units"][k]["site"] = c["site_info"]["sites"][k]["name"]
 | |
|         k += 1
 | |
| 
 | |
|     if k < len(c["site_info"]["sites"]):
 | |
|         bess["units"][k]["site"] = "Unassigned"
 | |
|     return bess
 | |
| 
 | |
| 
 | |
| def discharge_bess(bess, site_name, dt, discharge_power):
 | |
|     # convert discharge power to discharge energy (kW to kWh)
 | |
|     discharge_energy = discharge_power * dt / 3600
 | |
| 
 | |
|     """Discharge the BESS for a specific site."""
 | |
|     for index, unit in enumerate(bess["units"]):
 | |
|         if unit["site"] == site_name:
 | |
|             new_soc = unit["SoC"] - (dt * discharge_energy) / unit["capacity_kWh"]
 | |
|             new_soc = 0 if new_soc < 0 else new_soc
 | |
|             bess["units"][index]["SoC"] = new_soc
 | |
|     return bess
 |