Initial commit

This commit is contained in:
ChuXun
2026-02-16 21:52:26 +08:00
commit 18ce59bec7
334 changed files with 35333 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
"""
Fig 2: System Interaction Diagram
Shows system boundaries and variable relationships
"""
import os
from graphviz import Digraph
def make_figure(config):
"""Generate Fig 2: System Interaction Diagram"""
dot = Digraph(comment='System Interaction')
dot.attr(rankdir='LR', size='10,8')
dot.attr('node', fontname='Times New Roman', fontsize='11')
dot.attr('edge', fontname='Times New Roman', fontsize='10')
# Central system
dot.node('SYSTEM', 'Battery System\n(State: z, v_p, T_b, S, w)',
shape='box3d', style='filled', fillcolor='lightcoral', width='2.5', height='1.5')
# Input variables (left side)
inputs = [
('L', 'Screen\nBrightness\n(L)'),
('C', 'CPU Load\n(C)'),
('N', 'Network\nActivity\n(N)'),
('G', 'GPS Usage\n(G)', 'lightgreen'), # Highlight GPS
('Ta', 'Ambient\nTemp\n(T_a)')
]
for node_id, label, *color in inputs:
fillcolor = color[0] if color else 'lightyellow'
dot.node(node_id, label, shape='ellipse', style='filled', fillcolor=fillcolor)
dot.edge(node_id, 'SYSTEM', label='Input')
# Internal modules (below system)
modules = [
('PWR', 'Power\nMapping'),
('CPL', 'CPL\nClosure'),
('THERM', 'Thermal\nDynamics'),
('AGING', 'Aging\nModel')
]
for node_id, label in modules:
dot.node(node_id, label, shape='box', style='filled', fillcolor='lightblue')
dot.edge('SYSTEM', node_id, dir='both', style='dashed')
# Output variables (right side)
outputs = [
('TTE', 'Time to\nEmpty\n(TTE)'),
('SOH', 'State of\nHealth\n(SOH)'),
('VTERM', 'Terminal\nVoltage\n(V_term)'),
('TEMP', 'Battery\nTemp\n(T_b)')
]
for node_id, label in outputs:
dot.node(node_id, label, shape='ellipse', style='filled', fillcolor='lightgreen')
dot.edge('SYSTEM', node_id, label='Output')
# Output directory
figure_dir = config.get('global', {}).get('figure_dir', 'figures')
os.makedirs(figure_dir, exist_ok=True)
# Render
output_base = os.path.join(figure_dir, 'Fig02_System_Interaction')
dot.render(output_base, format='pdf', cleanup=True)
dot.render(output_base, format='png', cleanup=True)
return {
"output_files": [f"{output_base}.pdf", f"{output_base}.png"],
"computed_metrics": {},
"validation_flags": {},
"pass": True
}