diff --git a/CHANGELOG b/CHANGELOG index 5b2f72da91bbf6beb7bc1140f9fb974fefc5ff1c..d57b49be022fc94b25eb5f52f52468c374474264 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +Version 2.21.2 +=========== +- Fix a bug in the simulink converter that leads to incorrect voltages over rmphn elements + Version 2.21.1 =========== - Move RC.xml from scenarios to the unittests folder diff --git a/CMakeLists.txt b/CMakeLists.txt index c26d29755b699bd34af27a674325d6e5e189092e..ec0c20c011d9c210b4122d50f4f918ca7680722c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") cmake_policy(SET CMP0009 NEW) set(ISEAFrameVERSION_MAJOR 2) set(ISEAFrameVERSION_MINOR 21) -set(ISEAFramePATCH_LEVEL 1) +set(ISEAFramePATCH_LEVEL 2) set(ISEAFrameNAME "Refactor") set(ARCH_TYPE "64" diff --git a/simulink_model_creator/InsertApproximations.m b/simulink_model_creator/InsertApproximations.m deleted file mode 100644 index bff17869e4f1ab8e1ee49f3ac32a9d6d127a41ca..0000000000000000000000000000000000000000 --- a/simulink_model_creator/InsertApproximations.m +++ /dev/null @@ -1,29 +0,0 @@ -function [symbolicString] = InsertApproximations(symbolicString) -% Replace operators that cannot be inserted directly with their -% approximations. Currently this means replacing TANH. - -matches = strfind(symbolicString, 'TANH'); - -% go from end to start so the matches aren't invalidated by replacements -for startIndex = flip(matches) - % find the closing paranthesis that matches TANH - depth = 0; - endIndex = startIndex; - for i = startIndex:size(symbolicString, 2) - if symbolicString(i) == '(' - depth = depth + 1; - elseif symbolicString(i) == ')' - depth = depth - 1; - if depth == 0 - endIndex = i; - break; - end - end - end - argument = symbolicString(startIndex + 5:endIndex - 1); - approximation = ['SUB(1,DIV(2,ADD(POW(2.718,MUL(2,' argument ')),1)))']; - symbolicString = replaceBetween(symbolicString, startIndex, endIndex, approximation); -end - -end - diff --git a/simulink_model_creator/MatrixModel/MakeComponent.m b/simulink_model_creator/MatrixModel/MakeComponent.m index fbaad3ea936601e3c3f5859c1b382e035cf213a0..0080e17235301b04f32df6e3d5c39a92e508b491 100644 --- a/simulink_model_creator/MatrixModel/MakeComponent.m +++ b/simulink_model_creator/MatrixModel/MakeComponent.m @@ -26,7 +26,6 @@ add_block('Component/Component', destination, 'Position', position); set_param([destination '/RowConst'], 'Value', num2str(row)); set_param([destination '/ColConst'], 'Value', num2str(col)); component.(origsystemstr) = component.(origsystemstr) +1; -symbolicString = InsertApproximations(symbolicString); totalDepth = GetTotalDepth(symbolicString); global posVector; posVector = ones(1, totalDepth); diff --git a/simulink_model_creator/MatrixModel/MatrixConnectCellelement.m b/simulink_model_creator/MatrixModel/MatrixConnectCellelement.m index 73eb35933d91bfb16a4f3be43b63b0412a3bf4f6..8e9c491402f3da11895620678f103520b2ce8eba 100644 --- a/simulink_model_creator/MatrixModel/MatrixConnectCellelement.m +++ b/simulink_model_creator/MatrixModel/MatrixConnectCellelement.m @@ -16,6 +16,11 @@ set_param([system '/InitialSoC'], 'GotoTag', gotoInitialSoC); for i = 1:size(allBlocks, 1) add_line(system, 'Temperature/1', strcat(allBlocks(i,:), '/1'), 'autorouting', 'on'); add_line(system, 'SoC/1', strcat(allBlocks(i,:), '/2'), 'autorouting', 'on'); + if startsWith(allBlocks(i,:), 'Rmphn') + rmphnSystem = [system '/' strtrim(allBlocks(i,:))]; + add_line(rmphnSystem, 'T/1', 'ParallelRC_Elem1/1'); + add_line(rmphnSystem, 'SoC/1', 'ParallelRC_Elem1/2'); + end end end diff --git a/simulink_model_creator/MatrixModel/MatrixCreateRMPHN.m b/simulink_model_creator/MatrixModel/MatrixCreateRMPHN.m index 7db9c095506f9214bda1567285640088c26a448e..fbde9b98f70f84bbf2ebd56796261bccbc972bc3 100644 --- a/simulink_model_creator/MatrixModel/MatrixCreateRMPHN.m +++ b/simulink_model_creator/MatrixModel/MatrixCreateRMPHN.m @@ -1,6 +1,6 @@ function[destination] = MatrixCreateRMPHN(destination, iD ... - , rObjRowPoints, rObjColPoints, rObjMatrix ... - , tauObjRowPoints, tauObjColPoints, tauObjMatrix) + , tauObjRowPoints, tauObjColPoints, tauObjMatrix ... + , rObjRowPoints, rObjColPoints, rObjMatrix) [position, number] = GetPosition(destination); destination = SetElemNoToDestination(destination, number); diff --git a/simulink_model_creator/MatrixModel/PlaceSymbol.m b/simulink_model_creator/MatrixModel/PlaceSymbol.m index fe4d0de7f3313a898d692ac0d250dbb0fe824fc9..37083d1409940ffa67e8dbb37878d2703fb6c020 100644 --- a/simulink_model_creator/MatrixModel/PlaceSymbol.m +++ b/simulink_model_creator/MatrixModel/PlaceSymbol.m @@ -11,10 +11,14 @@ end posVector(depth) = posVector(depth) + 1; currentDepth = 0; +argStart = 0; splitPoint = size(symbolicString, 2); for i = 1:size(symbolicString, 2) if symbolicString(i) == '(' currentDepth = currentDepth + 1; + if argStart == 0 + argStart = i + 1; + end elseif symbolicString(i) == ')' currentDepth = currentDepth - 1; elseif currentDepth == 1 && symbolicString(i) == ',' @@ -22,8 +26,11 @@ for i = 1:size(symbolicString, 2) break; end end -splitString1 = symbolicString(5:(splitPoint - 1)); -splitString2 = symbolicString((splitPoint + 1):(size(symbolicString, 2) - 1)); + +if argStart > 0 + splitString1 = symbolicString(argStart:(splitPoint - 1)); + splitString2 = symbolicString((splitPoint + 1):(size(symbolicString, 2) - 1)); +end if(IsOperator(symbolicString, 'NEG')) blockName = ['Neg' num2str(depth) '_' num2str(height)]; @@ -68,6 +75,12 @@ elseif(IsOperator(symbolicString, 'POW')) set_param([destination '/' blockName], 'Operator', 'pow'); PlaceSymbol(destination, splitString1, depth - 1, [blockName '/1']); PlaceSymbol(destination, splitString2, depth - 1, [blockName '/2']); +elseif(IsOperator(symbolicString, 'TANH')) + blockName = ['Tanh' num2str(depth) '_' num2str(height)]; + add_block('simulink/Math Operations/Trigonometric Function', [destination '/' blockName], 'Position', position); + add_line(destination, [blockName '/1'], connectTo, 'autorouting', 'on'); + set_param([destination '/' blockName], 'Operator', 'tanh'); + PlaceSymbol(destination, splitString1, depth - 1, [blockName '/1']); elseif(IsValidDouble(symbolicString)) blockName = ['Const' num2str(depth) '_' num2str(height)]; add_block('simulink/Sources/Constant', [destination '/' blockName], 'Position', position);