R wrapper for fz core functions using reticulate. This package provides R bindings to the fz Python package, allowing R users to access fz functionality directly from R.
You can install the development version of fz from GitHub with:
# install.packages("devtools")
devtools::install_github("Funz/fz.R")This package requires the fz Python package. You can install it using:
library(fz)
fz_install()Or manually with:
reticulate::py_install("fz")First, check if the fz Python package is available:
library(fz)
# Check if fz is available
if (fz_available()) {
message("fz is ready to use!")
} else {
message("Please install fz with fz_install()")
}The package provides R wrappers for the main fz Python functions:
# Use the core fz functions
result1 <- fz(...) # Main fz function
result2 <- fzi(...) # fzi function
result3 <- fzc(...) # fzc function
result4 <- fzo(...) # fzo function
result5 <- fzd(...) # fzd functionAll functions pass arguments directly to their Python counterparts, maintaining the same API and behavior as the original fz Python package.
The package includes comprehensive examples for working with Modelica models:
# Example 1: Design of Experiments with Bouncing Ball model
fzi(model = "modelica", model_path = "BouncingBall.mo")
fzc(
input = list(h0 = c(1, 10), v0 = c(-2, 2)),
output = "h_max"
)
results <- fzd(design = "LatinHypercube", n = 50)
# Example 2: Optimization of Spring-Mass-Damper system
fzi(model = "modelica", model_path = "SpringMassDamper.mo")
fzc(
input = list(m = c(0.5, 5), k = c(100, 10000), c = c(1, 100)),
output = "settling_time"
)
optimal <- fzo(objective = "minimize", objective_var = "settling_time")
# Example 3: Parameter study for Heat Exchanger
fzi(model = "modelica", model_path = "HeatExchanger.mo")
fzc(
input = list(mdot_hot = c(0.5, 1.5), mdot_cold = c(0.5, 1.5)),
output = c("effectiveness", "Q_total")
)
results <- fzd(design = "FullFactorial")For more detailed examples, see the vignette:
vignette("modelica-examples", package = "fz")- R (>= 3.6.0)
- Python (>= 3.7)
- reticulate package
This package uses:
- reticulate for Python integration
- testthat for unit testing
- GitHub Actions for continuous integration and CRAN checks
- roxygen2 for documentation
devtools::test()devtools::check()Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Please report issues at https://github.com/Funz/fz.R/issues