Python actual combat battery digital twin [including source code]

Brain in new VAT 2021-11-25 18:49:57
python actual combat battery digital

In this tutorial , We will show how to use Python Create simple but practical digital twins , Lithium ion batteries will be our physical assets . This digital twinning will enable us to analyze and predict battery behavior , And can be integrated into any virtual asset management workflow . We will use Keras Building neural networks , Use plotly mapping .

1、 Virtual systems and digital twins

Digital twins are industrial 4.0 An important part of , Its basic principle is to reproduce physical assets in the virtual world , To simulate its dynamics . Imagine , We have a pump somewhere in the city's water network . The pump consumes energy , Release energy in the form of water flow and pressure . The term " Reappear " It means creating a virtual object that can simulate this behavior .

The pump is connected to the pipeline 、 valve 、 Instruments and other accessories or subsystems , They are all part of the whole water pipe network system . These subsystems are connected to each other . Virtualizing a system requires performing the same work on all subsystems . after , We can simulate the whole system , Including its dependencies . The goal of virtual system is to imitate the physical world , To introduce changes 、 Evaluate performance or predict scenarios involving this asset or subsystem ( For example, in maintenance tasks ).

As mentioned earlier , Digital twins are virtual objects representing subsystems . This " twin " Should be with " Physical twinning " Respond to input variables in the same way . This virtual object must integrate the model to do this . The most important feature of digital twinning is that the model can simulate " Physics " Behavior . please remember , When we say that " Physics ", We mean any real-world entity ( It can be a lithium ion battery , Water pump , A person , A city or a cat ). Anything that can be modeled can be virtualized :

 Insert picture description here

2、 Digital model of lithium ion battery

Rechargeable lithium ion battery is a cutting-edge battery technology , Its electrochemistry depends on lithium ion . In addition to portable technical equipment , These batteries are also important assets for applications such as energy storage in electric vehicles and distribution networks . The key aspect of these batteries is their aging cost . After repeated charge and discharge cycle , The battery will deteriorate , Resulting in reduced charging capacity . This phenomenon has always been a key research field in the development of durable batteries . Its modeling is also a controversial topic . Battery degradation has an important impact on the planning and operation of these technologies .

The physical principle of battery life degradation is quite complex . In recent years , Some semi empirical degradation models of lithium ion batteries have been proposed , Used to measure battery life loss . Waste batteries are usually described as providing only their rated maximum capacity 80% The battery . This degradation can be described using the following empirical model :
 Insert picture description here

among L Is the battery life time ,L’ Is the initial battery life time ,fd Is the linear degradation rate per unit time and period . This rate is the discharge time t 、 Discharge cycle depth δ Of 、 Periodic average state of charge σ And unit temperature Tc Function of :
 Insert picture description here

3、 experimental data

Our model must predict the battery life based on the available information . however , We want to compare this model with the measurements made to determine the accuracy of the model . Let's pause here .

Many digital twins are not based on accurate physical models . They only use experimental data sets and machine learning algorithms . It's a cool way to do things . for example , They can use deep neural network models to capture the real dynamics of data . however , Extending this model to other objects requires working with a large number of data sets , In order to obtain a reliable general model . On the other hand , When the physical model works , We need less data to get an accurate general model .
We will use the real data of charge and discharge cycles of lithium-ion batteries to build our digital twin .

We will use NASA's data set ( Lithium ion battery aging data set ). This data collection comes from NASA Ames The battery prognosis test station built by the Prediction Center (PCoE). This data set is valuable for determining the accuracy of our physical model and improving its value . We will use batteries 5 Number related data . We're going to draw " Capacity " Function and number of cycles , And compare it with our physical model . Before we start , We'll change the variables L( Battery life ) Replace with C( Battery capacity ). equation 1 Will be written as follows :
 Insert picture description here

among C Is the battery capacity ,C0 Is the initial battery capacity . about fd, We used the following approximation :

 Insert picture description here

among i Is the discharge cycle ,tc Battery measured during the cycle cell temperature ,ti Is the discharge time ,k Is an empirical constant , Value taking 0.13.
 Insert picture description here

chart 2 Explain the results . Our model accurately predicts the observed values ( The average absolute error is 0.004). The model shall collect battery capacity behavior , The capacity decreases slowly in the first cycle , Then accelerate after a certain point . These changes are subtle , Many engineers use simple linear models to approach this behavior . Our model is semi empirical , Including various adjustments , To avoid dealing with partial differential equations .

4、 Building mixed digital twins

We can use it directly " Model " Create a digital twin . however , In order to apply machine learning , We will use it to improve the model based on the experimental data of NASA data set . The scheme is shown in the figure below .
 Insert picture description here

We use the experimental data and the output of neural network model to improve the model .

#Define inputs and outputs
# input: the simulation capacity
X_in = (dfb['C. Capacity'])
# output: difference between experimental values and simulation
X_out = (dfb['Capacity']) - (dfb['C. Capacity'])
X_in_train, X_in_test, X_out_train, X_out_test = train_test_split(X_in, X_out, test_size=0.33)

We use a very simple neural network :

model = Sequential()
model.add(Dense(64, activation='relu', input_shape=(1,)))
model.add(Dense(32, activation='relu'))

Integrate :

epochs = 100
loss = 'mse'
model.compile(optimizer = SGD(learning_rate=0.001),
metrics=['mae'], #Mean Absolute Error
history =,
validation_data=(X_in_test, X_out_test),

Comparison results :
 Insert picture description here

As we can see in the picture above , The neural network learns the difference between the mathematical model and the experimental results . Now? , We can add this learning to our mathematical model to improve it :

# Our digital twin by improving our model with experimental data
X_twin = X_in + model.predict(X_in).reshape(-1)

Okay , We have digital twins ( Or mixed twins ):

  • Create a physical model ( Or mathematical model )
  • Compare the model with the experimental data .
  • Through this comparison , We can improve the model .

Final , In our virtual environment, we get a " twin " The battery , Its performance is expected to be similar to that of the actual battery . Next , I want to compare the mathematical model with the mathematical model of digital twins :

 Insert picture description here

The figure above shows how our digital twins moderately improve our model . The benefits of mixed digital twins are , It enables us to use semi empirical mathematical models , And use the experimental data to improve it . It has advantages over both , Especially the mathematical model , Because it can improve , More general ( Therefore, it can be applied to other batteries to obtain better accuracy than a separate machine learning model ).

5、 forecast

Through our digital twins , Can make predictions , In order to operate Lithium ion battery .
 Insert picture description here

6、 Conclusion

Digital twins are industrial 4.0 An emerging topic in the field . We have shown how to use Python Make the smallest digital twin . When we have experimental data sets , We can show " blend " Digital twins is a more realistic way to virtualize assets . Besides , Less data is needed to develop reliable models .

The tutorial code can be found in here download , The data set used can be in here download .

In the future , You can add more future experimental data to this digital twin , To improve more mathematical models .

Original link :[Python Actual combat digital twin — BimAnt]

本文为[Brain in new VAT]所创,转载请带上原文链接,感谢

  1. 关于#python_while循环的写法#的问题,如何解决?
  2. Python异常处理中异常的种类有哪些?你知道几个?
  3. Python异常處理中异常的種類有哪些?你知道幾個?
  4. Quels sont les types d'exceptions dans la gestion des exceptions python? Combien en savez - vous?
  5. À propos de # Python Comment résoudre le problème de l'écriture de la Boucle while?
  6. Python如何操作数据库
  7. python数字游戏,让你欲罢不能
  8. Python中的可迭代对象、迭代器、For循环工作机制、生成器
  9. 一个从没接触过编程的人,如何自学进入Python行业?
  10. 一份超级实用的 Python ”技巧“清单
  11. Python 程序员给上路初学者的3点忠告
  12. 3 conseils pour les débutants sur la route par les programmeurs Python
  13. Une liste de conseils Python super pratiques
  14. Comment quelqu'un qui n'a jamais été en contact avec la programmation peut - il apprendre à entrer dans l'industrie python?
  15. Objets itérables, itérateurs, pour le mécanisme de travail circulaire, générateurs en python
  16. Les Jeux de chiffres Python vous font vous arrêter
  17. Comment Python fonctionne avec la base de données
  18. Python之html与markdown互相转换
  19. Python之html與markdown互相轉換
  20. Conversion HTML et markdown de Python
  21. Python生成的随机数,要怎么设定成随机数a小于随机数b啊
  22. Python生成的隨機數,要怎麼設定成隨機數a小於隨機數b啊
  23. Le nombre aléatoire généré par Python, comment définir le nombre aléatoire a est inférieur au nombre aléatoire B
  24. Python爬虫能做什么
  25. Python老技师给上路初学者的3点忠告
  26. 3 conseils aux débutants sur la route de l'ancien technicien Python
  27. Que peuvent faire les reptiles Python
  28. The code NPM cloned from git will report a python error after it is installed!
  29. 数据分析从零开始实战,Pandas读写CSV数据
  30. Python基础(十二):类与对象
  31. Python Foundation (12): classes et objets
  32. Python基礎(十二):類與對象
  33. L'analyse des données commence à zéro et pandas lit et écrit les données CSV
  34. Python Qt GUI设计:QSlider滑动条类(基础篇—16)
  35. #yyds干货盘点#数据分析从零开始实战,Pandas读写CSV数据
  36. This paper designs an examination system for automatically setting questions and judging papers by using Python standard library language to investigate the ability of users to calculate four integers within 100.
  37. Yyds Dry Inventory # Data Analysis started from zero, pandas read and write CSV Data
  38. python数据结构:数组、列表、栈、队列及实现
  39. Python编程真的是未来人工智能的主流吗?
  40. Python编写通讯录,支持模糊查询,利用数据库存储
  41. Python編寫通訊錄,支持模糊查詢,利用數據庫存儲
  42. Python編程真的是未來人工智能的主流嗎?
  43. Python écrit le carnet d'adresses, prend en charge les requêtes floues et utilise le stockage de base de données
  44. La programmation Python est - elle vraiment le courant dominant de l'IA future?
  45. Structure des données Python: tableaux, listes, piles, files d'attente et implémentations
  46. Python networkx Practical Social Network Visualization
  47. [译] 通过 for 循环,比较 Python 与 Ruby 编程思想的差别
  48. Comparez les différences de programmation entre Python et Ruby à travers la boucle for
  49. Python basic and introductory tutorials
  50. What you don't know
  51. 人生苦短,能让你更早下班的Python垃圾回收机制
  52. Boring playing Tetris, using Python to do their own without advertising
  53. Seemingly boring Python games, but I fished for work all afternoon!!
  54. A collection of grammar knowledge points for getting started with Python
  55. Benefits of learning Python
  56. Play childhood memories with Python, greedy snake
  57. Python is suitable for beginners
  58. Simple Python game making
  59. Welfare is coming!! Python basic syntax dry goods
  60. Simply understand the learning direction of Python and make yourself a better choice