Numssp
Numssp.jl
is a numerical package for the daily routines of my solid state physics (SSP) experiments.
1. Optimization and Root Finding
Based on the implementation of the WCSCA solver, the following functionality is provided.
1.1 Function Minimization (Root Finding)
minimize!(fn!::Function, lb::NTuple{ND,T}, ub::NTuple{ND,T}[, NP::Int, NR::Int, imax::Int, dmax::T])
where:
fn!
is the objective function to be minimized.lb
andub
are the lower/upper boundaries to define the feasible region to be minimized.NP
is the popuplation size for WCSCA (optional).NR
is the number of splitting in two subpopulations (optional).imax
is the maximum iteration of WCSCA evolution (optional).dmax
is the criterion distance between candidates to start a stagnation treatment (optional).
The objective function fn!
should be defined as:
function fn!(params::Vector{T}) where T
# body ...
end
A simple way to conduct a minimization is:
res = minimize!(fn!, lb, ub)
and use:
res.x
to access the optiomized parameters.res.f
to access the corresponding function value.
1.2 LeastSquare and χ² Curve Fitting
A χ² curve fitting is described as:
, when all of σ
are 1.0
is a leastsqurea curve fitting.
To conduct:
 χ² curve fitting by passing
(xdat, ydat, σdat, lb, ub)
.  leastsquare curve fitting by passing
(xdat, ydat, lb, ub)
.
where
xdat::Vector{T}
is the xraw dataydat::Vector{T}
is the yraw dataσdat::Vector{T}
is the σraw data
Available fitting models are described as below:
MultiExponential Decay
res = decay_fit(xdat, ydat[, σdat], lb, ub)
Gaussian Distribution
res = gauss_fit(xdat, ydat[, σdat], lb, ub)
Lorentzian Distribution
res = lorentz_fit(xdat, ydat[, σdat], lb, ub)
2. Unit Conversion
A functionality of unit conversion, by using
@unit_convert x "unit_1"=>"unit_2"
where x
can be any <:Real
number or AbstractVector{<:Real}
. Currently, the following conversion is provided:
"thz", "nj"
: terahertz <=> nanojoul"thz", "meV"
: terahertz <=> millielectron volt"nm", "nj"
: nanometer <=> nanojoul"nm", "eV"
: nanometer <=> electron volt"cm⁻¹", "nm"
: reciprocal wavelength <=> nanometer"ps", "μm"
: picosecond <=> micrometer
PyPlot
3. Some Customized Function for
For setting of using LaTeX and fontsize:
using PyPlot set_rcParams!(rc, PyPlot.PyDict(PyPlot.matplotlib."rcParams"), fontsize=12)

For setting ticklabels of specific direction:
set_ticklabels!(axis, tick_start, tick_end, tick_step, direction, pad=true)
where
tick_start:tick_step:tick_end
can be bothInt
orFloat64
,direction
should be:x, :y, :z
.If you have used
axis[:set_xticks](..., ...) axis[:set_yticks](..., ...) axis[:set_zticks](..., ...)
then
pad
should be passed byfalse
. 
For saving a pdf format figure:
save_pdf(file_name, fig)