Documentation
¶
Index ¶
- Constants
- Variables
- func Cab1DViewAll(view *View)
- func CenterF(c math32.Vector3) math32.Vector3
- func CenterFull(c math32.Vector3i) math32.Vector3i
- func CenterI(c math32.Vector3i) math32.Vector3i
- func CoordToFloat(c math32.Vector3i) math32.Vector3
- func CoordToInt(c math32.Vector3) math32.Vector3i
- func Curl18(x, y, z, vidx, tidx int32, cx, cy, cz *float32)
- func DiracKernel(i uint32)
- func Divergence18(x, y, z, vidx, tidx int32, dx, dy, dz *float32) float32
- func EdgeInBounds0(x, y, z, sx, sy, sz int32) bool
- func EdgeInBounds1(x, y, z, sx, sy, sz int32) bool
- func EdgesWrapKernel(i uint32)
- func FormDialog(ctx core.Widget, v any, title string)
- func GPUInit()
- func GPURelease()
- func GetParticleAt(idx int32) (lorentz, esq float32, pos math32.Vector3i, vel math32.Vector3)
- func GetRandomNumber(index uint32, counter uint64, funIndex uint32) float32
- func Gradient18(x, y, z, vidx, tidx int32, dx, dy, dz *float32)
- func KleinGordonCDampKernel(i uint32)
- func KleinGordonCKernel(i uint32)
- func KleinGordonDampKernel(i uint32)
- func KleinGordonKernel(i uint32)
- func Laplacian1D(x, y, z, vidx, tidx int32, ctr float32) float32
- func Laplacian26(x, y, z, vidx, tidx int32, ctr float32) float32
- func LaplacianEdge1D(x, y, z, sx, sy, sz, vidx, tidx int32, ctr float32) float32
- func LaplacianEdge26(x, y, z, sx, sy, sz, vidx, tidx int32, ctr float32) float32
- func MaxwellDampKernel(i uint32)
- func MaxwellKernel(i uint32)
- func NeighAverage27(x, y, z, vidx, tidx int32) float32
- func NeighMax26(x, y, z, vidx, tidx int32) int32
- func NeighValue(nidx, x, y, z, vidx, tidx int32) float32
- func PotentialEnergy1D(x, y, z, vidx, tidx int32, ctr float32) float32
- func PotentialEnergy26(x, y, z, vidx, tidx int32, ctr float32) float32
- func ReadFromGPU(vars ...GPUVars)
- func RunDiracKernel(n int)
- func RunDiracKernelCPU(n int)
- func RunDiracKernelGPU(n int)
- func RunDone(syncVars ...GPUVars)
- func RunEdgesWrapKernel(n int)
- func RunEdgesWrapKernelCPU(n int)
- func RunEdgesWrapKernelGPU(n int)
- func RunGPUSync()
- func RunKleinGordonCDampKernel(n int)
- func RunKleinGordonCDampKernelCPU(n int)
- func RunKleinGordonCDampKernelGPU(n int)
- func RunKleinGordonCKernel(n int)
- func RunKleinGordonCKernelCPU(n int)
- func RunKleinGordonCKernelGPU(n int)
- func RunKleinGordonDampKernel(n int)
- func RunKleinGordonDampKernelCPU(n int)
- func RunKleinGordonDampKernelGPU(n int)
- func RunKleinGordonKernel(n int)
- func RunKleinGordonKernelCPU(n int)
- func RunKleinGordonKernelGPU(n int)
- func RunMaxwellDampKernel(n int)
- func RunMaxwellDampKernelCPU(n int)
- func RunMaxwellDampKernelGPU(n int)
- func RunMaxwellKernel(n int)
- func RunMaxwellKernelCPU(n int)
- func RunMaxwellKernelGPU(n int)
- func RunOneDiracKernel(n int, syncVars ...GPUVars)
- func RunOneEdgesWrapKernel(n int, syncVars ...GPUVars)
- func RunOneKleinGordonCDampKernel(n int, syncVars ...GPUVars)
- func RunOneKleinGordonCKernel(n int, syncVars ...GPUVars)
- func RunOneKleinGordonDampKernel(n int, syncVars ...GPUVars)
- func RunOneKleinGordonKernel(n int, syncVars ...GPUVars)
- func RunOneMaxwellDampKernel(n int, syncVars ...GPUVars)
- func RunOneMaxwellKernel(n int, syncVars ...GPUVars)
- func RunOneSchrodingerKernel(n int, syncVars ...GPUVars)
- func RunOneSpinfieldKernel(n int, syncVars ...GPUVars)
- func RunOneWaveDampKernel(n int, syncVars ...GPUVars)
- func RunOneWaveKernel(n int, syncVars ...GPUVars)
- func RunSchrodingerKernel(n int)
- func RunSchrodingerKernelCPU(n int)
- func RunSchrodingerKernelGPU(n int)
- func RunSpinfieldKernel(n int)
- func RunSpinfieldKernelCPU(n int)
- func RunSpinfieldKernelGPU(n int)
- func RunWaveDampKernel(n int)
- func RunWaveDampKernelCPU(n int)
- func RunWaveDampKernelGPU(n int)
- func RunWaveKernel(n int)
- func RunWaveKernelCPU(n int)
- func RunWaveKernelGPU(n int)
- func SchrodingerKernel(i uint32)
- func SetParticleAt(idx int32, lorentz, esq float32, pos math32.Vector3i, vel math32.Vector3)
- func SpinfieldKernel(i uint32)
- func SpinfieldViewAll(view *View)
- func StateSum(sz math32.Vector3i, vr enums.Enum, curPrv int32) float64
- func SyncFromGPU(vars ...GPUVars)
- func ToGPU(vars ...GPUVars)
- func ToGPUTensorStrides()
- func Wave1DViewAll(view *View)
- func WaveDampKernel(i uint32)
- func WaveKernel(i uint32)
- func WavePacket(x, d, wavelength, width, phase, amp float32) float32
- type CabStates
- func (i CabStates) Desc() string
- func (i CabStates) Int64() int64
- func (i CabStates) MarshalText() ([]byte, error)
- func (i *CabStates) SetInt64(in int64)
- func (i *CabStates) SetString(s string) error
- func (i CabStates) String() string
- func (i *CabStates) UnmarshalText(text []byte) error
- func (i CabStates) Values() []enums.Enum
- type Config
- type Context
- func (ctx *Context) EdgeCoords(idx uint32, x, y, z *int32) int32
- func (ctx *Context) EdgeCoordsWrap(idx uint32, x, y, z, xs, ys, zs *int32) int32
- func (ctx *Context) EdgesN() int32
- func (ctx *Context) Init()
- func (ctx *Context) PrevState() int32
- func (ctx *Context) SizeFull() math32.Vector3i
- func (ctx *Context) SizePlus1() math32.Vector3i
- func (ctx *Context) StateCoords(idx uint32, x, y, z *int32) bool
- func (ctx *Context) StepInc()
- type CurPrev
- func (i CurPrev) Desc() string
- func (i CurPrev) Int64() int64
- func (i CurPrev) MarshalText() ([]byte, error)
- func (i *CurPrev) SetInt64(in int64)
- func (i *CurPrev) SetString(s string) error
- func (i CurPrev) String() string
- func (i *CurPrev) UnmarshalText(text []byte) error
- func (i CurPrev) Values() []enums.Enum
- type CurPrevBoth
- func (i CurPrevBoth) Desc() string
- func (i CurPrevBoth) Int64() int64
- func (i CurPrevBoth) MarshalText() ([]byte, error)
- func (i *CurPrevBoth) SetInt64(in int64)
- func (i *CurPrevBoth) SetString(s string) error
- func (i CurPrevBoth) String() string
- func (i *CurPrevBoth) UnmarshalText(text []byte) error
- func (i CurPrevBoth) Values() []enums.Enum
- type DiracStates
- func (i DiracStates) Desc() string
- func (i DiracStates) Int64() int64
- func (i DiracStates) MarshalText() ([]byte, error)
- func (i *DiracStates) SetInt64(in int64)
- func (i *DiracStates) SetString(s string) error
- func (i DiracStates) String() string
- func (i *DiracStates) UnmarshalText(text []byte) error
- func (i DiracStates) Values() []enums.Enum
- type EMStates
- func (i EMStates) Desc() string
- func (i EMStates) Int64() int64
- func (i EMStates) MarshalText() ([]byte, error)
- func (i *EMStates) SetInt64(in int64)
- func (i *EMStates) SetString(s string) error
- func (i EMStates) String() string
- func (i *EMStates) UnmarshalText(text []byte) error
- func (i EMStates) Values() []enums.Enum
- type Edges
- type Equations
- func (i Equations) Desc() string
- func (i Equations) Int64() int64
- func (i Equations) MarshalText() ([]byte, error)
- func (i *Equations) SetInt64(in int64)
- func (i *Equations) SetString(s string) error
- func (i Equations) String() string
- func (i *Equations) UnmarshalText(text []byte) error
- func (i Equations) Values() []enums.Enum
- type GPUVars
- func (i GPUVars) Desc() string
- func (i GPUVars) Int64() int64
- func (i GPUVars) MarshalText() ([]byte, error)
- func (i *GPUVars) SetInt64(in int64)
- func (i *GPUVars) SetString(s string) error
- func (i GPUVars) String() string
- func (i *GPUVars) UnmarshalText(text []byte) error
- func (i GPUVars) Values() []enums.Enum
- type GUI
- func (gui *GUI) AddView(tabName string) *View
- func (gui *GUI) FinalizeGUI(closePrompt bool)
- func (gui *GUI) GoUpdateWindow()
- func (gui *GUI) IsRunning() bool
- func (gui *GUI) MakeBody(b tree.Node, sim *Sim, fsroot fs.FS, appname, title, about string)
- func (gui *GUI) MakeToolbar(p *tree.Plan)
- func (gui *GUI) SetStopNow()
- func (gui *GUI) StartRun()
- func (gui *GUI) StopNow() bool
- func (gui *GUI) Stopped()
- func (gui *GUI) UpdateWindow()
- type MinusPlusOne
- func (i MinusPlusOne) Desc() string
- func (i MinusPlusOne) Int64() int64
- func (i MinusPlusOne) MarshalText() ([]byte, error)
- func (i *MinusPlusOne) SetInt64(in int64)
- func (i *MinusPlusOne) SetString(s string) error
- func (i MinusPlusOne) String() string
- func (i *MinusPlusOne) UnmarshalText(text []byte) error
- func (i MinusPlusOne) Values() []enums.Enum
- type NPanels
- func (i NPanels) Desc() string
- func (i NPanels) Int64() int64
- func (i NPanels) MarshalText() ([]byte, error)
- func (np NPanels) N() int
- func (i *NPanels) SetInt64(in int64)
- func (i *NPanels) SetString(s string) error
- func (i NPanels) String() string
- func (i *NPanels) UnmarshalText(text []byte) error
- func (i NPanels) Values() []enums.Enum
- type NeighWeights
- func (i NeighWeights) Desc() string
- func (i NeighWeights) Int64() int64
- func (i NeighWeights) MarshalText() ([]byte, error)
- func (i *NeighWeights) SetInt64(in int64)
- func (i *NeighWeights) SetString(s string) error
- func (i NeighWeights) String() string
- func (i *NeighWeights) UnmarshalText(text []byte) error
- func (i NeighWeights) Values() []enums.Enum
- type PanelView
- type Parameters
- type ParticleVars
- func (i ParticleVars) Desc() string
- func (i ParticleVars) Int64() int64
- func (i ParticleVars) MarshalText() ([]byte, error)
- func (i *ParticleVars) SetInt64(in int64)
- func (i *ParticleVars) SetString(s string) error
- func (i ParticleVars) String() string
- func (i *ParticleVars) UnmarshalText(text []byte) error
- func (i ParticleVars) Values() []enums.Enum
- type PlaneMesh
- func (pm *PlaneMesh) MeshSize() (nVtx, nIndex int, hasColor bool)
- func (pm *PlaneMesh) Set(vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32)
- func (pm *PlaneMesh) SetBars(vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32)
- func (pm *PlaneMesh) SetPlane(vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32)
- type PlaneObj
- type Scene
- type Settings
- type Sim
- func (ss *Sim) AddStat(fun func(init bool))
- func (ss *Sim) ConfigGUI(b tree.Node)
- func (ss *Sim) ConfigSim()
- func (ss *Sim) ConfigState()
- func (ss *Sim) ConfigVars()
- func (ss *Sim) CopyCurToPrev()
- func (ss *Sim) DiracConfig()
- func (ss *Sim) Gauss(vr enums.Enum, ctr math32.Vector3, width, amp, off float32)
- func (ss *Sim) Init()
- func (ss *Sim) InitRandSeed(run int)
- func (ss *Sim) InvR(vr enums.Enum, ctr math32.Vector3, val float32)
- func (ss *Sim) InvRDrive(vr enums.Enum, ctr math32.Vector3, decay float32)
- func (ss *Sim) KleinGordonCConfig()
- func (ss *Sim) KleinGordonConfig()
- func (ss *Sim) MaxwellConfig()
- func (ss *Sim) MovingWavePacket(posVar, velVar enums.Enum, dim math32.Dims, ctr math32.Vector3, ...)
- func (ss *Sim) MovingWavePacketConfig(posVar, velVar enums.Enum, dim math32.Dims, ctr math32.Vector3, ...)
- func (ss *Sim) OpenState(filename fsx.Filename) error
- func (ss *Sim) ParticleAt(c math32.Vector3i, pvel math32.Vector3, partType float32)
- func (ss *Sim) ParticleAtConfig(c math32.Vector3i, partType float32)
- func (ss *Sim) ParticleField(c math32.Vector3i, width float32)
- func (ss *Sim) ParticleStats()
- func (ss *Sim) Point(vr enums.Enum, curPrev CurPrevBoth, c math32.Vector3i, val float32)
- func (ss *Sim) PosWavePacket(vr enums.Enum, dim math32.Dims, ctr math32.Vector3, ...)
- func (ss *Sim) PosWavePacketConfig(vr enums.Enum, dim math32.Dims, ctr math32.Vector3, dir, phase, amp float32)
- func (ss *Sim) Run()
- func (ss *Sim) RunNoGUI()
- func (ss *Sim) RunStats(init bool)
- func (ss *Sim) SaveState(filename fsx.Filename) error
- func (ss *Sim) SchrodingerConfig()
- func (ss *Sim) SchrodingerStats()
- func (ss *Sim) Sine(vr enums.Enum, dim math32.Dims, wavelength, phase, amp, off float32)
- func (ss *Sim) SpinfieldConfig()
- func (ss *Sim) SpinfieldStats()
- func (ss *Sim) StatParticle(idx int) func(init bool)
- func (ss *Sim) StatStep() func(init bool)
- func (ss *Sim) StatSum(vr enums.Enum) func(init bool)
- func (ss *Sim) StepN(n int)
- func (ss *Sim) StepRun()
- func (ss *Sim) Stopped()
- func (ss *Sim) UpdateUnits()
- func (ss *Sim) UpdateView()
- func (ss *Sim) ViewInit(fun func(view *View))
- func (ss *Sim) WaveConfig()
- func (ss *Sim) WaveStats()
- type SpinfieldStates
- func (i SpinfieldStates) Desc() string
- func (i SpinfieldStates) Int64() int64
- func (i SpinfieldStates) MarshalText() ([]byte, error)
- func (i *SpinfieldStates) SetInt64(in int64)
- func (i *SpinfieldStates) SetString(s string) error
- func (i SpinfieldStates) String() string
- func (i *SpinfieldStates) UnmarshalText(text []byte) error
- func (i SpinfieldStates) Values() []enums.Enum
- type Units
- type VarSettinger
- type VarSettings
- type View
- func (vw *View) GetVarSettings(vr enums.Enum) (*VarSettings, error)
- func (vw *View) GetVarSettingsPanel(panelNo int) (*VarSettings, error)
- func (vw *View) GoUpdateView()
- func (vw *View) Init()
- func (vw *View) MakeToolbar(p *tree.Plan)
- func (vw *View) MakeViewbar(p *tree.Plan)
- func (vw *View) MoveStart(mv math32.Vector3i)
- func (vw *View) PlaneAtNumber(no int) *xyz.Group
- func (vw *View) Planes() *xyz.Group
- func (vw *View) RebuildView()
- func (vw *View) SceneXYZ() *xyz.Scene
- func (vw *View) SelectCamera(camNo int)
- func (vw *View) SetCounters(ctrs string)
- func (vw *View) SetCurPrev(curprv CurPrev, panelNo int)
- func (vw *View) SetMode(mode ViewModes, panelNo int)
- func (t *View) SetPanels(v [4]PanelView) *View
- func (t *View) SetSettings(v Settings) *View
- func (t *View) SetSize(v math32.Vector3i) *View
- func (t *View) SetStart(v math32.Vector3i) *View
- func (vw *View) SetVar(vr enums.Enum, panelNo int)
- func (vw *View) SetVarMinMax(vr enums.Enum, mn, mx float32)
- func (t *View) SetVarSettings(v map[enums.Enum]*VarSettings) *View
- func (vw *View) UpdateImpl()
- func (vw *View) UpdatePlanes()
- func (vw *View) UpdateView()
- func (vw *View) ValColor(raw float32, panelNo int) (scaled float32, clr color.RGBA)
- func (vw *View) VarsListUpdate()
- func (vw *View) ViewDefaults(se *xyz.Scene)
- func (vw *View) ZoomInSize(n int32)
- func (vw *View) ZoomOutSize(n int32)
- type ViewModes
- func (i ViewModes) Desc() string
- func (i ViewModes) Int64() int64
- func (i ViewModes) MarshalText() ([]byte, error)
- func (i *ViewModes) SetInt64(in int64)
- func (i *ViewModes) SetString(s string) error
- func (i ViewModes) String() string
- func (i *ViewModes) UnmarshalText(text []byte) error
- func (i ViewModes) Values() []enums.Enum
- type WaveStates
- func (i WaveStates) Desc() string
- func (i WaveStates) Int64() int64
- func (i WaveStates) MarshalText() ([]byte, error)
- func (i *WaveStates) SetInt64(in int64)
- func (i *WaveStates) SetString(s string) error
- func (ws WaveStates) SetVarSettings(vs *VarSettings)
- func (i WaveStates) String() string
- func (i *WaveStates) UnmarshalText(text []byte) error
- func (i WaveStates) Values() []enums.Enum
Constants ¶
const ( // Average27Sum is the sum of the AverageWts Average27Sum = float32(20.104084) // OneoAverage27Sum is 1.0/ sum of the AverageWts, for actual averaging OneoAverage27Sum = 0.049741138 )
const ( Pi = 3.14159265358979323846264338327950288419716939937510582097494459 TwoPi = 2 * Pi InvTwoPi = 1.0 / TwoPi )
The following are constants used across many equations.
const ( // C is the speed of light, m/s C = 299792458.0 // Hbar is the normalized Planck constant h / (2 Pi) = J s = m^2 kg / s Hbar = 1.054571628e-34 // E is the unit of electrical charge: C = A s E = 1.602176487e-19 // EMass is the electron rest mass kg EMass = 9.10938215e-31 // Mu0 is the magnetic constant, permeability of free space // N/A^2 = (m kg) / (s^2 A^2) Mu0 = 4.0 * math32.Pi * 1e-7 // Eps0 is the electric constant, permittivity of free space = 1 / (mu0 c^2) // F/m = (s^4 A^2) / (m^3 kg) Eps0 = 1.0 / (Mu0 * C * C) // Alpha is the fine structure constant: e^2 / (hbar c 4pi eps0) (dimensionless) Alpha = 7.2973525376e-3 // LambdaE is the Compton wavelength of the electron rest mass: // h / (m0 c) = (2 pi hbar) / (m0 c) = 2.42631e-12 m LambdaE = (2.0 * math32.Pi * Hbar) / (EMass * C) // LambdaBarE is the Compton wavelength of the electron rest mass in hbar // hbar / (m0 c) = 3.8615926771197e-13 m LambdaBarE = Hbar / (EMass * C) // A0 is the Bohr radius in hbar: hbar / (m0 c alpha) = 5.2917720859e-11 m A0 = Hbar / (EMass * C * Alpha) // Planck length, m Lp = 1.616252e-35 // Planck time, s Tp = 5.39124e-44 // Planck mass, kg Mp = 2.17644e-8 // Planck current, A Ip = 3.47899e25 )
physical constants in SI units (m, s, kg, A, N, W)
const NParticles = 4
NParticles is the total number of particles that can be tracked.
Variables ¶
var ( // GPUInitialized is true once the GPU system has been initialized. // Prevents multiple initializations. GPUInitialized bool // ComputeGPU is the compute gpu device. // Set this prior to calling GPUInit() to use an existing device. ComputeGPU *gpu.GPU // BorrowedGPU is true if our ComputeGPU is set externally, // versus created specifically for this system. If external, // we don't release it. BorrowedGPU bool // UseGPU indicates whether to use GPU vs. CPU. UseGPU bool )
var ( // Params contains the full set of simulation parameters. //gosl:group Params //gosl:read-only Params []Parameters // NeighOffs are neighborhood offsets for 3D 26 neighbors: [26][3] //gosl:dims 2 NeighOffs *tensor.Int32 // FaceOffs are neighborhood offsets for 3D 18 faces: [x,y,z][-,+][9][3] //gosl:dims 4 FaceOffs *tensor.Int32 // NeighWts are weighting factors for 3D 26 neighbors. // [NeighWeightsN][27] //gosl:dims 2 NeighWts *tensor.Float32 // Ctx has the Context state values. //gosl:group State //gosl:read-only Ctx []Context // Particles records tracking data on different particles. // [ParticlesN][VarsN] //gosl:dims 2 Particles *tensor.Float32 // State is the overall wave state, with inner-most index being the current // and previous states. [Z][Y][X][VarsN][2] // The display shows X-Y planes stacked in the Z dimension. //gosl:dims 5 //gosl:nbuffs 10 State *tensor.Float32 )
vars are all the global vars for GPU / CPU computation.
var DiracShouldDisplay = []string{"Edges", "Energy", "C", "Hbar", "Mass", "Wavelength", "PacketWidth"}
DiracShouldDisplay determines which Parameters fields to display.
var GPUSystem *gpu.ComputeSystem
GPUSystem is a GPU compute System with kernels operating on the same set of data variables.
var KGShouldDisplay = []string{"Edges", "Energy", "C", "Hbar", "Mass", "Wavelength", "PacketWidth"}
KGShouldDisplay determines which Parameters fields to display.
var MaxwellShouldDisplay = []string{"Edges", "C", "Mu0", "Eps0"}
MaxwellShouldDisplay determines which Parameters fields to display.
var MinUnitHeight = float32(1.0e-6)
MinUnitHeight ensures that there is always at least some dimensionality to the unit cubes -- affects transparency rendering etc
var NilColor = color.RGBA{0x20, 0x20, 0x20, 0x40}
var ParamsShouldDisplay []string
ParamsShouldDisplay should be set to an equation-specific list of Parameters field names to display. To simplify the GPU configuration, it is important to only have one struct with everything in it, so this simplifies things.
var ParticleDisplay = []string{"Edges", "Energy", "C", "Diff", "Decay", "Hbar", "Mass", "Wavelength", "PacketWidth", "Velocity", "Move"}
ParticleDisplay determines which Parameters fields to display.
var SchrodShouldDisplay = []string{"Edges", "Energy", "C", "Hbar", "Mass", "Wavelength", "PacketWidth"}
SchrodShouldDisplay determines which Parameters fields to display.
var TensorStrides tensor.Uint32
Tensor stride variables
var WaveShouldDisplay = []string{"Edges", "Energy", "C"}
WaveShouldDisplay determines which Parameters fields to display.
Functions ¶
func Cab1DViewAll ¶ added in v0.0.5
func Cab1DViewAll(view *View)
Cab1DViewAll configures the View to display A and B, Cur and Prev
func CenterF ¶ added in v0.0.6
CenterF returns the given 3D coords with any negative numbers replaced with the value plus center+1 (of non-edge space) such that -1 = center, -2 = 1 before center, etc.
func CenterFull ¶ added in v0.0.6
CenterFull returns the given 3d coords with any negative numbers replaced with the value plus center+1 (of full space) such that -1 = center, -2 = 1 before center, etc.
func CenterI ¶ added in v0.0.6
CenterI returns the given 3D coords with any negative numbers replaced with the value plus center+1 (of non-edge space) such that -1 = center, -2 = 1 before center, etc.
func Curl18 ¶ added in v0.0.5
Curl18 computes the 3D curl across 18 neighbors on a field vector, for given x,y,z center coordinates, variable index vidx (to X component), and cur / prev time index tidx.
func DiracKernel ¶ added in v0.0.5
func DiracKernel(i uint32)
DiracKernel is the kernel for computing the Dirac equations, on scalar state values (WaveStates).
func Divergence18 ¶ added in v0.0.5
Divergence18 computes the 3D divergence across 18 neighbors, for given x,y,z center coordinates, variable index vidx, and cur / prev time index tidx. Div = sum of gradients.
func EdgeInBounds0 ¶ added in v0.0.5
EdgeInBounds0 returns true if given coordinate is >= 0 and <= s.
func EdgeInBounds1 ¶ added in v0.0.5
EdgeInBounds1 returns true if given coordinate is >= 1 and < s.
func EdgesWrapKernel ¶ added in v0.0.5
func EdgesWrapKernel(i uint32)
EdgesWrapKernel is the kernel for wrapping edge values
func FormDialog ¶
FormDialog opens a dialog in a new, separate window for viewing / editing the given struct object, in the context of the given ctx widget.
func GPUInit ¶
func GPUInit()
GPUInit initializes the GPU compute system, configuring system(s), variables and kernels. It is safe to call multiple times: detects if already run.
func GPURelease ¶
func GPURelease()
GPURelease releases the GPU compute system resources. Call this at program exit.
func GetParticleAt ¶ added in v0.0.6
GetParticleAt gets particle dynamic data at given index.
func GetRandomNumber ¶ added in v0.0.5
GetRandomNumber returns a random number that depends on the index, counter and function index. We increment the counter after each cycle, so that we get new random numbers. This whole scheme exists to ensure equal results under different multithreading settings.
func Gradient18 ¶ added in v0.0.5
Gradient18 computes the 3D gradient across 18 neighbors, for given x,y,z center coordinates, variable index vidx, and cur / prev time index tidx.
func KleinGordonCDampKernel ¶ added in v0.0.5
func KleinGordonCDampKernel(i uint32)
KleinGordonCDampKernel is the kernel for computing the KleinGordonC equations, on complex wave state, at damped edges. Does Sommerfield damping where velocity = force.
func KleinGordonCKernel ¶ added in v0.0.5
func KleinGordonCKernel(i uint32)
KleinGordonCKernel is the kernel for computing the KleinGordonC equations, on complex wave state.
func KleinGordonDampKernel ¶ added in v0.0.5
func KleinGordonDampKernel(i uint32)
KleinGordonDampKernel is the kernel for computing the KleinGordon equations, on scalar state values (WaveStates), at damped edges. Does Sommerfield damping where velocity = force.
func KleinGordonKernel ¶ added in v0.0.5
func KleinGordonKernel(i uint32)
KleinGordonKernel is the kernel for computing the KleinGordon equations, on scalar state values (WaveStates).
func Laplacian1D ¶ added in v0.0.5
Laplacian1D computes the 1D Laplacian across 2 X dim neighbors, for given x,y,z center coordinates, variable index vidx, and cur / prev time index tidx. ctr is the center value.
func Laplacian26 ¶
Laplacian26 computes the 3D Laplacian across 26 neighbors, for given x,y,z center coordinates, variable index vidx, and cur / prev time index tidx. ctr is the center value.
func LaplacianEdge1D ¶ added in v0.0.5
LaplacianEdge1D computes the 1D Laplacian across 2 X dim neighbors, for given x,y,z center coordinates, variable index vidx, and cur / prev time index tidx. ctr is the center value. For computation at the edge, checks against given full size bounds.
func LaplacianEdge26 ¶ added in v0.0.5
LaplacianEdge26 computes the 3D Laplacian across 26 neighbors, for given x,y,z center coordinates, variable index vidx, and cur / prev time index tidx. ctr is the center value. For computation at the edge, checks against given full size bounds.
func MaxwellDampKernel ¶ added in v0.0.5
func MaxwellDampKernel(i uint32)
MaxwellDampKernel is the kernel for computing the Maxwell EM equations, on EM state values (EMStates), at damped edges. Does Sommerfield damping where velocity = force.
func MaxwellKernel ¶ added in v0.0.5
func MaxwellKernel(i uint32)
MaxwellKernel is the kernel for computing the Maxwell EM equations, on EM state values (EMStates).
func NeighAverage27 ¶ added in v0.0.5
NeighAverage27 computes the 3D average across 27 neighbors, including the center, for given x,y,z center coordinates, variable index vidx, and cur / prev time index tidx. ctr is the center value.
func NeighMax26 ¶ added in v0.0.6
NeighMax26 returns which neighbor cell index (into NeighOffs offsets) has the largest value among the 26 3D neighbors. for given x,y,z center coordinates, variable index vidx, and cur / prev time index tidx.
func NeighValue ¶ added in v0.0.6
NeighValue returns value at given neighbor cell index (into NeighOffs offsets), for given x,y,z center coordinates, variable index vidx, and cur / prev time index tidx.
func PotentialEnergy1D ¶ added in v0.0.5
PotentialEnergy1D computes the 1D potential energy across 2 neighbors, for given x,y,z center coordinates, variable index vidx, and cur / prev time index tidx. ctr is the center value.
func PotentialEnergy26 ¶
PotentialEnergy26 computes the 3D potential energy across 26 neighbors, for given x,y,z center coordinates, variable index vidx, and cur / prev time index tidx. ctr is the center value.
func ReadFromGPU ¶
func ReadFromGPU(vars ...GPUVars)
ReadFromGPU starts the process of copying vars to the GPU.
func RunDiracKernel ¶ added in v0.0.5
func RunDiracKernel(n int)
RunDiracKernel runs the DiracKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. Can call multiple Run* kernels in a row, which are then all launched in the same command submission on the GPU, which is by far the most efficient. MUST call RunDone (with optional vars to sync) after all Run calls. Alternatively, a single-shot RunOneDiracKernel call does Run and Done for a single run-and-sync case.
func RunDiracKernelCPU ¶ added in v0.0.5
func RunDiracKernelCPU(n int)
RunDiracKernelCPU runs the DiracKernel kernel on the CPU.
func RunDiracKernelGPU ¶ added in v0.0.5
func RunDiracKernelGPU(n int)
RunDiracKernelGPU runs the DiracKernel kernel on the GPU. See RunDiracKernel for more info.
func RunDone ¶
func RunDone(syncVars ...GPUVars)
RunDone must be called after Run* calls to start compute kernels. This actually submits the kernel jobs to the GPU, and adds commands to synchronize the given variables back from the GPU to the CPU. After this function completes, the GPU results will be available in the specified variables.
func RunEdgesWrapKernel ¶ added in v0.0.5
func RunEdgesWrapKernel(n int)
RunEdgesWrapKernel runs the EdgesWrapKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. Can call multiple Run* kernels in a row, which are then all launched in the same command submission on the GPU, which is by far the most efficient. MUST call RunDone (with optional vars to sync) after all Run calls. Alternatively, a single-shot RunOneEdgesWrapKernel call does Run and Done for a single run-and-sync case.
func RunEdgesWrapKernelCPU ¶ added in v0.0.5
func RunEdgesWrapKernelCPU(n int)
RunEdgesWrapKernelCPU runs the EdgesWrapKernel kernel on the CPU.
func RunEdgesWrapKernelGPU ¶ added in v0.0.5
func RunEdgesWrapKernelGPU(n int)
RunEdgesWrapKernelGPU runs the EdgesWrapKernel kernel on the GPU. See RunEdgesWrapKernel for more info.
func RunGPUSync ¶
func RunGPUSync()
RunGPUSync can be called to synchronize data between CPU and GPU. Any prior ToGPU* calls will execute to send data to the GPU, and any subsequent RunDone* calls will copy data back from the GPU.
func RunKleinGordonCDampKernel ¶ added in v0.0.5
func RunKleinGordonCDampKernel(n int)
RunKleinGordonCDampKernel runs the KleinGordonCDampKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. Can call multiple Run* kernels in a row, which are then all launched in the same command submission on the GPU, which is by far the most efficient. MUST call RunDone (with optional vars to sync) after all Run calls. Alternatively, a single-shot RunOneKleinGordonCDampKernel call does Run and Done for a single run-and-sync case.
func RunKleinGordonCDampKernelCPU ¶ added in v0.0.5
func RunKleinGordonCDampKernelCPU(n int)
RunKleinGordonCDampKernelCPU runs the KleinGordonCDampKernel kernel on the CPU.
func RunKleinGordonCDampKernelGPU ¶ added in v0.0.5
func RunKleinGordonCDampKernelGPU(n int)
RunKleinGordonCDampKernelGPU runs the KleinGordonCDampKernel kernel on the GPU. See RunKleinGordonCDampKernel for more info.
func RunKleinGordonCKernel ¶ added in v0.0.5
func RunKleinGordonCKernel(n int)
RunKleinGordonCKernel runs the KleinGordonCKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. Can call multiple Run* kernels in a row, which are then all launched in the same command submission on the GPU, which is by far the most efficient. MUST call RunDone (with optional vars to sync) after all Run calls. Alternatively, a single-shot RunOneKleinGordonCKernel call does Run and Done for a single run-and-sync case.
func RunKleinGordonCKernelCPU ¶ added in v0.0.5
func RunKleinGordonCKernelCPU(n int)
RunKleinGordonCKernelCPU runs the KleinGordonCKernel kernel on the CPU.
func RunKleinGordonCKernelGPU ¶ added in v0.0.5
func RunKleinGordonCKernelGPU(n int)
RunKleinGordonCKernelGPU runs the KleinGordonCKernel kernel on the GPU. See RunKleinGordonCKernel for more info.
func RunKleinGordonDampKernel ¶ added in v0.0.5
func RunKleinGordonDampKernel(n int)
RunKleinGordonDampKernel runs the KleinGordonDampKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. Can call multiple Run* kernels in a row, which are then all launched in the same command submission on the GPU, which is by far the most efficient. MUST call RunDone (with optional vars to sync) after all Run calls. Alternatively, a single-shot RunOneKleinGordonDampKernel call does Run and Done for a single run-and-sync case.
func RunKleinGordonDampKernelCPU ¶ added in v0.0.5
func RunKleinGordonDampKernelCPU(n int)
RunKleinGordonDampKernelCPU runs the KleinGordonDampKernel kernel on the CPU.
func RunKleinGordonDampKernelGPU ¶ added in v0.0.5
func RunKleinGordonDampKernelGPU(n int)
RunKleinGordonDampKernelGPU runs the KleinGordonDampKernel kernel on the GPU. See RunKleinGordonDampKernel for more info.
func RunKleinGordonKernel ¶ added in v0.0.5
func RunKleinGordonKernel(n int)
RunKleinGordonKernel runs the KleinGordonKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. Can call multiple Run* kernels in a row, which are then all launched in the same command submission on the GPU, which is by far the most efficient. MUST call RunDone (with optional vars to sync) after all Run calls. Alternatively, a single-shot RunOneKleinGordonKernel call does Run and Done for a single run-and-sync case.
func RunKleinGordonKernelCPU ¶ added in v0.0.5
func RunKleinGordonKernelCPU(n int)
RunKleinGordonKernelCPU runs the KleinGordonKernel kernel on the CPU.
func RunKleinGordonKernelGPU ¶ added in v0.0.5
func RunKleinGordonKernelGPU(n int)
RunKleinGordonKernelGPU runs the KleinGordonKernel kernel on the GPU. See RunKleinGordonKernel for more info.
func RunMaxwellDampKernel ¶ added in v0.0.5
func RunMaxwellDampKernel(n int)
RunMaxwellDampKernel runs the MaxwellDampKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. Can call multiple Run* kernels in a row, which are then all launched in the same command submission on the GPU, which is by far the most efficient. MUST call RunDone (with optional vars to sync) after all Run calls. Alternatively, a single-shot RunOneMaxwellDampKernel call does Run and Done for a single run-and-sync case.
func RunMaxwellDampKernelCPU ¶ added in v0.0.5
func RunMaxwellDampKernelCPU(n int)
RunMaxwellDampKernelCPU runs the MaxwellDampKernel kernel on the CPU.
func RunMaxwellDampKernelGPU ¶ added in v0.0.5
func RunMaxwellDampKernelGPU(n int)
RunMaxwellDampKernelGPU runs the MaxwellDampKernel kernel on the GPU. See RunMaxwellDampKernel for more info.
func RunMaxwellKernel ¶ added in v0.0.5
func RunMaxwellKernel(n int)
RunMaxwellKernel runs the MaxwellKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. Can call multiple Run* kernels in a row, which are then all launched in the same command submission on the GPU, which is by far the most efficient. MUST call RunDone (with optional vars to sync) after all Run calls. Alternatively, a single-shot RunOneMaxwellKernel call does Run and Done for a single run-and-sync case.
func RunMaxwellKernelCPU ¶ added in v0.0.5
func RunMaxwellKernelCPU(n int)
RunMaxwellKernelCPU runs the MaxwellKernel kernel on the CPU.
func RunMaxwellKernelGPU ¶ added in v0.0.5
func RunMaxwellKernelGPU(n int)
RunMaxwellKernelGPU runs the MaxwellKernel kernel on the GPU. See RunMaxwellKernel for more info.
func RunOneDiracKernel ¶ added in v0.0.5
RunOneDiracKernel runs the DiracKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. This version then calls RunDone with the given variables to sync after the Run, for a single-shot Run-and-Done call. If multiple kernels can be run in sequence, it is much more efficient to do multiple Run* calls followed by a RunDone call.
func RunOneEdgesWrapKernel ¶ added in v0.0.5
RunOneEdgesWrapKernel runs the EdgesWrapKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. This version then calls RunDone with the given variables to sync after the Run, for a single-shot Run-and-Done call. If multiple kernels can be run in sequence, it is much more efficient to do multiple Run* calls followed by a RunDone call.
func RunOneKleinGordonCDampKernel ¶ added in v0.0.5
RunOneKleinGordonCDampKernel runs the KleinGordonCDampKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. This version then calls RunDone with the given variables to sync after the Run, for a single-shot Run-and-Done call. If multiple kernels can be run in sequence, it is much more efficient to do multiple Run* calls followed by a RunDone call.
func RunOneKleinGordonCKernel ¶ added in v0.0.5
RunOneKleinGordonCKernel runs the KleinGordonCKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. This version then calls RunDone with the given variables to sync after the Run, for a single-shot Run-and-Done call. If multiple kernels can be run in sequence, it is much more efficient to do multiple Run* calls followed by a RunDone call.
func RunOneKleinGordonDampKernel ¶ added in v0.0.5
RunOneKleinGordonDampKernel runs the KleinGordonDampKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. This version then calls RunDone with the given variables to sync after the Run, for a single-shot Run-and-Done call. If multiple kernels can be run in sequence, it is much more efficient to do multiple Run* calls followed by a RunDone call.
func RunOneKleinGordonKernel ¶ added in v0.0.5
RunOneKleinGordonKernel runs the KleinGordonKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. This version then calls RunDone with the given variables to sync after the Run, for a single-shot Run-and-Done call. If multiple kernels can be run in sequence, it is much more efficient to do multiple Run* calls followed by a RunDone call.
func RunOneMaxwellDampKernel ¶ added in v0.0.5
RunOneMaxwellDampKernel runs the MaxwellDampKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. This version then calls RunDone with the given variables to sync after the Run, for a single-shot Run-and-Done call. If multiple kernels can be run in sequence, it is much more efficient to do multiple Run* calls followed by a RunDone call.
func RunOneMaxwellKernel ¶ added in v0.0.5
RunOneMaxwellKernel runs the MaxwellKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. This version then calls RunDone with the given variables to sync after the Run, for a single-shot Run-and-Done call. If multiple kernels can be run in sequence, it is much more efficient to do multiple Run* calls followed by a RunDone call.
func RunOneSchrodingerKernel ¶ added in v0.0.5
RunOneSchrodingerKernel runs the SchrodingerKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. This version then calls RunDone with the given variables to sync after the Run, for a single-shot Run-and-Done call. If multiple kernels can be run in sequence, it is much more efficient to do multiple Run* calls followed by a RunDone call.
func RunOneSpinfieldKernel ¶ added in v0.0.6
RunOneSpinfieldKernel runs the SpinfieldKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. This version then calls RunDone with the given variables to sync after the Run, for a single-shot Run-and-Done call. If multiple kernels can be run in sequence, it is much more efficient to do multiple Run* calls followed by a RunDone call.
func RunOneWaveDampKernel ¶ added in v0.0.5
RunOneWaveDampKernel runs the WaveDampKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. This version then calls RunDone with the given variables to sync after the Run, for a single-shot Run-and-Done call. If multiple kernels can be run in sequence, it is much more efficient to do multiple Run* calls followed by a RunDone call.
func RunOneWaveKernel ¶ added in v0.0.5
RunOneWaveKernel runs the WaveKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. This version then calls RunDone with the given variables to sync after the Run, for a single-shot Run-and-Done call. If multiple kernels can be run in sequence, it is much more efficient to do multiple Run* calls followed by a RunDone call.
func RunSchrodingerKernel ¶ added in v0.0.5
func RunSchrodingerKernel(n int)
RunSchrodingerKernel runs the SchrodingerKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. Can call multiple Run* kernels in a row, which are then all launched in the same command submission on the GPU, which is by far the most efficient. MUST call RunDone (with optional vars to sync) after all Run calls. Alternatively, a single-shot RunOneSchrodingerKernel call does Run and Done for a single run-and-sync case.
func RunSchrodingerKernelCPU ¶ added in v0.0.5
func RunSchrodingerKernelCPU(n int)
RunSchrodingerKernelCPU runs the SchrodingerKernel kernel on the CPU.
func RunSchrodingerKernelGPU ¶ added in v0.0.5
func RunSchrodingerKernelGPU(n int)
RunSchrodingerKernelGPU runs the SchrodingerKernel kernel on the GPU. See RunSchrodingerKernel for more info.
func RunSpinfieldKernel ¶ added in v0.0.6
func RunSpinfieldKernel(n int)
RunSpinfieldKernel runs the SpinfieldKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. Can call multiple Run* kernels in a row, which are then all launched in the same command submission on the GPU, which is by far the most efficient. MUST call RunDone (with optional vars to sync) after all Run calls. Alternatively, a single-shot RunOneSpinfieldKernel call does Run and Done for a single run-and-sync case.
func RunSpinfieldKernelCPU ¶ added in v0.0.6
func RunSpinfieldKernelCPU(n int)
RunSpinfieldKernelCPU runs the SpinfieldKernel kernel on the CPU.
func RunSpinfieldKernelGPU ¶ added in v0.0.6
func RunSpinfieldKernelGPU(n int)
RunSpinfieldKernelGPU runs the SpinfieldKernel kernel on the GPU. See RunSpinfieldKernel for more info.
func RunWaveDampKernel ¶ added in v0.0.5
func RunWaveDampKernel(n int)
RunWaveDampKernel runs the WaveDampKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. Can call multiple Run* kernels in a row, which are then all launched in the same command submission on the GPU, which is by far the most efficient. MUST call RunDone (with optional vars to sync) after all Run calls. Alternatively, a single-shot RunOneWaveDampKernel call does Run and Done for a single run-and-sync case.
func RunWaveDampKernelCPU ¶ added in v0.0.5
func RunWaveDampKernelCPU(n int)
RunWaveDampKernelCPU runs the WaveDampKernel kernel on the CPU.
func RunWaveDampKernelGPU ¶ added in v0.0.5
func RunWaveDampKernelGPU(n int)
RunWaveDampKernelGPU runs the WaveDampKernel kernel on the GPU. See RunWaveDampKernel for more info.
func RunWaveKernel ¶ added in v0.0.5
func RunWaveKernel(n int)
RunWaveKernel runs the WaveKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. Can call multiple Run* kernels in a row, which are then all launched in the same command submission on the GPU, which is by far the most efficient. MUST call RunDone (with optional vars to sync) after all Run calls. Alternatively, a single-shot RunOneWaveKernel call does Run and Done for a single run-and-sync case.
func RunWaveKernelCPU ¶ added in v0.0.5
func RunWaveKernelCPU(n int)
RunWaveKernelCPU runs the WaveKernel kernel on the CPU.
func RunWaveKernelGPU ¶ added in v0.0.5
func RunWaveKernelGPU(n int)
RunWaveKernelGPU runs the WaveKernel kernel on the GPU. See RunWaveKernel for more info.
func SchrodingerKernel ¶ added in v0.0.5
func SchrodingerKernel(i uint32)
SchrodingerKernel is the kernel for computing the Schrodinger equations.
func SetParticleAt ¶ added in v0.0.6
SetParticleAt sets particle dynamic data at given index.
func SpinfieldKernel ¶ added in v0.0.6
func SpinfieldKernel(i uint32)
SpinfieldKernel is the kernel for computing spinfield model. Only supports 3D.
func SpinfieldViewAll ¶ added in v0.0.6
func SpinfieldViewAll(view *View)
SpinfieldViewAll configures the View to display Spinfield values
func StateSum ¶ added in v0.0.5
StateSum computes the sum of given variable at given cur vs. prev state with given non-edge size.
func SyncFromGPU ¶
func SyncFromGPU(vars ...GPUVars)
SyncFromGPU synchronizes vars from the GPU to the actual variable.
func ToGPUTensorStrides ¶
func ToGPUTensorStrides()
ToGPUTensorStrides gets tensor strides and starts copying to the GPU.
func Wave1DViewAll ¶ added in v0.0.3
func Wave1DViewAll(view *View)
Wave1DViewAll configures the View to display Pos and Vel, Cur and Prev
func WaveDampKernel ¶ added in v0.0.5
func WaveDampKernel(i uint32)
WaveDampKernel is the kernel for computing the Wave equations at damped edges. Does Sommerfield damping where velocity = force.
func WaveKernel ¶ added in v0.0.5
func WaveKernel(i uint32)
WaveKernel is the kernel for computing the Wave equations.
func WavePacket ¶ added in v0.0.4
WavePacket returns value for a gaussian * cosine wave packet for given linear dimension value x and 3D distance d.
Types ¶
type CabStates ¶ added in v0.0.5
type CabStates int32 //enums:enum -trim-prefix=Cab
CabStates are the state variables for wave equations on a wave state with a single complex value, where A = real and B = complex components.
const ( // CabPosA is the position (height) wave state variable // for the real complex component A. CabPosA CabStates = iota // CabPosB is the position (height) wave state variable // for the imaginary complex component B. CabPosB // CabVelA is the velocity of wave state variable // for the real complex component A. CabVelA // CabVelB is the velocity of wave state variable // for the imaginary complex component B. CabVelB // CabForceA is the net force computed from neighbors // for the real complex component A. CabForceA // CabForceB is the net force computed from neighbors // for the imaginary complex component B. CabForceB // CabV is an external potential energy factor, that // can be used to push particles around. CabV // CabCC is the complex conjugate ("squared") wave // value, which represents the total probability or a conserved // charge value. CabCC // CabCharge is the charge density. CabCharge // CabCurrentX is the current density. CabCurrentX // CabCurrentY is the current density. CabCurrentY // CabCurrentZ is the current density. CabCurrentZ // CabKinetic is the total kinetic energy across components. CabKinetic // CabPotential is the total potential energy across components (only for KGC). CabPotential // CabEnergy is the total kinetic + potential energy. CabEnergy )
const CabStatesN CabStates = 15
CabStatesN is the highest valid value for type CabStates, plus one.
func CabStatesValues ¶ added in v0.0.5
func CabStatesValues() []CabStates
CabStatesValues returns all possible values for the type CabStates.
func (CabStates) MarshalText ¶ added in v0.0.5
MarshalText implements the encoding.TextMarshaler interface.
func (*CabStates) SetString ¶ added in v0.0.5
SetString sets the CabStates value from its string representation, and returns an error if the string is invalid.
func (CabStates) String ¶ added in v0.0.5
String returns the string representation of this CabStates value.
func (*CabStates) UnmarshalText ¶ added in v0.0.5
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Config ¶
type Config struct {
// GPU determines whether to use the GPU.
GPU bool `default:"true"`
// GUI determines whether to show the GUI.
GUI bool `default:"true"`
// Equation to run
Equation Equations `edit:"-"`
// Size of Universe to run. This is only the active portion, excluding
// edges at all sizes (add 2 to each dim).
Size math32.Vector3i
// ViewInterval is how often to update the view
ViewInterval int `min:"1"`
// Wavelength is the wavelength to use for functions that use it
// (Config suffix). Allows user to manipulate the wavelength easily,
// e.g., for KG and other matter waves.
Wavelength float32
// PacketWidth is the wave packet width to use for functions that use it
// (Config suffix). Allows user to manipulate the wave parameters easily,
// e.g., for KG and other matter waves.
PacketWidth float32
// Velocity provides the default particle velocity.
Velocity math32.Vector3
// MaxSteps is the maximum number of steps to run.
MaxSteps int
}
Config contains overall simulation configuration options.
type Context ¶
type Context struct {
// Size is the 3D size of the state, EXCLUSIVE of edges (add 2 to each dim).
Size slvec.Vector3i
// NVars is the number of state variables.
NVars int32
// Step is the current simulation timestep.
Step int32
// CurState is either 0 or 1, indicating which state variables
// are currently being updated on this compute pass.
CurState int32
// RandCounter is the random counter, incremented by maximum number of
// possible random numbers generated per cycle, regardless of how
// many are actually used. This is shared across all layers so must
// encompass all possible param settings.
RandCounter slrand.Counter
// contains filtered or unexported fields
}
Context contains all simulation counters and other context. This is only other state shared with GPU.
func GetCtx ¶
GetCtx returns a pointer to the given global variable: Ctx []Context at given index. This directly processed in the GPU code, so this function call is an equivalent for the CPU.
func (*Context) EdgeCoords ¶ added in v0.0.5
EdgeCoords returns the x,y,z coordinates for given index into the edge state, using non-shared edge patterns per above. returns the face / corner number we're at (0-6) or -1 for none
func (*Context) EdgeCoordsWrap ¶ added in v0.0.5
EdgeCoordsWrap returns the x,y,z coordinates for given index into the edge state, using non-shared edge patterns per above, and also the source state for wrapping the value around as in a torus. returns the face / corner number we're at (0-6) or -1 for none
func (*Context) EdgesN ¶ added in v0.0.5
EdgesN returns the number of points along the edges (and corners).
func (*Context) PrevState ¶
PrevState returns the index for the previous state, relative to CurState.
func (*Context) SizeFull ¶
SizeFull returns the full size of the state, including edges on either side.
func (*Context) SizePlus1 ¶ added in v0.0.5
SizePlus1 returns Size + 1. Used for edge bounds checking.
func (*Context) StateCoords ¶
StateCoords returns the x,y,z coordinates for given index into the state, where index is in Size units of active states, excluding edges. Resulting coords have 1 added to each, so they are valid coordinates into actual State. returns false if the index is out of range for size.
type CurPrev ¶
type CurPrev int32 //enums:enum
CurPrev for Current vs Previous state access.
const CurPrevN CurPrev = 2
CurPrevN is the highest valid value for type CurPrev, plus one.
func CurPrevValues ¶
func CurPrevValues() []CurPrev
CurPrevValues returns all possible values for the type CurPrev.
func (CurPrev) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*CurPrev) SetString ¶
SetString sets the CurPrev value from its string representation, and returns an error if the string is invalid.
func (*CurPrev) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type CurPrevBoth ¶ added in v0.0.5
type CurPrevBoth int32 //enums:enum
CurPrevBoth allows selecting current only, previous only, or both.
const ( // CurOnly sets only current states. CurOnly CurPrevBoth = iota // PrevOnly sets only previous states. PrevOnly // Both sets both current and previous states. Both )
const CurPrevBothN CurPrevBoth = 3
CurPrevBothN is the highest valid value for type CurPrevBoth, plus one.
func CurPrevBothValues ¶ added in v0.0.5
func CurPrevBothValues() []CurPrevBoth
CurPrevBothValues returns all possible values for the type CurPrevBoth.
func (CurPrevBoth) Desc ¶ added in v0.0.5
func (i CurPrevBoth) Desc() string
Desc returns the description of the CurPrevBoth value.
func (CurPrevBoth) Int64 ¶ added in v0.0.5
func (i CurPrevBoth) Int64() int64
Int64 returns the CurPrevBoth value as an int64.
func (CurPrevBoth) MarshalText ¶ added in v0.0.5
func (i CurPrevBoth) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*CurPrevBoth) SetInt64 ¶ added in v0.0.5
func (i *CurPrevBoth) SetInt64(in int64)
SetInt64 sets the CurPrevBoth value from an int64.
func (*CurPrevBoth) SetString ¶ added in v0.0.5
func (i *CurPrevBoth) SetString(s string) error
SetString sets the CurPrevBoth value from its string representation, and returns an error if the string is invalid.
func (CurPrevBoth) String ¶ added in v0.0.5
func (i CurPrevBoth) String() string
String returns the string representation of this CurPrevBoth value.
func (*CurPrevBoth) UnmarshalText ¶ added in v0.0.5
func (i *CurPrevBoth) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (CurPrevBoth) Values ¶ added in v0.0.5
func (i CurPrevBoth) Values() []enums.Enum
Values returns all possible values for the type CurPrevBoth.
type DiracStates ¶ added in v0.0.5
type DiracStates EMStates //enums:enum -trim-prefix=Dirac
DiracStates are the state variables for wave equations on a wave state with two complex values (1, 2), where A = real and B = complex components.
const ( // DiracPos1A is the position (height) wave state variable // 1 for the real complex component A. DiracPos1A DiracStates = DiracStates(EMStatesN) + iota // DiracPos1B is the position (height) wave state variable // 1 for the imaginary complex component B. DiracPos1B // DiracPos2A is the position (height) wave state variable // 2 for the real complex component A. DiracPos2A // DiracPos2B is the position (height) wave state variable // 2 for the imaginary complex component B. DiracPos2B // DiracVel1A is the velocity of wave state variable // 1 for the real complex component A. DiracVel1A // DiracVel1B is the velocity of wave state variable // 1 for the imaginary complex component B. DiracVel1B // DiracVel2A is the velocity of wave state variable // 2 for the real complex component A. DiracVel2A // DiracVel2B is the velocity of wave state variable // 2 for the imaginary complex component B. DiracVel2B // DiracCC is the complex conjugate ("squared") wave // value, which represents the total probability or a conserved // charge value. DiracCC )
const DiracStatesN DiracStates = 27
DiracStatesN is the highest valid value for type DiracStates, plus one.
func DiracStatesValues ¶ added in v0.0.5
func DiracStatesValues() []DiracStates
DiracStatesValues returns all possible values for the type DiracStates.
func (DiracStates) Desc ¶ added in v0.0.5
func (i DiracStates) Desc() string
Desc returns the description of the DiracStates value.
func (DiracStates) Int64 ¶ added in v0.0.5
func (i DiracStates) Int64() int64
Int64 returns the DiracStates value as an int64.
func (DiracStates) MarshalText ¶ added in v0.0.5
func (i DiracStates) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*DiracStates) SetInt64 ¶ added in v0.0.5
func (i *DiracStates) SetInt64(in int64)
SetInt64 sets the DiracStates value from an int64.
func (*DiracStates) SetString ¶ added in v0.0.5
func (i *DiracStates) SetString(s string) error
SetString sets the DiracStates value from its string representation, and returns an error if the string is invalid.
func (DiracStates) String ¶ added in v0.0.5
func (i DiracStates) String() string
String returns the string representation of this DiracStates value.
func (*DiracStates) UnmarshalText ¶ added in v0.0.5
func (i *DiracStates) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (DiracStates) Values ¶ added in v0.0.5
func (i DiracStates) Values() []enums.Enum
Values returns all possible values for the type DiracStates.
type EMStates ¶ added in v0.0.5
type EMStates int32 //enums:enum
EMStates are the state variables for EM wave equations.
const ( // A0Pos is the position (height) wave state variable // for the EM A0 electrical (scalar) potential field. A0Pos EMStates = iota // AXPos is the position (height) wave state variable // for the EM AX magnetic (vector) potential field, X component. AXPos // AYPos is the position (height) wave state variable // for the EM AY magnetic (vector) potential field, Y component. AYPos // AZPos is the position (height) wave state variable // for the EM AZ magnetic (vector) potential field, Z component. AZPos // A0Vel is the velocity of wave state variable // for the EM A0 electrical (scalar) potential field. A0Vel // AXVel is the velocity of wave state variable // for the EM AX magnetic (vector) potential field, X component. AXVel // AYVel is the velocity of wave state variable // for the EM AY magnetic (vector) potential field, Y component. AYVel // AZVel is the velocity of wave state variable // for the EM AZ magnetic (vector) potential field, Z component. AZVel // EX is the electrical vector field, X component: -grad A_0 - d \vec{A}/dt EX // EY is the electrical vector field, Y component: -grad A_0 - d \vec{A}/dt EY // EZ is the electrical vector field, Z component: -grad A_0 - d \vec{A}/dt EZ // BX is the magnetic vector field, X component: curl \vec{A} BX // BY is the magnetic vector field, Y component: curl \vec{A} BY // BZ is the magnetic vector field, Z component: curl \vec{A} BZ // Charge is the density of charge, drives A0. Charge // CurrentX is the density of current, X component, drives AX. CurrentX // CurrentY is the density of current, Y component, drives AY. CurrentY // CurrentZ is the density of current, Z component, drives AZ. CurrentZ )
const EMStatesN EMStates = 18
EMStatesN is the highest valid value for type EMStates, plus one.
func EMStatesValues ¶ added in v0.0.5
func EMStatesValues() []EMStates
EMStatesValues returns all possible values for the type EMStates.
func (EMStates) MarshalText ¶ added in v0.0.5
MarshalText implements the encoding.TextMarshaler interface.
func (*EMStates) SetString ¶ added in v0.0.5
SetString sets the EMStates value from its string representation, and returns an error if the string is invalid.
func (EMStates) String ¶ added in v0.0.5
String returns the string representation of this EMStates value.
func (*EMStates) UnmarshalText ¶ added in v0.0.5
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Edges ¶
type Edges int32 //enums:enum -trim-prefix=Edges
Edges determines how to handle the edges.
const EdgesN Edges = 3
EdgesN is the highest valid value for type Edges, plus one.
func EdgesValues ¶
func EdgesValues() []Edges
EdgesValues returns all possible values for the type Edges.
func (Edges) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Edges) SetString ¶
SetString sets the Edges value from its string representation, and returns an error if the string is invalid.
func (*Edges) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Equations ¶
type Equations int32 //enums:enum
Equations are the different implemented equations to simulate.
const ( // Wave is the basic wave equation in one dimension (X). Wave Equations = iota // KleinGordon is the Klein-Gordon massive particle wave function, // on a scalar wave state. KleinGordon // KleinGordonC is the Klein-Gordon massive particle wave function, // on a complex wave state. KleinGordonC // Schrodinger is the Schrodinger wave function on complex state. Schrodinger // Maxwell is Maxwell's equations for electromagnetic (EM) waves. Maxwell // Dirac is Dirac's wave equation coupled with electromagnetic (EM) waves. Dirac // Spinfield is the Klein-Gordon complex version of stochastic particles. Spinfield // ParticleMove is just particle motion without any wave field. ParticleMove )
const EquationsN Equations = 8
EquationsN is the highest valid value for type Equations, plus one.
func EquationsValues ¶
func EquationsValues() []Equations
EquationsValues returns all possible values for the type Equations.
func (Equations) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Equations) SetString ¶
SetString sets the Equations value from its string representation, and returns an error if the string is invalid.
func (*Equations) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type GPUVars ¶
type GPUVars int32 //enums:enum
GPUVars is an enum for GPU variables, for specifying what to sync.
const GPUVarsN GPUVars = 7
GPUVarsN is the highest valid value for type GPUVars, plus one.
func GPUVarsValues ¶
func GPUVarsValues() []GPUVars
GPUVarsValues returns all possible values for the type GPUVars.
func (GPUVars) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*GPUVars) SetString ¶
SetString sets the GPUVars value from its string representation, and returns an error if the string is invalid.
func (*GPUVars) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type GUI ¶
type GUI struct {
lab.Browser
// Active is true if the GUI is configured and running
Active bool `display:"-"`
// SimForm displays the Sim object fields in the left panel.
SimForm *core.Form `display:"-"`
// Body is the entire content of the sim window.
Body *core.Body `display:"-"`
// view if created.
View *View
// contains filtered or unexported fields
}
GUI manages all standard elements of a simulation Graphical User Interface
func NewGUIBody ¶
NewGUIBody returns a new GUI, with an initialized Body by calling [gui.MakeBody].
func (*GUI) FinalizeGUI ¶
FinalizeGUI wraps the end functionality of the GUI
func (*GUI) GoUpdateWindow ¶
func (gui *GUI) GoUpdateWindow()
GoUpdateWindow triggers an update on window body, for calling from a separate goroutine.
func (*GUI) MakeBody ¶
MakeBody initializes default Body with a top-level core.Splits containing a core.Form editor of the given sim object, and a filetree for the data filesystem rooted at fsroot, and with given app name, title, and about information. The first arg is an optional existing core.Body to make into: if nil then a new body is made first.
func (*GUI) MakeToolbar ¶
func (*GUI) SetStopNow ¶
func (gui *GUI) SetStopNow()
SetStopNow sets the stopNow flag to true, under a mutex.
func (*GUI) StartRun ¶
func (gui *GUI) StartRun()
StartRun should be called whenever a process starts running. It sets stopNow = false and isRunning = true under a mutex.
func (*GUI) Stopped ¶
func (gui *GUI) Stopped()
Stopped is called when a run method stops running, from a separate goroutine (do not call from main event loop). Turns off the isRunning flag, calls OnStop, and calls GoUpdateWindow to update window state.
func (*GUI) UpdateWindow ¶
func (gui *GUI) UpdateWindow()
UpdateWindow triggers an update on window body, to be called from within the normal event processing loop. See GoUpdateWindow for version to call from separate goroutine.
type MinusPlusOne ¶ added in v0.0.5
type MinusPlusOne int32 //enums:enum
MinusPlusOne is minus1 and plus1
const ( Minus1 MinusPlusOne = iota Plus1 )
const MinusPlusOneN MinusPlusOne = 2
MinusPlusOneN is the highest valid value for type MinusPlusOne, plus one.
func MinusPlusOneValues ¶ added in v0.0.5
func MinusPlusOneValues() []MinusPlusOne
MinusPlusOneValues returns all possible values for the type MinusPlusOne.
func (MinusPlusOne) Desc ¶ added in v0.0.5
func (i MinusPlusOne) Desc() string
Desc returns the description of the MinusPlusOne value.
func (MinusPlusOne) Int64 ¶ added in v0.0.5
func (i MinusPlusOne) Int64() int64
Int64 returns the MinusPlusOne value as an int64.
func (MinusPlusOne) MarshalText ¶ added in v0.0.5
func (i MinusPlusOne) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*MinusPlusOne) SetInt64 ¶ added in v0.0.5
func (i *MinusPlusOne) SetInt64(in int64)
SetInt64 sets the MinusPlusOne value from an int64.
func (*MinusPlusOne) SetString ¶ added in v0.0.5
func (i *MinusPlusOne) SetString(s string) error
SetString sets the MinusPlusOne value from its string representation, and returns an error if the string is invalid.
func (MinusPlusOne) String ¶ added in v0.0.5
func (i MinusPlusOne) String() string
String returns the string representation of this MinusPlusOne value.
func (*MinusPlusOne) UnmarshalText ¶ added in v0.0.5
func (i *MinusPlusOne) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (MinusPlusOne) Values ¶ added in v0.0.5
func (i MinusPlusOne) Values() []enums.Enum
Values returns all possible values for the type MinusPlusOne.
type NPanels ¶
type NPanels int32 //enums:enum -trim-prefix=Panels
NPanels selects number of panels.
const NPanelsN NPanels = 3
NPanelsN is the highest valid value for type NPanels, plus one.
func NPanelsValues ¶
func NPanelsValues() []NPanels
NPanelsValues returns all possible values for the type NPanels.
func (NPanels) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*NPanels) SetString ¶
SetString sets the NPanels value from its string representation, and returns an error if the string is invalid.
func (*NPanels) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type NeighWeights ¶ added in v0.0.5
type NeighWeights int32 //enums:enum
NeighWeights
const ( // LaplacianWts are weighting factors for 3D Laplacian = 3 / (13 * d^2) LaplacianWts NeighWeights = iota // AverageWts are 26 + 1 ctr average weights = 1 / d AverageWts // Grad18Wts are 18 neighbor gradaients Grad18Wts )
const NeighWeightsN NeighWeights = 3
NeighWeightsN is the highest valid value for type NeighWeights, plus one.
func NeighWeightsValues ¶ added in v0.0.5
func NeighWeightsValues() []NeighWeights
NeighWeightsValues returns all possible values for the type NeighWeights.
func (NeighWeights) Desc ¶ added in v0.0.5
func (i NeighWeights) Desc() string
Desc returns the description of the NeighWeights value.
func (NeighWeights) Int64 ¶ added in v0.0.5
func (i NeighWeights) Int64() int64
Int64 returns the NeighWeights value as an int64.
func (NeighWeights) MarshalText ¶ added in v0.0.5
func (i NeighWeights) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*NeighWeights) SetInt64 ¶ added in v0.0.5
func (i *NeighWeights) SetInt64(in int64)
SetInt64 sets the NeighWeights value from an int64.
func (*NeighWeights) SetString ¶ added in v0.0.5
func (i *NeighWeights) SetString(s string) error
SetString sets the NeighWeights value from its string representation, and returns an error if the string is invalid.
func (NeighWeights) String ¶ added in v0.0.5
func (i NeighWeights) String() string
String returns the string representation of this NeighWeights value.
func (*NeighWeights) UnmarshalText ¶ added in v0.0.5
func (i *NeighWeights) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (NeighWeights) Values ¶ added in v0.0.5
func (i NeighWeights) Values() []enums.Enum
Values returns all possible values for the type NeighWeights.
type PanelView ¶
type PanelView struct {
// Variable to display.
Var enums.Enum
// Select which state to view
CurPrev CurPrev
// Mode is how the state values are displayed for this panel.
Mode ViewModes
// Offset is an additional offset from the global Start,
// enforced to be within the displayable size.
Offset math32.Vector3i
}
PanelView for what each panel in the View renders.
type Parameters ¶
type Parameters struct {
// ThreeD runs the 3D version of wave equations, else 1D.
ThreeD slbool.Bool
// Energy determines if energy is computed (when not necessary).
Energy slbool.Bool
// Move determines if particles actually move according to their momentums.
Move slbool.Bool
// C is the speed of light factor. Generally should not exceed 1!
C float32
// Diff is the particle diffusion rate: how fast to spread distance to neighbors.
Diff float32
// Decay is the particle decay rate: portion of neighbor value to
// retain per unit distance.
Decay float32
// CSq = C^2
CSq float32 `display:"-"`
// Inv2CSq = 1 / 2C^2
Inv2CSq float32 `display:"-"`
// Hbar = h / 2pi = reduced Planck constant.
Hbar float32
// Mass is a general mass term, e.g., for the KleinGordon equations.
Mass float32
// MOverHSq = Mass^2 / Hbar^2 is the mass drag factor in KleinGordon
// and related equations. Note: C^2 factor is added in basic vel += c^2 force
MOverHSq float32 `display:"-"`
// HSqOver2M = Hbar^2 / 2 Mass is the factor for Schrodinger's equation.
HSqOver2M float32 `display:"-"`
// HEOver2MCSq = (Hbar*e) / (2 Mass * CSq) for computing charge.
HEOver2MCSq float32 `display:"-"`
// Omega0 is (Mass * Csq) / Hbar -- the angular velocity for
// complex-valued oscillator corresponding to the rest mass energy only.
Omega0 float32 `display:"-"`
// HOverMC = (Hbar) / (Mass * C) for computing particle momentum from phase.
HOverMC float32 `display:"-"`
// MOver2 = Mass / 2 for computing kinetic energy.
MOver2 float32 `display:"-"`
// MCSq = (Mass^2 * C^2) for computing total momentum squared
MCSq float32 `display:"-"`
// C6M2= (C^6 * Mass^2) is the numerator for computing total particle energy
C6M2 float32 `display:"-"`
// E is the electric charge constant, which determines the
// electric potential units, C = A s
// 0.302822 causes Mu0 and Eps0 to both be 1, if C and Hbar are both 1
E float32
// Mu0 is mu_0, or the permeability of free space, which weights
// the impact of current on the magnetic vector potential.
Mu0 float32
// Eps0 is epsilon_0, or the permittivity of free space, which weights
// the impact of charge on the electrical scalar potential = 1 / (mu0 c^2)
Eps0 float32 `edit:"-"`
// OneoEps0 = 1 / Eps0
OneoEps0 float32 `display:"-"`
// Edges determines how to handle the edges.
Edges Edges
// contains filtered or unexported fields
}
Parameters contains the full set of simulation parameters, for all equations. These are the bare computational values, uploaded to the GPU. Use Units to set values relative to a particular set of units.
func GetParams ¶
func GetParams(idx uint32) *Parameters
GetParams returns a pointer to the given global variable: Params []Parameters at given index. This directly processed in the GPU code, so this function call is an equivalent for the CPU.
func (*Parameters) Defaults ¶
func (pr *Parameters) Defaults()
func (*Parameters) ShouldDisplay ¶ added in v0.0.4
func (pr *Parameters) ShouldDisplay(field string) bool
func (*Parameters) Update ¶
func (pr *Parameters) Update()
type ParticleVars ¶ added in v0.0.6
type ParticleVars int32 //enums:enum -trim-prefix=Particle
ParticleVars are the particle variables to record.
const ( // ParticleType is the type or ID of the particle ParticleType ParticleVars = iota // ParticleMass is the rest mass of the particle. ParticleMass // Position ParticlePosX ParticlePosY ParticlePosZ // Velocity ParticleVelX ParticleVelY ParticleVelZ // ParticleLorentz is the Lorentz factor. ParticleLorentz // ParticleESq is the squared energy of the particle. ParticleESq )
const ParticleVarsN ParticleVars = 10
ParticleVarsN is the highest valid value for type ParticleVars, plus one.
func ParticleVarsValues ¶ added in v0.0.6
func ParticleVarsValues() []ParticleVars
ParticleVarsValues returns all possible values for the type ParticleVars.
func (ParticleVars) Desc ¶ added in v0.0.6
func (i ParticleVars) Desc() string
Desc returns the description of the ParticleVars value.
func (ParticleVars) Int64 ¶ added in v0.0.6
func (i ParticleVars) Int64() int64
Int64 returns the ParticleVars value as an int64.
func (ParticleVars) MarshalText ¶ added in v0.0.6
func (i ParticleVars) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*ParticleVars) SetInt64 ¶ added in v0.0.6
func (i *ParticleVars) SetInt64(in int64)
SetInt64 sets the ParticleVars value from an int64.
func (*ParticleVars) SetString ¶ added in v0.0.6
func (i *ParticleVars) SetString(s string) error
SetString sets the ParticleVars value from its string representation, and returns an error if the string is invalid.
func (ParticleVars) String ¶ added in v0.0.6
func (i ParticleVars) String() string
String returns the string representation of this ParticleVars value.
func (*ParticleVars) UnmarshalText ¶ added in v0.0.6
func (i *ParticleVars) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (ParticleVars) Values ¶ added in v0.0.6
func (i ParticleVars) Values() []enums.Enum
Values returns all possible values for the type ParticleVars.
type PlaneMesh ¶
PlaneMesh is a xyz.Mesh that represents an X-Y plane through the state, as either a Heightfield or bars. It is dynamically updated using the Set method. The geometry is literal in the size: 0,0,0 lower-left corner and increasing X,Z in display for the X,Y plane. Display applies an overall scaling to make it fit within the larger view.
func NewPlaneMesh ¶
NewPlaneMesh adds PlaneMesh mesh to given scene for given layer
type Scene ¶
Scene is a Widget for managing the 3D Scene of the NetView
func NewScene ¶
NewScene returns a new Scene with the given optional parent: Scene is a Widget for managing the 3D Scene of the NetView
func (*Scene) MouseDownEvent ¶
func (*Scene) PlaneUnitAtPoint ¶ added in v0.0.6
type Settings ¶
type Settings struct {
// Number of different panels, each capable of displaying a different variable, mode,
// and location in the state.
NPanels NPanels
// TrackParticle is the particle number to track: -1 = not
TrackParticle int
// Mode is how the state values are displayed.
Mode ViewModes
// Height is how high the values are, in normalized units.
Height float32
// Camera specifies the initial camera view to show the scene
// 1 = default = top-down, 2 = side-long
Camera int
// size of a single bar element, where 1 = full width and no space.. .9 default
BarSize float32 `min:"0.1" max:"1" step:"0.1" default:"0.9"`
// name of color map to use
ColorMap core.ColorMapName `display:"-"`
// size of the labels
LabelSize float32 `min:"0.01" max:".1" step:"0.01" default:"0.05"`
// opacity (0-1) of zero values. greater magnitude values become increasingly
// opaque on either side of this minimum.
ZeroAlpha float32 `min:"0" max:"1" step:"0.1" default:"0.5"`
}
Settings for how the View is rendered.
type Sim ¶
type Sim struct {
// Params contains the current simulation parameters.
Params *Parameters `display:"add-fields"`
// Config contains the broader running configuration.
Config *Config `display:"add-fields"`
// Units convert between real-world SI units and per-cube computational units.
Units Units `new-window:"+" display:"no-inline"`
// ConfigFunc is run at initial configuration, after all default configuration,
// and can then change any parameters etc.
ConfigFunc func(sim *Sim) `display:"-"`
// InitFunc is run at initialization, and should be used to set
// the initial State, using functions in init.
InitFunc func(sim *Sim) `display:"-"`
// StatFuncs are the stats functions that have been added.
StatFuncs []func(init bool) `display:"-"`
// Root is the root tensorfs directory, where all stats and other misc sim data goes.
Root *tensorfs.Node `display:"-"`
// Stats has the stats directory within Root.
Stats *tensorfs.Node `display:"-"`
// Current has the current stats values within Stats.
Current *tensorfs.Node `display:"-"`
// GUI manages all the GUI elements
GUI GUI // `display:"-"`
// StateVars points the current state variables in effect.
StateVars enums.Enum `display:"-"`
// Rand is the random number generator for the network.
// all random calls must use this.
// Set seed here for weight initialization values.
Rand randx.Rand `display:"-"`
// Random seed to be set at the start of configuring
// the network and initializing the weights.
// Set this to get a different set of weights.
RandSeed int64 `display:"-"`
// RandSeeds is a list of random seeds to use for each run.
RandSeeds randx.Seeds `display:"-"`
// contains filtered or unexported fields
}
Sim contains everything for the simulation.
func (*Sim) ConfigState ¶
func (ss *Sim) ConfigState()
func (*Sim) ConfigVars ¶
func (ss *Sim) ConfigVars()
func (*Sim) CopyCurToPrev ¶
func (ss *Sim) CopyCurToPrev()
CopyCurToPrev copies the current values to previous values for all variables.
func (*Sim) DiracConfig ¶ added in v0.0.5
func (ss *Sim) DiracConfig()
func (*Sim) Init ¶
func (ss *Sim) Init()
Init initializes the state and prepares everything for running.
func (*Sim) InitRandSeed ¶
func (*Sim) InvR ¶ added in v0.0.5
InvR adds 1/r values radiating from given center point, with peak point as given value.
func (*Sim) InvRDrive ¶ added in v0.0.6
InvRDrive adds pow(decay, r) values radiating from given center point, with peak point as given value, which is used for the drive value in the spinfield model.
func (*Sim) KleinGordonCConfig ¶ added in v0.0.5
func (ss *Sim) KleinGordonCConfig()
func (*Sim) KleinGordonConfig ¶ added in v0.0.4
func (ss *Sim) KleinGordonConfig()
func (*Sim) MaxwellConfig ¶ added in v0.0.5
func (ss *Sim) MaxwellConfig()
func (*Sim) MovingWavePacket ¶
func (ss *Sim) MovingWavePacket(posVar, velVar enums.Enum, dim math32.Dims, ctr math32.Vector3, dir, wavelength, width, phase, amp float32)
MovingWavePacket adds a gaussian * cosine wave packet along given dimension, with given parameters, to both the position and velocity variables in current and previous states, which results in a single wave packet moving in given direction.
func (*Sim) MovingWavePacketConfig ¶ added in v0.0.5
func (ss *Sim) MovingWavePacketConfig(posVar, velVar enums.Enum, dim math32.Dims, ctr math32.Vector3, dir, phase, amp float32)
MovingWavePacketConfig is a version of [MovingWavePacket] that takes its wavelength and width variables from Config
func (*Sim) OpenState ¶ added in v0.0.4
OpenState opens the state from given file. If filename ends in .gz, it is un-gzipped.
func (*Sim) ParticleAt ¶ added in v0.0.5
ParticleAt adds a particle at given point, setting the normalized particle velocity factors.
func (*Sim) ParticleAtConfig ¶ added in v0.0.5
ParticleAtConfig is a version of ParticleAt that sets Velocity from Config
func (*Sim) ParticleField ¶ added in v0.0.6
ParticleField sets field parameters for particle at given position.
func (*Sim) ParticleStats ¶ added in v0.0.6
func (ss *Sim) ParticleStats()
func (*Sim) Point ¶ added in v0.0.5
Point adds value to individual point, optionally for both cur and previous values.
func (*Sim) PosWavePacket ¶ added in v0.0.4
func (ss *Sim) PosWavePacket(vr enums.Enum, dim math32.Dims, ctr math32.Vector3, dir, wavelength, width, phase, amp float32)
PosWavePacket adds a gaussian * cosine wave packet along given dimension, with given parameters, to just the current and previous position variables. This will produce two moving wave packets that split off into opposite directions.
func (*Sim) PosWavePacketConfig ¶ added in v0.0.5
func (ss *Sim) PosWavePacketConfig(vr enums.Enum, dim math32.Dims, ctr math32.Vector3, dir, phase, amp float32)
PosWavePacketConfig is a version of [PosWavePacket] that gets parameters from Config
func (*Sim) Run ¶
func (ss *Sim) Run()
Run runs until stopped or Step > MaxSteps. Must be called by goroutine.
func (*Sim) SaveState ¶ added in v0.0.4
SaveState saves the state to given file. If filename ends in .gz, it is gzipped.
func (*Sim) SchrodingerConfig ¶ added in v0.0.4
func (ss *Sim) SchrodingerConfig()
func (*Sim) SchrodingerStats ¶ added in v0.0.5
func (ss *Sim) SchrodingerStats()
func (*Sim) SpinfieldConfig ¶ added in v0.0.6
func (ss *Sim) SpinfieldConfig()
func (*Sim) SpinfieldStats ¶ added in v0.0.6
func (ss *Sim) SpinfieldStats()
func (*Sim) StatParticle ¶ added in v0.0.6
StatParticle is a stats function that records particle state for given particle index.
func (*Sim) StatSum ¶ added in v0.0.5
StatSum is a stats function that records sum of given variable for current state.
func (*Sim) StepRun ¶
func (ss *Sim) StepRun()
StepRun does one step of running. Must be called from goroutine.
func (*Sim) UpdateUnits ¶ added in v0.0.5
func (ss *Sim) UpdateUnits()
UpdateUnits updates Units from Params and vice-versa.
func (*Sim) UpdateView ¶
func (ss *Sim) UpdateView()
func (*Sim) ViewInit ¶
ViewInit adds given function to view initialization functions. Called in reverse of order added. Equations typically set default init for specific equations (e.g., variable), added at the end.
func (*Sim) WaveConfig ¶
func (ss *Sim) WaveConfig()
type SpinfieldStates ¶ added in v0.0.6
type SpinfieldStates CabStates //enums:enum -trim-prefix=Spinfield
SpinfieldStates are the state variables for the spinfield model.
const ( // SpinfieldParticle indicates the type of particle present at this cell. // zero indicates no particle. SpinfieldParticle SpinfieldStates = SpinfieldStates(CabStatesN) + iota // SpinfieldPvelX is the particle velocity (proportion of c, [-1..1]) along X axis SpinfieldPvelX // SpinfieldPvelY is the particle velocity (proportion of c, [-1..1]) along Y axis SpinfieldPvelY // SpinfieldPvelZ is the particle velocity (proportion of c, [-1..1]) along Z axis SpinfieldPvelZ // SpinfieldPESq is the square of the particle energy. SpinfieldPESq // SpinfieldDist is the 1/r distance propagated from the source particle. SpinfieldDist // SpinfieldDrive is the coupling strength of particle field to wave fields. // Computed from Dist. SpinfieldDrive // Spinfield0a is the core spin complex-valued oscillator, a. Spinfield0a // Spinfield0b is the core spin complex-valued oscillator, b. Spinfield0b // SpinfieldXa is the complex-valued oscillator for velocity // along the X asis, a. Phase relative to 0 determines velocity. SpinfieldXa // SpinfieldXb is the complex-valued oscillator for velocity // along the X asis, b. Phase relative to 0 determines velocity. SpinfieldXb // SpinfieldXa is the complex-valued oscillator for velocity // along the Y asis, a. Phase relative to 0 determines velocity. SpinfieldYa // SpinfieldXb is the complex-valued oscillator for velocity // along the Y asis, b. Phase relative to 0 determines velocity. SpinfieldYb // SpinfieldXa is the complex-valued oscillator for velocity // along the Z asis, a. Phase relative to 0 determines velocity. SpinfieldZa // SpinfieldXb is the complex-valued oscillator for velocity // along the Z asis, b. Phase relative to 0 determines velocity. SpinfieldZb )
const SpinfieldStatesN SpinfieldStates = 30
SpinfieldStatesN is the highest valid value for type SpinfieldStates, plus one.
func SpinfieldStatesValues ¶ added in v0.0.6
func SpinfieldStatesValues() []SpinfieldStates
SpinfieldStatesValues returns all possible values for the type SpinfieldStates.
func (SpinfieldStates) Desc ¶ added in v0.0.6
func (i SpinfieldStates) Desc() string
Desc returns the description of the SpinfieldStates value.
func (SpinfieldStates) Int64 ¶ added in v0.0.6
func (i SpinfieldStates) Int64() int64
Int64 returns the SpinfieldStates value as an int64.
func (SpinfieldStates) MarshalText ¶ added in v0.0.6
func (i SpinfieldStates) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*SpinfieldStates) SetInt64 ¶ added in v0.0.6
func (i *SpinfieldStates) SetInt64(in int64)
SetInt64 sets the SpinfieldStates value from an int64.
func (*SpinfieldStates) SetString ¶ added in v0.0.6
func (i *SpinfieldStates) SetString(s string) error
SetString sets the SpinfieldStates value from its string representation, and returns an error if the string is invalid.
func (SpinfieldStates) String ¶ added in v0.0.6
func (i SpinfieldStates) String() string
String returns the string representation of this SpinfieldStates value.
func (*SpinfieldStates) UnmarshalText ¶ added in v0.0.6
func (i *SpinfieldStates) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (SpinfieldStates) Values ¶ added in v0.0.6
func (i SpinfieldStates) Values() []enums.Enum
Values returns all possible values for the type SpinfieldStates.
type Units ¶
type Units struct {
// ComptonE is the compton hbar wavelength of an electron in cubic elements,
// i.e., how many cubes long is the Compton wavelength of the electron.
// This fixes the length dimension of a cube, as the inverse of this times
// the numerical value of this quantity (LambdaBarE).
ComptonE float64 `default:"16" min:"4"`
// C is the speed of light in a vacuum in units of cube length / time step.
// For Dirac waves, 0.5 is the maximum stable value. This fixes the time
// scale given the length scale from ComptonE.
C float64
// Hbar = h / 2pi = reduced Planck constant, which determines the mass scale
// given length (from ComptonE) and time (from C).
Hbar float64
// E is the electric charge constant in cubic units, which determines the
// electric potential units, C = A s
// 0.302822 causes Mu0 and Eps0 to both be 1, if C and Hbar are both 1
E float64
// EMass is the rest mass of the electron, in cubic units.
EMass float64 `edit:"-"`
// Mu0 is the computed Mu0 magnetic constant, permeability of free space
// N/A^2 = m kg / s^2 A^2
Mu0 float64 `edit:"-"`
// Eps0 is the computed Eps0 electric constant, permittivity of free space
// F/m = (s^4 A^2) / (m^3 kg)
Eps0 float64 `edit:"-"`
// CuM is the computed length of a cubic element, in meters.
CuM float64 `edit:"-"`
// CuS is the computed duration of a time step update, in seconds.
CuS float64 `edit:"-"`
// CuKg is the computed cube unit of mass, in Kg.
CuKg float64 `edit:"-"`
// CuN is the computed unit of force, in Newtons: kg m / s^2.
CuN float64 `edit:"-"`
// CuJ is the computed unit of energy, in Joules: N m = kg m^2 / s^2.
CuJ float64 `edit:"-"`
// CuW is the computed unit of power, in Watts: J / s = kg m^2 / s^3.
CuW float64 `edit:"-"`
// CuA is the computed unit of current, in Ampheres: A = C / s; Esi / (E * S).
CuA float64 `edit:"-"`
// CuC is the computed cube unit of charge, in Coulombs: C = A * s.
CuC float64 `edit:"-"`
// CuV is the computed unit of electrical potential, in Volts: V = W / A = kg m^2.
CuV float64 `edit:"-"`
// CuF is the computed unit of capacitance, in Farads = C / V: 1/kg 1/m^2 s^4 A^2
CuF float64 `edit:"-"`
// Csi is the speed of light, m/s
Csi float64 `edit:"-"`
// Hbar is the normalized Planck constant h / (2 Pi) = J s = m^2 kg / s
HbarSi float64 `edit:"-"`
// Esi is the unit of electrical charge: C = A s
Esi float64 `edit:"-"`
// EMassSi is the electron rest mass kg
EMassSi float64 `edit:"-"`
// Mu0 is the magnetic constant, permeability of free space
// N/A^2 = (m kg) / (s^2 A^2)
Mu0si float64 `edit:"-"`
// Eps0 is the electric constant, permittivity of free space = 1 / (mu0 c^2)
// F/m = (s^4 A^2) / (m^3 kg)
Eps0si float64 `edit:"-"`
// Alpha is the fine structure constant: e^2 / (hbar c 4pi eps0) (dimensionless)
Alpha float64 `edit:"-"`
// LambdaEsi is the Compton wavelength of the electron rest mass:
// h / (m0 c) = (2 pi hbar) / (m0 c) = 2.42631e-12 m
LambdaEsi float64 `edit:"-"`
// LambdaBarEsi is the Compton wavelength of the electron rest mass in hbar
// hbar / (m0 c) = 3.8615926771197e-13 m
LambdaBarEsi float64 `edit:"-"`
// A0 is the Bohr radius in hbar: hbar / (m0 c alpha) = 5.2917720859e-11 m
A0si float64 `edit:"-"`
}
Units establishes a consistent set of units for computing physics-based [Parameter] factors. Length units are in terms of individual cubic elements.
type VarSettinger ¶
type VarSettinger interface {
SetVarSettings(vs *VarSettings)
}
VarSettinger sets variable parameters
type VarSettings ¶
type VarSettings struct {
// the variable
Var enums.Enum
// keep Min - Max centered around 0, and use negative heights for units
// else use full min-max range for height (no negative heights)
ZeroCtr bool
// range to display
Range minmax.Range32 `display:"inline"`
// if not using fixed range, this is the actual range of data
MinMax minmax.F32 `display:"inline"`
}
VarSettings holds parameters for display of each variable
func (*VarSettings) Defaults ¶
func (vs *VarSettings) Defaults()
Defaults sets default values if otherwise not set
type View ¶
type View struct {
core.Frame
// Var determines the set of variables being used.
// actual variable to view is in the PanelView.
Var enums.Enum `set:"-"`
// Pannels are the view settings per panel (4 max).
Panels [4]PanelView
// Starting front-left corner location within state.
Start math32.Vector3i
// Size of planes
Size math32.Vector3i
// parameters for the list of variables to view
VarSettings map[enums.Enum]*VarSettings
// Settings are parameters controlling how the view is rendered
Settings Settings
// Counters are displayed at the bottom: time, etc.
Counters string `set:"-" display:"-"`
sync.Mutex
// contains filtered or unexported fields
}
View is a Cogent Core Widget that provides a 3D view into state.
func NewView ¶
NewView returns a new View with the given optional parent: View is a Cogent Core Widget that provides a 3D view into state.
func (*View) GetVarSettings ¶ added in v0.0.3
func (vw *View) GetVarSettings(vr enums.Enum) (*VarSettings, error)
func (*View) GetVarSettingsPanel ¶ added in v0.0.3
func (vw *View) GetVarSettingsPanel(panelNo int) (*VarSettings, error)
func (*View) GoUpdateView ¶
func (vw *View) GoUpdateView()
GoUpdateView is the update call to make from another go routine it does the proper blocking to coordinate with GUI updates generated on the main GUI thread.
func (*View) MakeToolbar ¶
func (*View) MakeViewbar ¶
func (*View) PlaneAtNumber ¶
PlaneAtNumber returns the xyz.Group that represents given plane number. nil if not found.
func (*View) RebuildView ¶ added in v0.0.5
func (vw *View) RebuildView()
RebuildView does a full update and then rebuild of view data
func (*View) SelectCamera ¶ added in v0.0.3
SelectCamera selects the given pre-configured camera view, which have different angles. 1= top-down, 2 = head-on
func (*View) SetCounters ¶
SetCounters sets the counters widget view display at bottom of netview
func (*View) SetCurPrev ¶
SetCurPrev sets the current vs. previous state viewing
func (*View) SetMode ¶
SetMode sets the display mode for given panel number. if panelNo < 0 then sets default for all panels.
func (*View) SetPanels ¶
SetPanels sets the View.Panels: Pannels are the view settings per panel (4 max).
func (*View) SetSettings ¶
SetSettings sets the View.Settings: Settings are parameters controlling how the view is rendered
func (*View) SetStart ¶
SetStart sets the View.Start: Starting front-left corner location within state.
func (*View) SetVar ¶
SetVar sets the variable to view and updates the display, for given panel number. If panelNo is -1, then this sets the global default for all panels, and doesn't update display.
func (*View) SetVarMinMax ¶ added in v0.0.3
SetVarMinMax sets the min and max range for given variable.
func (*View) SetVarSettings ¶
func (t *View) SetVarSettings(v map[enums.Enum]*VarSettings) *View
SetVarSettings sets the View.VarSettings: parameters for the list of variables to view
func (*View) UpdateImpl ¶
func (vw *View) UpdateImpl()
UpdateImpl does the guts of updating -- backend for Update or GoUpdate
func (*View) UpdatePlanes ¶
func (vw *View) UpdatePlanes()
UpdatePlanes updates the planes display with any structural or current data changes. Very fast if no structural changes.
func (*View) UpdateView ¶
func (vw *View) UpdateView()
UpdateView updates the display based on last recorded state of network.
func (*View) ValColor ¶
ValColor returns the raw value, scaled value, and color representation for given raw value
func (*View) VarsListUpdate ¶
func (vw *View) VarsListUpdate()
VarsListUpdate updates the list of network variables
func (*View) ViewDefaults ¶
ViewDefaults are the default 3D view params
func (*View) ZoomInSize ¶ added in v0.0.5
func (*View) ZoomOutSize ¶ added in v0.0.5
type ViewModes ¶
type ViewModes int32 //enums:enum
ViewModes are different ways of displaying wave states.
const ViewModesN ViewModes = 2
ViewModesN is the highest valid value for type ViewModes, plus one.
func ViewModesValues ¶
func ViewModesValues() []ViewModes
ViewModesValues returns all possible values for the type ViewModes.
func (ViewModes) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*ViewModes) SetString ¶
SetString sets the ViewModes value from its string representation, and returns an error if the string is invalid.
func (*ViewModes) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type WaveStates ¶
type WaveStates int32 //enums:enum -trim-prefix=Wave
WaveStates are the state variables for Wave equations.
const ( // WavePos is the position (height) wave state variable. WavePos WaveStates = iota // WaveVel is the velocity of wave state variable. WaveVel // WaveForce is the net force computed from neighbors. WaveForce // WaveKinetic is the kinetic energy. WaveKinetic // WavePotential is the potential energy. WavePotential // WaveEnergy is the total kinetic + potential energy. WaveEnergy )
const WaveStatesN WaveStates = 6
WaveStatesN is the highest valid value for type WaveStates, plus one.
func WaveStatesValues ¶
func WaveStatesValues() []WaveStates
WaveStatesValues returns all possible values for the type WaveStates.
func (WaveStates) Desc ¶
func (i WaveStates) Desc() string
Desc returns the description of the WaveStates value.
func (WaveStates) Int64 ¶
func (i WaveStates) Int64() int64
Int64 returns the WaveStates value as an int64.
func (WaveStates) MarshalText ¶
func (i WaveStates) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*WaveStates) SetInt64 ¶
func (i *WaveStates) SetInt64(in int64)
SetInt64 sets the WaveStates value from an int64.
func (*WaveStates) SetString ¶
func (i *WaveStates) SetString(s string) error
SetString sets the WaveStates value from its string representation, and returns an error if the string is invalid.
func (WaveStates) SetVarSettings ¶
func (ws WaveStates) SetVarSettings(vs *VarSettings)
func (WaveStates) String ¶
func (i WaveStates) String() string
String returns the string representation of this WaveStates value.
func (*WaveStates) UnmarshalText ¶
func (i *WaveStates) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (WaveStates) Values ¶
func (i WaveStates) Values() []enums.Enum
Values returns all possible values for the type WaveStates.