setup_sphere_scene Function

public function setup_sphere_scene(dict) result(array)

setup a test scene with user defined spheres

Arguments

Type IntentOptional Attributes Name
type(toml_table), intent(inout) :: dict

Return Value type(sdf), allocatable, (:)


Source Code

    function setup_sphere_scene(dict) result(array)
    !! setup a test scene with user defined spheres

        use mat_class,         only : invert
        use opticalProperties, only : opticalProp_t, mono
        use sdfs,              only : sdf, sphere, box
        use sdfHelpers,        only : translate
        use random,            only : ranu
        use vector_class,      only : vector

        type(toml_table), intent(inout) :: dict
        type(sdf), allocatable :: array(:)
        
        integer :: num_spheres, i
        real(kind=wp) :: t(4,4), mus, mua, hgg, n, radius
        type(vector) :: pos
        type(opticalProp_t) :: opt(2)

        call get_value(dict, "num_spheres", num_spheres)
        allocate(array(num_spheres+1))

        mus = 1e-17_wp
        mua = 1e-17_wp
        hgg = 0.0_wp
        n   = 1.0_wp

        opt(2) = mono(mus, mua, hgg, n)

        array(num_spheres+1) = box(vector(2._wp, 2._wp, 2._wp), opt(2), num_spheres+1)
        
        mus = 0.0_wp!ranu(1._wp, 50._wp)
        mua = 0.0_wp!ranu(0.01_wp, 1._wp)
        hgg = 0.9_wp
        n = 1.37_wp
        opt(1) = mono(mus, mua, hgg, n)
        do i = 1, num_spheres
            radius = ranu(0.001_wp, 0.25_wp)
            pos = vector(ranu(-1._wp+radius, 1._wp-radius), ranu(-1._wp+radius, 1._wp-radius),&
                        ranu(-1._wp+radius, 1._wp-radius))
            t = invert(translate(pos))

            array(i) = sphere(radius, opt(1), i, transform=t)
        end do

    end function setup_sphere_scene