Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.20251017.0
0.20251022.0
14 changes: 14 additions & 0 deletions src/sed/sedinstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,23 @@ SedInstance::Impl::Impl(const SedDocumentPtr &pDocument)
}
}
}

// Keep track of the issues of all the tasks.

mTasksIssues = mIssues;
} else {
addError("The simulation experiment description does not contain any tasks to run.");
}
}

double SedInstance::Impl::run()
{
// Reset iourselves.

removeAllIssues();

mIssues = mTasksIssues;

// Run all the tasks associated with this instance unless they have some issues.

auto res = 0.0;
Expand All @@ -84,6 +94,10 @@ double SedInstance::Impl::run()

if (task->hasIssues()) {
addIssues(task);

// Reset the issues of the task so that they are not reported again should the instance be run again.

task->pimpl()->removeAllIssues();
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/sed/sedinstance_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SedInstance::Impl: public Logger::Impl
{
public:
SedInstanceTaskPtrs mTasks;
IssuePtrs mTasksIssues;

static SedInstancePtr create(const SedDocumentPtr &pDocument);

Expand Down
20 changes: 10 additions & 10 deletions src/sed/sedinstancetask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,17 @@ void SedInstanceTask::Impl::initialise()
#else
mRuntime->initialiseVariablesForDifferentialModel()(mStates, mRates, mConstants, mComputedConstants, mAlgebraic);
#endif
} else {
#ifdef __EMSCRIPTEN__
mRuntime->initialiseVariablesForAlgebraicModel(mConstants, mComputedConstants, mAlgebraic);
#else
mRuntime->initialiseVariablesForAlgebraicModel()(mConstants, mComputedConstants, mAlgebraic);
#endif
}

applyChanges();
applyChanges();

if (mSedUniformTimeCourse != nullptr) {
#ifdef __EMSCRIPTEN__
mRuntime->computeComputedConstantsForDifferentialModel(mStates, mRates, mConstants, mComputedConstants, mAlgebraic);
mRuntime->computeRates(mVoi, mStates, mRates, mConstants, mComputedConstants, mAlgebraic);
Expand All @@ -174,14 +182,6 @@ void SedInstanceTask::Impl::initialise()
mRuntime->computeVariablesForDifferentialModel()(mVoi, mStates, mRates, mConstants, mComputedConstants, mAlgebraic);
#endif
} else {
#ifdef __EMSCRIPTEN__
mRuntime->initialiseVariablesForAlgebraicModel(mConstants, mComputedConstants, mAlgebraic);
#else
mRuntime->initialiseVariablesForAlgebraicModel()(mConstants, mComputedConstants, mAlgebraic);
#endif

applyChanges();

#ifdef __EMSCRIPTEN__
mRuntime->computeComputedConstantsForAlgebraicModel(mConstants, mComputedConstants, mAlgebraic);
mRuntime->computeVariablesForAlgebraicModel(mConstants, mComputedConstants, mAlgebraic);
Expand Down Expand Up @@ -219,7 +219,7 @@ double SedInstanceTask::Impl::run()
auto startTime = std::chrono::high_resolution_clock::now();

// (Re)initialise our model.
// Note: reinitialise our model in case we are running our model multiple times.
// Note: reinitialise our model because we initialised it when we created the instance task.

initialise();

Expand Down
6 changes: 4 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ include(api/sed/tests.cmake)
include(api/solver/tests.cmake)
include(api/version/tests.cmake)

include(misc/compiler/tests.cmake)
include(misc/tests.cmake)

include(support/cellml/tests.cmake)
include(support/combine/tests.cmake)
Expand Down Expand Up @@ -170,7 +170,9 @@ include_directories(${CMAKE_SOURCE_DIR}/src/misc

foreach(TEST ${TESTS})
if(LIBOPENCOR_UNIT_TESTING)
if(NOT "${${TEST}_CATEGORY}" STREQUAL "")
if("${${TEST}_CATEGORY}" STREQUAL "")
set(TEST_CATEGORY)
else()
set(TEST_CATEGORY "${${TEST}_CATEGORY}_")
endif()

Expand Down
File renamed without changes.
47 changes: 47 additions & 0 deletions tests/misc/failingsimulationtests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright libOpenCOR contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include "tests/utils.h"

#include <libopencor>

TEST(FailingSimulationTest, basic)
{
// Default simulation.

auto file = libOpenCOR::File::create(libOpenCOR::resourcePath("../misc/res/tt04.omex"));
auto document = libOpenCOR::SedDocument::create(file);
auto instance = document->instantiate();

EXPECT_NE(instance->run(), 0.0);
EXPECT_FALSE(instance->hasIssues());

// Set the value of `membrane.test` to zero and rerun the simulation.

auto model = document->model(0);

model->addChange(libOpenCOR::SedChangeAttribute::create("membrane", "test", "0.0"));

EXPECT_EQ(instance->run(), 0.0);
EXPECT_TRUE(instance->hasIssues());

// Remove all changes and rerun the simulation.

model->removeAllChanges();

EXPECT_NE(instance->run(), 0.0);
EXPECT_FALSE(instance->hasIssues());
}
Binary file added tests/misc/res/tt04.omex
Binary file not shown.
7 changes: 4 additions & 3 deletions tests/misc/compiler/tests.cmake → tests/misc/tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set(TEST compiler)
set(TEST misc)

list(APPEND TESTS ${TEST})

set(${TEST}_CATEGORY misc)
set(${TEST}_CATEGORY)
set(${TEST}_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/tests.cpp
${CMAKE_CURRENT_LIST_DIR}/compilertests.cpp
${CMAKE_CURRENT_LIST_DIR}/failingsimulationtests.cpp
)
Loading