-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor VCellStoch into separate lib/exe, add unit test
- Loading branch information
Showing
20 changed files
with
213 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
cmake_minimum_required (VERSION 3.0) | ||
project(MovingBoundaryTest) | ||
set (CMAKE_CXX_STANDARD 11) | ||
cmake_policy(SET CMP0046 OLD) | ||
enable_testing() | ||
|
||
set(SRC_FILES | ||
statstest.cpp | ||
) | ||
|
||
file(GLOB HDR_FILES *h) | ||
|
||
set(EXE_FILE Test TestVCellStoch) | ||
|
||
set_source_files_properties( ${SRC_FILES} PROPERTIES LANGUAGE CXX) | ||
|
||
message(STATUS "HDF5 VERSION IS ${HDF5_VERSION}, LIBS = ${HDF5_LIBRARIES}, HL_LIBS = ${HDF5_HL_LIBRARIES}") | ||
|
||
add_executable(TestVCellStoch ${SRC_FILES} ${HDR_FILES}) | ||
add_dependencies(TestVCellStoch VCellStochLib gtest) | ||
target_link_libraries(TestVCellStoch VCellStochLib GTest::gtest_main) | ||
install(TARGETS TestVCellStoch | ||
RUNTIME DESTINATION bin) | ||
|
||
include(GoogleTest) | ||
gtest_discover_tests(TestVCellStoch) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// | ||
// Created by Jim Schaff on 4/25/23. | ||
// | ||
#include <stdexcept> | ||
#include "gtest/gtest.h" | ||
#include "../VCellStoch/include/Gibson.h" | ||
#include <iostream> | ||
#include <cstdio> | ||
|
||
const char* input_file_contents = R"INPUT_FILE( | ||
<control> | ||
STARTING_TIME 0.0 | ||
ENDING_TIME 20.0 | ||
TOLERANCE 1.0E-9 | ||
SAVE_PERIOD 0.02 | ||
MAX_SAVE_POINTS 1001.0 | ||
NUM_TRIAL 50000 | ||
SEED 566564762 | ||
BMULTIBUTNOTHISTO 1 | ||
</control> | ||
<model> | ||
<discreteVariables> | ||
TotalVars 3 | ||
s0_Count 1 | ||
s1_Count 0 | ||
s2_Count 1 | ||
</discreteVariables> | ||
<jumpProcesses> | ||
TotalProcesses 2 | ||
r0 | ||
r0_reverse | ||
</jumpProcesses> | ||
<processDesc> | ||
TotalDescriptions 2 | ||
JumpProcess r0 | ||
Propensity (0.9996443474639611 * s0_Count * s2_Count) | ||
Effect 3 | ||
s0_Count inc -1.0 | ||
s2_Count inc -1.0 | ||
s1_Count inc 1.0 | ||
DependentProcesses 0 | ||
JumpProcess r0_reverse | ||
Propensity 0.0 | ||
Effect 3 | ||
s0_Count inc 1.0 | ||
s2_Count inc 1.0 | ||
s1_Count inc -1.0 | ||
DependentProcesses 1 | ||
r0 | ||
</processDesc> | ||
</model> | ||
)INPUT_FILE"; | ||
|
||
|
||
TEST(statstest,test1) { | ||
std::string temp_input_file_name = std::tmpnam(nullptr); | ||
std::ofstream input_file (temp_input_file_name); | ||
bool bWroteFile = false; | ||
if (input_file.is_open()){ | ||
input_file << input_file_contents; | ||
input_file.close(); | ||
bWroteFile = true; | ||
} | ||
ASSERT_TRUE(bWroteFile); | ||
|
||
std::string temp_output_file_name = std::tmpnam(nullptr); | ||
|
||
Gibson *gb= new Gibson(temp_input_file_name.c_str(), temp_output_file_name.c_str()); | ||
gb->march(); | ||
delete gb; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
//#define DEBUG //enable it when debug is needed. | ||
#include <limits> | ||
#include <stdexcept> | ||
#include "Gibson.h" | ||
#include "../include/Gibson.h" | ||
#ifdef __APPLE__ | ||
#include "/usr/local/opt/[email protected]/include/hdf5.h" | ||
#else | ||
|
@@ -32,14 +32,14 @@ using namespace std; | |
#include <sys/types.h> | ||
#include <sys/timeb.h> | ||
#include <time.h> | ||
#include "Jump.h" | ||
#include "StochVar.h" | ||
#include "IndexedTree.h" | ||
#include "../include/Jump.h" | ||
#include "../include/StochVar.h" | ||
#include "../include/IndexedTree.h" | ||
|
||
#ifdef USE_MESSAGING | ||
#include <VCELL/SimulationMessaging.h> | ||
#endif | ||
#include <VCellException.h> | ||
#include "VCellException.h" | ||
const double double_infinity = numeric_limits<double>::infinity(); | ||
const double EPSILON = 1E-12; | ||
const string Gibson::MY_T_STR = "t"; | ||
|
@@ -61,7 +61,7 @@ Gibson::Gibson() | |
*Input para: srting, the input file(name), where the model info. is read. | ||
* string, the output file(name), where the results are saved. | ||
*/ | ||
Gibson::Gibson(char* arg_infilename, char* arg_outfilename) | ||
Gibson::Gibson(const char* arg_infilename, const char* arg_outfilename) | ||
:StochModel(), | ||
savedSampleCount(1), | ||
lastTime (std::numeric_limits<long>::min( )) | ||
|
2 changes: 1 addition & 1 deletion
2
Stochastic/VCellStoch/IndexedTree.cpp → Stochastic/VCellStoch/src/IndexedTree.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
Stochastic/VCellStoch/Jump.cpp → Stochastic/VCellStoch/src/Jump.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.