Learn R Programming

unfoldr (version 0.5.1)

simSpheroidSystem: Simulation of spheroid system

Description

Simulation of Poisson spheroid system

Usage

simSpheroidSystem(theta, lam, size, shape = "const",
  orientation = "rbetaiso", stype = c("prolate", "oblate"), rjoint = NULL,
  box = list(c(0, 1)), mu = c(0, 0, 1), pl = 0, label = "N")

Arguments

theta
simulation parameters
lam
mean number of spheroids per unit volume
size
name of random generating function for size distribution
shape
scalar shape parameter
orientation
name of random generating function for orientation distribution
stype
spheroid type
rjoint
name of joint random generating function
box
simulation box
mu
main orientation axis
pl
optional: print level
label
optional: set a label to all generated spheroids

Value

  • list of spheroids either of class prolate or oblate

Details

The function simulates a Poisson spheroid system according to the supplied simulation parameter theta in a predefined simulation box. The argument size is of type string and denotes the major-axis length random generating function name.

Further the function simulates either stype="prolate" or stype='oblate' spheroids. For the directional orientation of the spheroid's major-axis one has the choice of a uniform (runifdir), isotropic random planar (rbetaiso, see reference) or von Mises-Fisher (rvMisesFisher) distribution. The simulation box is a list containing of vector arguments which correspond to the lower and upper points in each direction. If the argument box has only one element, i.e. list(c(0,1), the same extent is used for the other dimensions. If rjoint names a joint random generating function then argument size is ignored. For the purpose of exact simulation setting size equal to rbinorm declares a bivarite size-shape distribution which leads to a log normal distributed semi-major axis a and a scaled semi-minor axis length c. If $[X,Y]$ follow a bivariate normal distribution with correlation parameter $\rho$ then $a=exp(x)$ defines the sample semi-major axis length together with the scaled semi-minor axis length $c=a*s$ and shape parameter set to $s=1/(1+exp(-y))$. The parameter $\rho$ defines the degree of correlation between the semi-axes lengths which must be provided as part of the list of simulation parameters theta. The method of exact simulation is tailored to the above described model. For a general approach please see the given reference below.

The argument pl denotes the print level of output information during simulation. Currently, only pl=0 for no output and pl>100 for some additional info is implemented.

References

{Ohser, J. and Schladitz, K. 3D images of materials structures Wiley-VCH, 2009} {C. Lantu$\acute{\textrm{e}}$joul. Geostatistical simulation. Models and algorithms. Springer, Berlin, 2002. Zbl 0990.86007}

Examples

Run this code
# directional distribution
rbetaiso <- function(kappa) {
   phi <- runif(1,0,1)*2*pi
   q <- runif(1,0,1)
   theta=acos((1-2*q)/sqrt(kappa*kappa-(1-2*q)*(1-2*q)*(kappa*kappa-1)))
   list("u"=c(sin(theta)*cos(phi),sin(theta)*sin(phi),cos(theta)),
		   "theta"=theta,"phi"=phi)					
}
   
# multivariate size distribution and orientation distribution 
rmulti <- function(m,s,kappa) {	
   dir <- rbetaiso(kappa)
   M <- chol(s, pivot = TRUE)
   M <- M[, order(attr(M, "pivot"))]
   x <- exp(matrix(m,nrow=1) +
          matrix(rnorm(ncol(s)), nrow = 1, byrow = TRUE) %*%M)
   a <- min(x)
   b <- max(x)
   
   list("a"=a,"b"=b,"u"=dir$u,"shape"=a/b,
        "theta"=dir$theta, "phi"=dir$phi)

}

set.seed(1234)
lam <- 1000
sigma <- matrix(c(0.1,0.1,0.1,0.25), ncol=2)
theta <- list("m"=c(-3.0,-2.0),"s"=sigma,"kappa"=0.5)
S <- simSpheroidSystem(theta,lam,rjoint="rmulti",box=list(c(0,5)),pl=101)

# Spheroids with log normal distributed semi-major axis length
# distribution and independent orientation distribution
theta <- list("size"=list("meanlog"=-2.5,"sdlog"=0.5),
              "shape"=list("s"=0.5),
              "orientation"=list("kappa"=1.5))
S <- simSpheroidSystem(theta,lam,size="rlnorm",orientation="rbetaiso",
                       box=list(c(0,5)),pl=101)

# Spheroids of constant sizes
theta <- list("size"=list(0.25),
              "shape"=list("s"=0.5),
              "orientation"=list("kappa"=1))
S <- simSpheroidSystem(theta,lam,size="const",orientation="rbetaiso",
                       box=list(c(0,5)),pl=101)
			   
			   
# Spheroids exact simulation
param <- list("mx"=-1.0,"my"=-2.5, "sdx"=0.15,"sdy"=0.2,"rho"=0.0,"kappa"=1.0)
theta <- list("size"=list("mx"=param$mx,
					      "sdx"=param$sdx,
						  "my"=param$my,
						  "sdy"=param$sdy,
						  "rho"=param$rho),
			  "orientation"=list("kappa"=param$kappa),
			  "shape"=list())

S <- simSpheroidSystem(theta,lam,size="rbinorm",orientation="rbetaiso",box=list(c(0,5)),pl=101)

Run the code above in your browser using DataLab