Skip to content
Snippets Groups Projects
Commit 94c406e0 authored by Michael Alfons Schlüter's avatar Michael Alfons Schlüter
Browse files

Some new files and a Scipt to plot saved data

parent b494d1ec
Branches reproduction
No related tags found
No related merge requests found
Showing
with 242 additions and 1 deletion
......@@ -651,6 +651,7 @@ def read_drive_cycle(file, vehicle):
return(cycle, variable_names)
def calc_con(vehicle, qns, qTs):
"""Calculation of conture plots in the torque-speed plane."""
ns = np.linspace(1,float(vehicle['basic']['n_max'])/60,qns)
T_max = 3/2 * vehicle['electric']['zp'] * ( (vehicle['electric']['PSI'] * (vehicle['electric']['I_max']/np.sqrt(2)) ) + (vehicle['electric']['Ld']-vehicle['electric']['Lq'])*-(vehicle['electric']['I_max']/np.sqrt(2))**2 )
T_max = np.ceil( T_max/100)*100
......
# DriCy_Selo module
Created on Thu Mar 4 08:53:28 2021
Created on Thu Oct 27 08:53:28 2022
@author: Michael Schlüter
......@@ -11,6 +11,18 @@ Created on Thu Mar 4 08:53:28 2021
> [m.schlueter@tu-berlin.de](mailto:m.schlueter@tu-berlin.de)
## How to install
Requirement:
- Python 3.10
```
git clone https://git.tu-berlin.de/mschluet/dricy-selo.git <clone/copy repository>
cd dricy-selo <change to folder>
py -3.10 -m pip install . <Install Scipt and needed packages>
(pip(3) install .) <alternative>
DriCy_Selo.exe main <Start Program and enjoy>
```
### _class_ DriCy_Selo.Config()
Bases: `object`
......
File moved
# -*- coding: utf-8 -*-
"""
Created on Tue May 31 13:27:15 2022
@author: Micha
"""
import pickle
import matplotlib.pyplot as plt
from matplotlib import cm
import os
import matplotlib.ticker
import numpy as np
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.serif": "Times",
"font.size": 11,
"legend.fontsize": 11,
"xtick.labelsize": 10,
"ytick.labelsize": 10,
"text.latex.preamble": r'\usepackage{siunitx} \sisetup{detect-all} \usepackage{helvet} \usepackage{sansmath} \sansmath' # makes the plot very slow but I want to use sans-serif font
})
print(os.listdir('save'))
[cycle, variable_names] = pickle.load( open(os.path.join('save', 'EQS 450+ 800 V_WLTC_Class_3_v53_2022_10_22_14-31.p'),'rb') )
cycle[:,25][-1] / (cycle[:,25][-1] + cycle[:,19][-1]) # ETA MOSFET
cycle[:,25][-1] / (cycle[:,25][-1] + cycle[:,24][-1]) # ETA IGBT
max(cycle[:,1]) # max speed
max(cycle[:,6]) # max Power
np.average(abs(cycle[:,6]))/1000 # average Power
np.cumsum(cycle[:,4])[-1] # distance traveld
# fig, ax = plt.subplots(figsize=(6,5))
# p1 = ax.plot(cycle[:,0], cycle[:,nr], label = variable_names[nr])
# # p2 = ax.bar(labels, V_inv_sim, label = 'Ploss inverter sim', alpha = .6)
# # p3 = ax.bar(labels, V_s_sim, label='Ploss static sim', alpha = .6)
# # p4 = ax.bar(labels, V_d_sim, bottom = V_s_sim, label='Ploss dynamic sim', alpha = .6)
# ax.legend(loc=1)
# if nr >=14:
# ax.set_ylim( (0, max( max(cycle[:,14]), max(cycle[:,17]) ) ) )
# #ax.set_xlim(43.5,72.5)
# #ax.bar_label(p1,fmt='%0.4f', label_type='edge')
# # ax.bar_label(p2,fmt='%0.0f', label_type='edge')
# # ax.bar_label(p3,fmt='%0.0f', label_type='center')
# # ax.bar_label(p4,fmt='%0.0f', label_type='center')
# ax.set_ylabel(variable_names[nr])
# ax.set_xlabel('Time [s]')
# ax.grid(True, axis='both', ls="-", color='0.8')
fig, ax = plt.subplots(figsize=(6,5))
nr = 1
p1 = ax.plot(cycle[0:590,0], cycle[0:590,nr],'tab:blue', label = variable_names[nr])
p2 = ax.plot(cycle[589:1023,0], cycle[589:1023,nr], 'tab:green', label = variable_names[nr])
p3 = ax.plot(cycle[1022:1476,0], cycle[1022:1476,nr], 'tab:orange', label = variable_names[nr])
p4 = ax.plot(cycle[1475:1801,0], cycle[1475:1801,nr], 'tab:red', label = variable_names[nr])
ax.set_ylabel(variable_names[nr])
ax.yaxis.set_label_coords(-.07, .4)
ax.set_xlabel('Time [s]')
ax2 = ax.twinx()
nr = 3
p1 = ax2.plot(cycle[0:590,0], cycle[0:590,nr],'tab:blue', label = variable_names[nr])
p2 = ax2.plot(cycle[589:1023,0], cycle[589:1023,nr], 'tab:green', label = variable_names[nr])
p3 = ax2.plot(cycle[1022:1476,0], cycle[1022:1476,nr], 'tab:orange', label = variable_names[nr])
p4 = ax2.plot(cycle[1475:1801,0], cycle[1475:1801,nr], 'tab:red', label = variable_names[nr])
ax2.set_ylabel(r'acceleration $[m/s^2]$')
ax2.yaxis.set_label_coords(1.1, 0.9)
# ax2.set_xlabel('Time [s]')
#ax.legend(loc=1)
ax2.set_ylim((-19,3))
ax.set_ylim((0,210))
ax.set_yticks([0,20,40,60,80,100,120,140,160])
ax2.set_yticks([-1.5,0,1.5])
ax2.grid(True, axis='y')
ax.grid(True, axis='both', ls="-", color='0.8')
fig.tight_layout()
# plt.savefig('WoWo2.svg')
fig, ax = plt.subplots(figsize=(6,5))
nr = 15 # P_total_MOSFET
p1 = ax.plot(cycle[:,0], cycle[:,nr],'tab:blue', label = variable_names[nr], linewidth=1.0, alpha = 0.6)
nr = 20 # P_total_IGBT
p2 = ax.plot(cycle[:,0], cycle[:,nr], 'tab:green', label = variable_names[nr], linewidth=1.0, alpha = 0.6)
#p3 = ax.plot(cycle[1022:1476,0], cycle[1022:1476,nr], 'tab:orange', label = variable_names[nr])
#p4 = ax.plot(cycle[1475:1801,0], cycle[1475:1801,nr], 'tab:red', label = variable_names[nr])
ax.set_ylabel(variable_names[15] + ' / ' + variable_names[20])
#ax.yaxis.set_label_coords(-.07, .4)
ax.set_xlabel('Time [s]')
ax2 = ax.twinx()
nr = 19 # E_total_MOSFET
p1 = ax2.plot(cycle[:,0], cycle[:,nr],'tab:blue', label = variable_names[nr], linewidth=3.0, alpha = 0.8)
nr = 24 # E_total_IGBT
p2 = ax2.plot(cycle[:,0], cycle[:,nr], 'tab:green', label = variable_names[nr], linewidth=3.0, alpha = 0.8)
#p3 = ax2.plot(cycle[:,0], cycle[1022:1476,nr], 'tab:orange', label = variable_names[nr])
#p4 = ax2.plot(cycle[1475:1801,0], cycle[1475:1801,nr], 'tab:red', label = variable_names[nr])
ax2.set_ylabel(variable_names[19] + ' / ' + variable_names[24])
#ax2.yaxis.set_label_coords(1.1, 0.9)
# ax2.set_xlabel('Time [s]')
ax2.legend(['MOSFET', 'IGBT'], loc=0)
#ax2.set_ylim((-19,3))
#ax.set_ylim((0,210))
#ax.set_yticks([0,20,40,60,80,100,120,140,160])
#ax2.set_yticks([-1.5,0,1.5])
#ax2.grid(True, axis='y')
ax.grid(True, axis='both', ls="-", color='0.8')
fig.tight_layout()
# datan in MJ/kg, MJ/L -> 1/3.6 to kW/(L / kg)
data = (
('Butanol', 36.6, 29.2, {'halign': 'right', 'valign': 'top', 'x': 0, 'y': 0}),
('Diesel', 46.2, 37.3, {'halign': 'right', 'valign': 'bottom', 'x': 0, 'y': 0}),
('Ethanol', 30, 24, {'halign': 'right', 'valign': 'top', 'x': 0, 'y': 0}),
('Gasoline', 46.4, 34.2, {'halign': 'left', 'valign': 'center', 'x': 0, 'y': 0}),
('Hydrogen gas', 143, 0.01079),
('Hydrogen gas (700 bar)', 143, 5.6, {'valign': 'top', 'x': 0}),
('Kerosene', 42.8, 33, {'halign': 'right', 'valign': 'center', 'x': 0, 'y': 0}),
('Liquid hydrogen', 143, 10.1),
('Liquid natural gas', 53.6, 22.2, {'halign': 'left', 'valign': 'top', 'x': 0, 'y': 0}),
('LPG propane', 49.6, 25.3, {'halign': 'left', 'valign': 'center', 'x': 0}),
('Lead-acid battery', 0.14, 0.27, {'halign': 'left', 'valign': 'top', 'x': 0, 'y': 0}),
('Methanol', 19.7, 15.6, {'halign': 'right', 'valign': 'top', 'x': 0, 'y': 0}),
('Natural gas', 53.6, 0.0364),
('Natural gas (250 bar)', 53.6, 9, {'valign': 'top', 'x': 0}),
('Zinc–air battery', 1.59, 6.02),
# 0.54-0.72, 0.9-1.9 (values used are from the Li-Ion battery article)
('LiFePO4 battery', 0.58, 1.2),
('NMC battery', 0.74, 2.1),
)
#https://en.wikipedia.org/wiki/Comparison_of_commercial_battery_types
#https://en.wikipedia.org/wiki/Energy_density
# font12 = FontProperties(family=['serif'], size=12)
# font10 = FontProperties(family=['serif'], size=10)
# font8 = FontProperties(family=['serif'], size=8)
# plt.rcParams.update({'figure.figsize': [12, 7.5]})
fig, ax = plt.subplots(figsize=(6,5))
# fig=plt.figure(1)
# ax=plt.axes([0.05, 0.07, 0.97 - 0.05, 0.95 - 0.07])
for v in data:
# (name, MJ/kg, MJ/L, label-adjustments)
label = v[0]
x = v[1]/3.6
y = v[2]/3.6
if len(v) < 4:
halign = 'center'
valign = 'bottom'
x_text = x
y_text = y
else:
halign = v[3].get('halign', 'center')
valign = v[3].get('valign', 'bottom')
x_text = x + v[3].get('x', 0)
y_text = y + v[3].get('y', 0)
if valign == 'bottom':
y_text += 0
elif valign == 'top':
y_text -= 0
plt.scatter(x=[x], y=[y], c='r', s=5 , marker = 'o', alpha=(.8))
plt.text(x=x_text, y=y_text, s=label,
horizontalalignment=halign,
verticalalignment=valign,)
# fontproperties=font10)
#plt.title('Selected energy densities')#,
#fontproperties=font12)
plt.ylabel('kWh/L')#, fontproperties=font10)
plt.xlabel('kWh/kg')#, fontproperties=font10)
# plt.xticks(fontproperties=font8)
# plt.yticks(fontproperties=font8)
fmt = matplotlib.ticker.StrMethodFormatter("{x}")
ax.xaxis.set_major_formatter(fmt)
ax.yaxis.set_major_formatter(fmt)
# ax.xaxis.grid(True)
# ax.yaxis.grid(True)
ax.grid(True, axis='both', ls="-", color='0.9', which="both")
ax.set_axisbelow(True)
ax.set_yscale('log')
ax.set_xscale('log')
plt.xlim(3e-2, 2e2)
# #plt.ylim(1e-2, 1e2)
# plt.savefig('energy_density2.svg')
# # surf/countour plot
# b1=1
# b2=0.003
# b3=0.000017
# b4=0.0000082
# b5=0.000000018
# b6=0.00000096
# def f(T,n):
# return 2*np.pi*n*(T-(b1 + b2*T +b3*n+b4*T**2+b5*n**2+b6*T*n)) / (2*np.pi*n*T)
# #plt.style.use('seaborn-white')
# T = np.linspace(0,250,100)
# n = np.linspace(0,12500,100)
# X, Y = np.meshgrid(n, T)
# Z = f(Y,X)
# cf = plt.contourf(X, Y, Z, np.linspace(0 ,1,3)**(1/6), vmax=1, colors=['red','blue','green']);
# CBI = plt.colorbar(cf, orientation='vertical')
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment