Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
5ab46d8
Initial commit for 'manuscript' branch.
dfkapraun Jun 11, 2025
cfcd353
Update draft-pdf.yml
shapiromatron Jun 11, 2025
b2bb1b2
Updated 'paper.md'.
dfkapraun Jun 11, 2025
058f55b
(auto) Paper PDF Draft
dfkapraun Jun 11, 2025
a64a4c4
Updated 'paper.md'.
dfkapraun Jun 11, 2025
fe0ba43
(auto) Paper PDF Draft
dfkapraun Jun 11, 2025
bf1e1b6
Updated 'paper.md'.
dfkapraun Jun 11, 2025
4a22a9b
(auto) Paper PDF Draft
dfkapraun Jun 11, 2025
dc5277d
Updated 'paper.md'.
dfkapraun Jun 11, 2025
fc37f54
Merge branch 'manuscript' of https://github.com/USEPA/MCSimMod into m…
dfkapraun Jun 11, 2025
106e3e6
(auto) Paper PDF Draft
dfkapraun Jun 11, 2025
0fae774
Updated 'paper.md'.
dfkapraun Jun 11, 2025
8b5a189
(auto) Paper PDF Draft
dfkapraun Jun 11, 2025
d0960ee
Updated 'paper.md'.
dfkapraun Jun 11, 2025
160093e
(auto) Paper PDF Draft
dfkapraun Jun 11, 2025
256dbdf
Updated 'paper.bib' with DOIs.
dfkapraun Jun 16, 2025
68ea278
(auto) Paper PDF Draft
dfkapraun Jun 16, 2025
cc76d22
Add RStudio link to README
tjzurlin Jul 18, 2025
e37500b
Updated and renumbered vignettes.
dfkapraun Jul 18, 2025
ec6eca0
Updated _pkgdown.yml
dfkapraun Jul 18, 2025
7b4c7fd
Updated vignette '02_details.Rmd' to conform with styler.
dfkapraun Jul 18, 2025
63bfd84
Renamed vignettes.
dfkapraun Jul 18, 2025
0b25b21
Inlcude link to issues and contact email (will need to be filled in).…
tjzurlin Jul 21, 2025
44fb606
typo in markdown heading
tjzurlin Jul 21, 2025
75f56ec
Include GPL 3.0 license and appropriate link in README
tjzurlin Jul 21, 2025
10fb1e0
Added new vignette 'details.Rmd'.
dfkapraun Jul 21, 2025
5948e5a
Updated vignette 'details.Rmd' using styler.
dfkapraun Jul 22, 2025
c4da53b
Updated vignettes.
dfkapraun Jul 22, 2025
295f855
Used styler to update 'details.Rmd'.
dfkapraun Jul 22, 2025
3eb312d
(auto) Paper PDF Draft
dfkapraun Jul 22, 2025
42520f6
Added vignette 'pbpk_demo.Rmd' to provide an example involving a PBPK…
dfkapraun Jul 23, 2025
87680c1
Updated '_pkgdown.yml' to include the new vignette 'pbpk_demo.Rmd'.
dfkapraun Jul 23, 2025
159d7bb
Modified description file to add URL for documentation web page.
dfkapraun Jul 28, 2025
5e29414
Remove one section from 'pbpk_demo.Rmd'.
dfkapraun Jul 28, 2025
66dd00d
Removed documentation URL from DESCRIPTION file.
dfkapraun Jul 28, 2025
95b7187
Added some lines back to 'pbpk_demo.Rmd'.
dfkapraun Jul 28, 2025
9885551
Added some more lines back to 'pbpk_demo.Rmd'.
dfkapraun Jul 28, 2025
0aa5dff
Removed line with 'loadModel()' from 'pbpk_demo.Rmd'.
dfkapraun Jul 28, 2025
fb4119c
Modified 'compileModel.R' for more complete logging of the model tran…
dfkapraun Jul 28, 2025
fbe23d9
Ran styler::style_pkg().
dfkapraun Jul 28, 2025
08ed74d
Updated 'main.yml' to use 'windows-2025' instead of 'windows-2022'.
dfkapraun Jul 28, 2025
a453bfe
Added debug script to 'main.yml'.
dfkapraun Jul 28, 2025
9798ebd
Updated 'main.yml' to modify testing.
dfkapraun Jul 28, 2025
f694060
Simplified 'pbpk_simple.model' for debugging/testing.
dfkapraun Jul 28, 2025
9900f5e
Ran styler::style_pkg().
dfkapraun Jul 28, 2025
7b4bba5
Removed some lines from 'pbpk_demo.Rmd' for debugging.
dfkapraun Jul 29, 2025
2ae5f20
Removed lines from 'pbpk_simple.model' for debugging.
dfkapraun Jul 29, 2025
e528d58
Updated 'pbpk_demo.Rmd' and 'pbpk_simple.model'.
dfkapraun Jul 29, 2025
72ce6bd
Modified 'main.yml' so that continuous integration checks are only pe…
dfkapraun Jul 29, 2025
feda692
Updated 'paper.md' to explain why users might choose MCSimMod over ex…
dfkapraun Jul 29, 2025
b0de2fa
(auto) Paper PDF Draft
dfkapraun Jul 29, 2025
787c7fc
Edited 'pbpk_demo.Rmd' so that R code chunks are not evaluated. Tranl…
dfkapraun Jul 30, 2025
6f49cd4
Merge branch 'manuscript' of https://github.com/USEPA/MCSimMod into m…
dfkapraun Jul 30, 2025
0c81ce4
Ran styler::style_pkg().
dfkapraun Jul 30, 2025
f139cde
Add R plot figures to vignette 'pbpk_demo.Rmd'.
dfkapraun Jul 30, 2025
6d322a4
Updated 'paper.md' and 'README.md' with new text.
dfkapraun Jul 30, 2025
3c353a0
(auto) Paper PDF Draft
dfkapraun Jul 30, 2025
ca4212d
Updated 'paper.md' and 'paper.bib'.
dfkapraun Jul 31, 2025
2b69acd
(auto) Paper PDF Draft
dfkapraun Jul 31, 2025
3e1cd09
Updated 'DESCRIPTION' file.
dfkapraun Jul 31, 2025
d857c90
Formatted 'DESCRIPTION' file.
dfkapraun Jul 31, 2025
cde83cd
Corrected typographical error in 'details.Rmd'.
dfkapraun Jul 31, 2025
fbfdb75
Corrected a typographical error in 'pbpk_demo.Rmd' and made minor for…
dfkapraun Aug 1, 2025
88d3723
Corrected typographical error in 'newt_cool_demo.Rmd'.
dfkapraun Aug 1, 2025
4ff186c
Minor modifications to three vignettes.
dfkapraun Aug 1, 2025
9eb5cd9
Created an option for writing error and warning messages (from the tr…
dfkapraun Oct 20, 2025
8fe92a8
Update R/createModel.R
dfkapraun Oct 20, 2025
5a2691c
Update R/MCSim_model.R
dfkapraun Oct 20, 2025
17f72a2
Update R/MCSim_model.R
dfkapraun Oct 20, 2025
cc83597
Minor corrections to documentation strings.
dfkapraun Oct 20, 2025
79d1562
Increase timeout for one GitHub action job defined in 'main.yml'.
dfkapraun Oct 20, 2025
f9d5f99
Update .github/workflows/main.yml
dfkapraun Oct 20, 2025
3f0f94a
Removed timeout statement from 'main.yml'.
dfkapraun Oct 20, 2025
39f05ed
Changed required version of 'styler' package to 1.11.0.
dfkapraun Oct 20, 2025
4ef3dd9
Update draft-pdf.yml
dfkapraun Nov 5, 2025
5caf415
Update draft-pdf.yml
dfkapraun Nov 5, 2025
eb37e2a
Resolved merge conflicts.
Nov 5, 2025
997d4b2
Updated 'test-compileModel.R' to reflect changes to model translation…
Nov 6, 2025
0910c35
Added timeout statement to 'main.yml' (where it had been removed prev…
dfkapraun Nov 17, 2025
8fe3d55
Modified syntax for timeout statement in 'main.yml'.
dfkapraun Nov 17, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/draft-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ jobs:
# message: '(auto) Paper PDF Draft'
# # This should be the path to the paper within your repo.
# add: 'paper/paper.pdf'

1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:

check:
runs-on: ${{ matrix.config.os }}
timeout-minutes: 30 # Set timeout for this job to 30 minutes
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
strategy:
fail-fast: false
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ MCSimMod.Rproj
*.dll
*.so
*.html
*.DS_Store

mcsimmod_*.model

Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: MCSimMod
Title: Working with 'MCSim' Models
Version: 1.0
Version: 1.0.9000
Authors@R: c(
person("Dustin F.", "Kapraun", role=c("aut", "cre"), email = "kapraun.dustin@epa.gov", comment = c(ORCID = "0000-0001-5570-6383")),
person("Todd J.", "Zurlinden", role="aut", comment = c(ORCID = "0000-0003-1372-3913")),
Expand All @@ -26,7 +26,7 @@ Suggests:
testthat (>= 3.0.0)
Config/Needs/dev:
devtools,
styler (== 1.10.3),
styler (== 1.11.0),
testthat,
covr
Config/Needs/website:
Expand Down
7 changes: 4 additions & 3 deletions R/MCSim_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ Model <- setRefClass("Model",
#' @field parms Named vector of parameter values for the associated MCSim model.
#' @field Y0 Named vector of initial conditions for the state variables of the associated MCSim model.
#' @field paths List of character strings that are names of files associated with the model.
#' @field writeTemp Boolean specifying whether to write model files to a temporary directory. If value is TRUE, model files will be Written to a temporary directory; if value is FALSE, model files will be Written to the same directory that contains the model specification file.
#' @field writeTemp Boolean specifying whether to write model files to a temporary directory. If value is TRUE, model files will be written to a temporary directory; if value is FALSE, model files will be written to the same directory that contains the model specification file.
#' @field verboseOutput Boolean specifying whether to write translator messages to standard output. If value is TRUE, messages will be written to standard output; if value is FALSE, messages will be written to files in a temporary directory.
mName = "character", mString = "character", initParms = "function",
initStates = "function", Outputs = "ANY", parms = "numeric", Y0 = "numeric",
paths = "list", writeTemp = "logical"
paths = "list", writeTemp = "logical", verboseOutput = "logical"
),
methods = list(
initialize = function(...) {
Expand Down Expand Up @@ -97,7 +98,7 @@ Model <- setRefClass("Model",
# specification file has been changed since the last translation and
# compiling.
if (!file.exists(paths$dll_file) | (force) | (!hash_exists) | (hash_exists & hash_has_changed)) {
compileModel(paths$model_file, paths$c_file, paths$dll_name, paths$dll_file, hash_file = paths$hash_file)
compileModel(paths$model_file, paths$c_file, paths$dll_name, paths$dll_file, hash_file = paths$hash_file, verbose_output = verboseOutput)
}

# Load the compiled model (DLL).
Expand Down
64 changes: 44 additions & 20 deletions R/compileModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#' @param dll_name Name of a DLL or SO file without the extension (".dll" or ".so").
#' @param dll_file Name of the same DLL or SO file with the appropriate extension (".dll" or ".so").
#' @param hash_file Name of a file containing a hash key for determining if `model_file` has changed since the previous translation and compilation.
#' @param verbose_output Boolean specifying whether to write translator messages to standard output. If value is TRUE, messages will be written to standard output; if value is FALSE, messages will be written to files in a temporary directory.
#' @returns No return value. Creates files and saves them in locations specified by function arguments.
#' @import tools
#' @useDynLib MCSimMod, .registration=TRUE
#' @export
compileModel <- function(model_file, c_file, dll_name, dll_file, hash_file = NULL) {
compileModel <- function(model_file, c_file, dll_name, dll_file, hash_file = NULL, verbose_output = FALSE) {
# Unload DLL if it has been loaded.
if (is.loaded("derivs", PACKAGE = dll_name)) {
dyn.unload(dll_file)
Expand All @@ -34,38 +35,61 @@ compileModel <- function(model_file, c_file, dll_name, dll_file, hash_file = NUL
mod_output <- paste(mod_output, collapse = "\n")

# Save the translator output to a file.
temp_directory <- tempdir()
out_file <- file.path(temp_directory, "mod_output.txt")
write(mod_output, file = out_file)
if (!verbose_output) {
temp_directory <- tempdir()
out_file <- file.path(temp_directory, "mod_output.txt")
write(mod_output, file = out_file)
}

# Check to see if there was an error during translation. If so, print a
# message about the location of the translation log file and stop execution.
# message about where to find full details and stop execution.
if (grepl("*** Error:", mod_output, fixed = TRUE)) {
stop(
"An error was identified when translating the MCSim model specification ",
"text to C. Full details are available in the file ",
normalizePath(out_file), "."
)
if (verbose_output) {
stop(
"An error was identified when translating the MCSim model ",
"specification text to C. Full details follow.\n", mod_output
)
} else {
stop(
"An error was identified when translating the MCSim model ",
"specification text to C. Full details are available in the file ",
normalizePath(out_file), "."
)
}
}

# Check to see if there was a warning during translation. If so, print a
# message about the location of the translation log file and raise a warning.
else if (grepl("*** Warning:", mod_output, fixed = TRUE)) {
warning(
"A warning was identified when translating the MCSim model ",
"specification text to C. Full details are available in the file ",
normalizePath(out_file), ".\n"
)
if (verbose_output) {
warning(
"A warning was generated when translating the MCSim model ",
"specification text to C. Full details follow.\n", mod_output
)
} else {
warning(
"A warning was generated when translating the MCSim model ",
"specification text to C. Full details are available in the file ",
normalizePath(out_file), ".\n"
)
}
}

# If there was no error or warning during translation, just print a message
# about the location of the translation log file.
else {
message(
"Translation of model specification text complete. Full details are ",
"available in the file ",
normalizePath(out_file), ".\n"
)
if (verbose_output) {
message(
"Translation of model specification text complete. Full details ",
"follow.\n", mod_output
)
} else {
message(
"Translation of model specification text complete. Full details are ",
"available in the file ",
normalizePath(out_file), ".\n"
)
}
}

# Compile the C model to obtain an object file (ending with ".o") and a
Expand Down
5 changes: 3 additions & 2 deletions R/createModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
#' @param mName Name of an MCSim model specification file, excluding the file name extension `.model`.
#' @param mString A character string containing MCSim model specification text.
#' @param writeTemp Boolean specifying whether to write model files to a temporary directory. If value is TRUE (the default), model files will be Written to a temporary directory; if value is FALSE, model files will be Written to the same directory that contains the model specification file.
#' @param verboseOutput Boolean specifying whether to write translator messages to standard output. If value is TRUE, messages will be written to standard output; if value is FALSE, messages will be written to files in a temporary directory.
#' @returns Model object.
#' @export
createModel <- function(mName = character(0), mString = character(0), writeTemp = TRUE) {
return(Model(mName = mName, mString = mString, writeTemp = writeTemp))
createModel <- function(mName = character(0), mString = character(0), writeTemp = TRUE, verboseOutput = FALSE) {
return(Model(mName = mName, mString = mString, writeTemp = writeTemp, verboseOutput = verboseOutput))
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ R -e "covr::report(file = 'coverage_html/index.html')"
## Code Formatting
To maintain a consistent format for all `MCSimMod` source code, we use the [styler](https://styler.r-lib.org/) package to format R code. Note that we use a specific version of the package.
```R
# Install version 1.10.3 of the styler package.
install.packages("styler", version = "1.10.3")
# Install version 1.11.0 of the styler package.
install.packages("styler", version = "1.11.0")

# Apply styler format conventions to all files in the package.
styler::style_pkg(".")
Expand Down
4 changes: 3 additions & 1 deletion man/Model-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion man/compileModel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion man/createModel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-compileModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ testthat::test_that("compileModel::warning", {
model <- createModel(mString = modelString)
testthat::expect_warning(
model$loadModel(),
"A warning was identified when translating the MCSim model specification"
"A warning was generated when translating the MCSim model specification"
)
})