component C_table % C_table % Models a capacitor where the capacitance value (C) depends on an external % physical signal inputs SOC and T. It is assumed that the capacitance value % is slowly varying with time, and hence the equation i = C*dv/dt holds. % Copyright 2012-2015 The MathWorks, Inc. nodes p = foundation.electrical.electrical; % +:left n = foundation.electrical.electrical; % -:right end inputs T = {293.15,'K'}; %T:left SOC = {1,'1'}; %SOC:left end parameters (Size=variable) C_Table = {ones(5,3),'F'} % Matrix of capacitance values, C(SOC,T) SOC_Table = {[0;0.1;0.5;0.9;1],'1'} % State of charge (SOC) breakpoints Temp_Table = {[273.15 293.15 313.15],'K'} % Temperature (T) breakpoints end parameters v0 = {0,'V'}; % Initial voltage across capacitor end variables(Access=private) i = { 0, 'A' }; % Current v = { 0, 'V' }; % Voltage end function setup %#simple % Check parameter values if any(any(value(C_Table,'F')<=0)) pm_error('simscape:GreaterThanZero','Matrix of capacitance values, C(SOC,T)') end if any(value(SOC_Table,'1')<0) pm_error('simscape:GreaterThanOrEqualToZero','State of charge (SOC) breakpoints'); end if any(value(Temp_Table,'K')<0) pm_error('simscape:GreaterThanOrEqualToZero','% Temperature (T) breakpoints'); end % Set the initial voltage v = {value=v0, priority=priority.high}; end branches i : p.i -> n.i; end equations v == p.v - n.v; let % Perform the table lookup C = tablelookup(SOC_Table,Temp_Table,C_Table,SOC,T,... interpolation=linear,extrapolation=nearest) in % Electrical equation i == C * v.der; end end end