handy-diffusion 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +103 -0
- package/index.js +11 -0
- package/package.json +2 -1
package/index.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for handy-diffusion
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Set properties for the ADI (Alternating Direction Implicit) method
|
|
7
|
+
* @param width - Grid width
|
|
8
|
+
* @param height - Grid height
|
|
9
|
+
* @param diffusionCoefficient - Diffusion coefficient
|
|
10
|
+
* @param deltaX - Spatial step size
|
|
11
|
+
* @param deltaT - Time step size
|
|
12
|
+
* @param decayRate - Decay rate constant (default: 0)
|
|
13
|
+
*/
|
|
14
|
+
export function setADIProperties(
|
|
15
|
+
width: number,
|
|
16
|
+
height: number,
|
|
17
|
+
diffusionCoefficient: number,
|
|
18
|
+
deltaX: number,
|
|
19
|
+
deltaT: number,
|
|
20
|
+
decayRate?: number
|
|
21
|
+
): void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Solve 2D diffusion equation using ADI method
|
|
25
|
+
* @param concentrationData - Concentration array (width * height)
|
|
26
|
+
* @param sources - Source terms array
|
|
27
|
+
* @param totalNumberOfIterations - Number of time steps
|
|
28
|
+
* @param allowNegativeValues - Whether to allow negative concentrations (default: false)
|
|
29
|
+
*/
|
|
30
|
+
export function ADI(
|
|
31
|
+
concentrationData: Float64Array | number[],
|
|
32
|
+
sources: Float64Array | number[],
|
|
33
|
+
totalNumberOfIterations: number,
|
|
34
|
+
allowNegativeValues?: boolean
|
|
35
|
+
): void;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Set properties for the Crank-Nicolson method (1D)
|
|
39
|
+
* @param length - Number of grid points
|
|
40
|
+
* @param diffusionCoefficient - Diffusion coefficient
|
|
41
|
+
* @param deltaX - Spatial step size
|
|
42
|
+
* @param deltaT - Time step size
|
|
43
|
+
* @param decayRate - Decay rate constant (default: 0)
|
|
44
|
+
*/
|
|
45
|
+
export function setCNProperties(
|
|
46
|
+
length: number,
|
|
47
|
+
diffusionCoefficient: number,
|
|
48
|
+
deltaX: number,
|
|
49
|
+
deltaT: number,
|
|
50
|
+
decayRate?: number
|
|
51
|
+
): void;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Solve 1D diffusion equation using Crank-Nicolson method
|
|
55
|
+
* @param concentrationData - Initial concentration values
|
|
56
|
+
* @param sources - Source terms
|
|
57
|
+
* @param totalNumberOfIterations - Number of time steps
|
|
58
|
+
* @param allowNegativeValues - Whether to allow negative concentrations (default: false)
|
|
59
|
+
*/
|
|
60
|
+
export function CrankNicolson(
|
|
61
|
+
concentrationData: Float64Array | number[],
|
|
62
|
+
sources: Float64Array | number[],
|
|
63
|
+
totalNumberOfIterations: number,
|
|
64
|
+
allowNegativeValues?: boolean
|
|
65
|
+
): void;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Calculate analytic steady-state solution
|
|
69
|
+
* @param WIDTH - Grid width
|
|
70
|
+
* @param HEIGHT - Grid height
|
|
71
|
+
* @param DIFFUSION_RATE - Diffusion rate
|
|
72
|
+
* @param DECAY_RATE - Decay rate
|
|
73
|
+
* @param deltaX - Spatial step size
|
|
74
|
+
* @param sources - Source terms array
|
|
75
|
+
* @param maxMode - Maximum mode for series expansion
|
|
76
|
+
* @returns Steady-state concentration array
|
|
77
|
+
*/
|
|
78
|
+
export function analyticSteadyState(
|
|
79
|
+
WIDTH: number,
|
|
80
|
+
HEIGHT: number,
|
|
81
|
+
DIFFUSION_RATE: number,
|
|
82
|
+
DECAY_RATE: number,
|
|
83
|
+
deltaX: number,
|
|
84
|
+
sources: Float64Array | number[],
|
|
85
|
+
maxMode: number
|
|
86
|
+
): Float64Array;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Calculate effective influence of sources
|
|
90
|
+
* @param width - Grid width
|
|
91
|
+
* @param height - Grid height
|
|
92
|
+
* @param sources - Source terms array
|
|
93
|
+
* @param lambda - Length scale parameter
|
|
94
|
+
* @param scale - Scaling factor
|
|
95
|
+
* @returns Effective influence array
|
|
96
|
+
*/
|
|
97
|
+
export function efectiveInfluence(
|
|
98
|
+
width: number,
|
|
99
|
+
height: number,
|
|
100
|
+
sources: Float64Array | number[],
|
|
101
|
+
lambda: number,
|
|
102
|
+
scale: number
|
|
103
|
+
): Float64Array;
|
package/index.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Import and re-export ADI functions
|
|
2
|
+
export { ADI, setADIProperties } from './ADI.js';
|
|
3
|
+
|
|
4
|
+
// Import and re-export Crank-Nicolson functions
|
|
5
|
+
export { CrankNicolson, setCNProperties } from './CrankNicolson.js';
|
|
6
|
+
|
|
7
|
+
// Import and re-export analytic solution
|
|
8
|
+
export { analyticSteadyState } from './analyticSolution.js';
|
|
9
|
+
|
|
10
|
+
// Import and re-export effective influence
|
|
11
|
+
export { efectiveInfluence } from './effective.js';
|
package/package.json
CHANGED