smart_lorentz_gauss 2.0.4 smart_lorentz_gauss: ^2.0.4 copied to clipboard
Provides functionalities to compute mixed Lorentz-Gauss line shapes, also called n-dimensional Pseudo-Voigt function.
// Copyright (c) 2019, Dr. Bruno Guigas. All rights reserved. Use of this source
// code is governed by a BSD-style license that can be found in the LICENSE file.
import 'package:smart_lorentz_gauss/smart_lorentz_gauss.dart';
import 'dart:typed_data';
/// Creates an array containing a mixed Lorentz-Gauss line shape.
main() {
final int NPOINTS = 100; // array length
double height = 100; // value of line shape maximum
double center = 40; // the maximum should be at this position
double width = 10; // width of shape at half height of maximum
Float64List array = Float64List(NPOINTS); // create array
// construct a line shape with 80% Lorentzian and 20% Gaussian fractions
LorentzGauss lg = new LorentzGauss.fromPars(height, [center], [width], [0.2]);
// fill array with line shape values
for (int k = 0; k < NPOINTS; k++) {
array[k] = lg.getValueAt([k.toDouble()]);
}
// print result: you may paste the result to a MS Excel, OpenOffice Calc or so
// to view the shape as a curve.
for (int k = 0; k < NPOINTS; k++) {
print("$k ${array[k].toStringAsFixed(2)}");
}
}