core

package
v0.0.0-...-082c65a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinFlowRate     = 0.0   // 最小流动率
	MaxFlowRate     = 1.0   // 最大流动率
	DefaultCapacity = 100.0 // 默认容量
)

EnergyNetworkConstants 能量网络常数

View Source
const (
	MinEnergy       = 0.0    // 最小能量
	MaxEnergy       = 1000.0 // 最大能量
	EntropyFactor   = 0.01   // 熵增因子
	DissipationRate = 0.05   // 能量耗散率
	DefaultBalance  = 1.0    // 默认平衡度
)

能量系统常量

View Source
const (
	// 场强度限制
	MinFieldStrength = 0.0
	MaxFieldStrength = 100.0

	// 相互作用常数
	InteractionConstant = 8.987551787e9 // 库仑常数
	GravityConstant     = 6.67430e-11   // 引力常数

	// 场的特征尺度
	DefaultGridSize = 32    // 默认场网格大小
	MinWaveLength   = 1e-10 // 最小波长(m)
	MaxWaveLength   = 1e3   // 最大波长(m)
)

场的基本常数

View Source
const (
	G              = 9.80665        // 重力加速度 (m/s²)
	StdTemperature = 298.15         // 标准温度 (K)
	StdPressure    = 101.325        // 标准大气压 (kPa)
	StdDensity     = 1.0            // 标准密度 (kg/m³)
	SpecificHeat   = 4186.0         // 比热容 J/(kg·K)
	BoltzmannConst = 1.380649e-23   // 玻尔兹曼常数
	PlanckConst    = 6.62607015e-34 // 普朗克常数
)

定义常量

View Source
const (
	MinCoupling     = 0.0 // 最小耦合强度
	MaxCoupling     = 1.0 // 最大耦合强度
	DefaultCoupling = 0.5 // 默认耦合强度
)

InteractionConstants 相互作用常数

View Source
const (
	// 演化模式常量
	PatternIntegrate QuantumPattern = "integrate" // 整合模式
	PatternSplit     QuantumPattern = "split"     // 分裂模式
	PatternCycle     QuantumPattern = "cycle"     // 循环模式
	PatternBalance   QuantumPattern = "balance"   // 平衡模式

	// 量子态常量
	MaxProbability = 1.0
	MinProbability = 0.0
	DefaultPhase   = 0.0
	TwoPi          = 2 * math.Pi
	DefaultEnergy  = 1.0
	DefaultEntropy = 0.0
)

Variables

View Source
var (
	ErrExceedCapacity     = errors.New("energy exceeds system capacity")
	ErrInvalidParameter   = errors.New("invalid parameter value")
	ErrInsufficientEnergy = errors.New("insufficient energy for conversion")
)
View Source
var (
	ErrInvalidQuantumState = errors.New("invalid quantum state")
)

错误定义

View Source
var FlowTypeMap = map[EnergyType]string{
	PotentialEnergy: "potential",
	KineticEnergy:   "kinetic",
	ThermalEnergy:   "thermal",
	FieldEnergy:     "field",
}

FlowTypeMap 能量类型名称映射

Functions

func GetCurrentTimestamp

func GetCurrentTimestamp() int64

GetCurrentTimestamp 获取当前时间戳

func NewCoreError

func NewCoreError(message string) error

NewCoreError 创建新的核心错误

func NewCoreErrorWithCode

func NewCoreErrorWithCode(code ErrorCode, message string) error

NewCoreErrorWithCode 创建带错误码的核心错误

func WrapCoreError

func WrapCoreError(err error, code ErrorCode, message string) error

WrapCoreError 包装错误

Types

type BaseFlow

type BaseFlow struct {
	// contains filtered or unexported fields
}

BaseFlow 提供FlowSource的基础实现

func NewBaseFlow

func NewBaseFlow(config *FlowConfig) *BaseFlow

NewBaseFlow 创建基础流实现

func (*BaseFlow) AddObserver

func (bf *BaseFlow) AddObserver(observer FlowObserver)

AddObserver 添加观察者

func (*BaseFlow) AdjustDirection

func (bf *BaseFlow) AdjustDirection(direction *FlowDirection) error

AdjustDirection 调整方向

func (*BaseFlow) AdjustEnergy

func (bf *BaseFlow) AdjustEnergy(delta float64) error

AdjustEnergy 调节能量

func (*BaseFlow) GetEnergy

func (bf *BaseFlow) GetEnergy() float64

GetEnergy 获取当前能量

func (*BaseFlow) GetState

func (bf *BaseFlow) GetState() FlowState

GetState 获取当前状态

func (*BaseFlow) Initialize

func (bf *BaseFlow) Initialize(ctx context.Context) error

Initialize 实现初始化

func (*BaseFlow) StartFlow

func (bf *BaseFlow) StartFlow(ctx context.Context) error

StartFlow 开始流动

func (*BaseFlow) StopFlow

func (bf *BaseFlow) StopFlow(ctx context.Context) error

StopFlow 停止流动

func (*BaseFlow) Transform

func (bf *BaseFlow) Transform(ctx context.Context, newState FlowState) error

Transform 状态转换

type CoreError

type CoreError struct {
	Message string    // 错误消息
	Code    ErrorCode // 错误码
	Stack   []string  // 错误堆栈
	// contains filtered or unexported fields
}

CoreError 核心错误类型

func (*CoreError) Error

func (e *CoreError) Error() string

Error 实现 error 接口

func (*CoreError) GetCode

func (e *CoreError) GetCode() ErrorCode

GetCode 获取错误码

func (*CoreError) Unwrap

func (e *CoreError) Unwrap() error

Unwrap 实现 errors.Unwrap 接口

type Correlator

type Correlator struct {
	// contains filtered or unexported fields
}

Correlator 关联器

func NewCorrelator

func NewCorrelator() *Correlator

NewCorrelator 创建关联器

func (*Correlator) GetCorrelation

func (c *Correlator) GetCorrelation(key string) float64

GetCorrelation 获取关联强度

func (*Correlator) Initialize

func (c *Correlator) Initialize() error

Initialize 初始化关联器

func (*Correlator) SetCorrelation

func (c *Correlator) SetCorrelation(key string, value float64) error

SetCorrelation 设置关联强度

func (*Correlator) Update

func (c *Correlator) Update() error

Update 更新关联状态

type CorrelatorConfig

type CorrelatorConfig struct {
	DecayTime      float64 // 关联衰减时间
	MaxCorrelation float64 // 最大关联强度
	UpdateInterval float64 // 更新间隔
}

CorrelatorConfig 关联器配置

type CycleManager

type CycleManager struct {
	// contains filtered or unexported fields
}

CycleManager 周期管理器

func NewCycleManager

func NewCycleManager(length int) *CycleManager

NewCycleManager 创建新的周期管理器

func (*CycleManager) Advance

func (cm *CycleManager) Advance() error

Advance 推进周期

func (*CycleManager) Close

func (cm *CycleManager) Close() error

Close 关闭管理器

func (*CycleManager) GetCurrent

func (cm *CycleManager) GetCurrent() int

GetCurrent 获取当前位置

func (*CycleManager) GetEnergy

func (cm *CycleManager) GetEnergy() float64

GetEnergy 获取周期能量

func (*CycleManager) GetPhase

func (cm *CycleManager) GetPhase() float64

GetPhase 获取当前相位

func (*CycleManager) Initialize

func (cm *CycleManager) Initialize() error

Initialize 初始化周期管理器

type CycleState

type CycleState struct {
	Index     int       // 当前周期索引
	Phase     float64   // 当前相位
	Energy    float64   // 周期能量
	Timestamp time.Time // 时间戳
}

CycleState 周期状态

type EnergyFlow

type EnergyFlow struct {
	Source    string  // 源节点
	Target    string  // 目标节点
	Amount    float64 // 流动量
	Timestamp int64   // 时间戳
}

EnergyFlow 能量流动记录

type EnergyNetwork

type EnergyNetwork struct {
	// contains filtered or unexported fields
}

EnergyNetwork 能量网络

func NewEnergyNetwork

func NewEnergyNetwork() *EnergyNetwork

NewEnergyNetwork 创建新的能量网络

func (*EnergyNetwork) AddNode

func (en *EnergyNetwork) AddNode(id string, capacity float64) error

AddNode 添加节点

func (*EnergyNetwork) GetBalance

func (en *EnergyNetwork) GetBalance() float64

GetBalance 获取网络平衡度

func (*EnergyNetwork) GetNodeEnergy

func (en *EnergyNetwork) GetNodeEnergy(id string) (float64, error)

GetNodeEnergy 获取节点能量

func (*EnergyNetwork) GetTotalEnergy

func (en *EnergyNetwork) GetTotalEnergy() float64

GetTotalEnergy 获取总能量

func (*EnergyNetwork) Initialize

func (en *EnergyNetwork) Initialize() error

Initialize 初始化网络

func (*EnergyNetwork) UpdateFlow

func (en *EnergyNetwork) UpdateFlow(from, to string, amount float64) error

UpdateFlow 更新能量流动

type EnergySystem

type EnergySystem struct {
	// contains filtered or unexported fields
}

EnergySystem 能量系统

func NewEnergySystem

func NewEnergySystem(capacity float64) *EnergySystem

NewEnergySystem 创建能量系统

func (*EnergySystem) Convert

func (es *EnergySystem) Convert(from, to EnergyType, amount float64) (float64, error)

Convert 能量转换

func (*EnergySystem) GetBalance

func (es *EnergySystem) GetBalance() float64

GetBalance 获取能量平衡度

func (*EnergySystem) GetEnergy

func (es *EnergySystem) GetEnergy(typ EnergyType) float64

GetEnergy 获取指定类型的能量

func (*EnergySystem) GetEnergyState

func (es *EnergySystem) GetEnergyState() map[string]float64

GetEnergyState 获取能量状态

func (*EnergySystem) GetTotalEnergy

func (es *EnergySystem) GetTotalEnergy() float64

getTotalEnergy 获取总能量(无锁)

func (*EnergySystem) String

func (es *EnergySystem) String() string

String 返回能量系统的字符串表示

func (*EnergySystem) TransformEnergy

func (es *EnergySystem) TransformEnergy(energyMap map[EnergyType]float64) error

TransformEnergy 能量形态转换

type EnergyType

type EnergyType uint8

EnergyType 能量类型

const (
	PotentialEnergy EnergyType = iota // 势能 - 储存能量
	KineticEnergy                     // 动能 - 运动能量
	ThermalEnergy                     // 热能 - 热力学能量
	FieldEnergy                       // 场能 - 场相关能量
)

type ErrorCode

type ErrorCode string

ErrorCode 错误码类型

const (
	// 基础错误
	ErrInvalid    ErrorCode = "INVALID"    // 无效值
	ErrRange      ErrorCode = "RANGE"      // 超出范围
	ErrState      ErrorCode = "STATE"      // 状态错误
	ErrInitialize ErrorCode = "INITIALIZE" // 初始化错误

	// 量子相关错误
	ErrQuantum   ErrorCode = "QUANTUM"   // 量子态错误
	ErrSuperpose ErrorCode = "SUPERPOSE" // 叠加态错误
	ErrEntangle  ErrorCode = "ENTANGLE"  // 纠缠态错误

	// 场相关错误
	ErrField       ErrorCode = "FIELD"       // 场错误
	ErrPotential   ErrorCode = "POTENTIAL"   // 势场错误
	ErrInteraction ErrorCode = "INTERACTION" // 相互作用错误

	// 能量相关错误
	ErrEnergy       ErrorCode = "ENERGY"       // 能量错误
	ErrTransform    ErrorCode = "TRANSFORM"    // 转换错误
	ErrConservation ErrorCode = "CONSERVATION" // 守恒错误
)

type Field

type Field struct {

	// 场的基本属性
	Type      FieldType // 场类型
	Dimension int       // 场维度
	GridSize  int       // 网格大小
	Boundary  []float64 // 边界条件

	// 场的物理量
	Strength  [][]float64  // 场强度分布
	Potential [][]float64  // 势能分布
	Gradient  [][]Vector3D // 梯度分布

	// 场的动态特性
	WaveNumber float64 // 波数
	Frequency  float64 // 频率
	Phase      float64 // 相位

	// 相互作用特性
	Coupling    float64 // 耦合强度
	Interaction float64 // 相互作用强度

	// 阴阳属性
	YinField  *Field // 阴性场
	YangField *Field // 阳性场
	// contains filtered or unexported fields
}

Field 场的基本结构

func NewField

func NewField(fieldType FieldType, dimension int) *Field

NewField 创建新的场

func (*Field) ApplyYinYangSeparation

func (f *Field) ApplyYinYangSeparation(yinRatio float64) error

ApplyYinYangSeparation 应用阴阳分离

func (*Field) CalculateFieldGradient

func (f *Field) CalculateFieldGradient(position Vector3D) Vector3D

CalculateFieldGradient 计算场梯度

func (*Field) CalculateFieldStrength

func (f *Field) CalculateFieldStrength(position Vector3D) float64

CalculateFieldStrength 计算场强度

func (*Field) CalculateInterference

func (f *Field) CalculateInterference(other *Field, position Vector3D) float64

CalculateInterference 计算场的干涉

func (*Field) Evolve

func (f *Field) Evolve() error

Evolve 场演化

func (*Field) GetStrength

func (f *Field) GetStrength() float64

GetStrength 获取平均场强度

func (*Field) GetUniformity

func (f *Field) GetUniformity() float64

GetUniformity 获取场的均匀性

func (*Field) Initialize

func (f *Field) Initialize() error

Initialize 初始化场

func (*Field) Reset

func (f *Field) Reset() error

Reset 重置场到初始状态

func (*Field) SetPhase

func (f *Field) SetPhase(phase float64) error

SetPhase 设置场相位

func (*Field) SetStrength

func (f *Field) SetStrength(strength float64) error

SetStrength 设置场强度

func (*Field) Update

func (f *Field) Update(phase float64) error

Update 使用给定的相位更新场

type FieldType

type FieldType uint8

FieldType 场的类型

const (
	ScalarField FieldType = iota // 标量场
	VectorField                  // 向量场
	TensorField                  // 张量场
)

type Flow

type Flow struct {
	ID        string         // 唯一标识
	Energy    float64        // 能量值(0-100)
	State     FlowState      // 当前状态
	Direction *FlowDirection // 流动方向
	// contains filtered or unexported fields
}

Flow 定义基本流结构

func NewFlow

func NewFlow() *Flow

NewFlow 创建新的流

type FlowConfig

type FlowConfig struct {
	MinEnergy     float64
	MaxEnergy     float64
	FlowInterval  time.Duration
	MaxTransforms int
}

FlowConfig 流的配置

type FlowDirection

type FlowDirection struct {
	X     float64 // X轴方向分量
	Y     float64 // Y轴方向分量
	Z     float64 // Z轴方向分量
	Angle float64 // 方向角度(0-360)
}

FlowDirection 定义流动方向

type FlowEvent

type FlowEvent uint8

FlowEvent 流事件类型

const (
	FlowEventInitialize FlowEvent = iota
	FlowEventStart
	FlowEventStop
	FlowEventTransform
	FlowEventEnergyChange
	FlowEventDirectionChange
)

type FlowObserver

type FlowObserver interface {
	OnFlowEvent(event FlowEvent, flow *Flow)
}

FlowObserver 观察者接口

type FlowPhysics

type FlowPhysics struct {
	// contains filtered or unexported fields
}

FlowPhysics 流体物理特性

func NewFlowPhysics

func NewFlowPhysics() *FlowPhysics

NewFlowPhysics 创建新的流体物理实例

func (*FlowPhysics) ApplyYinYangTransformation

func (fp *FlowPhysics) ApplyYinYangTransformation(yinRatio float64) error

ApplyYinYangTransformation 应用阴阳转化

func (*FlowPhysics) CalculateEntropy

func (fp *FlowPhysics) CalculateEntropy() float64

CalculateEntropy 计算熵变

func (*FlowPhysics) CalculateReynoldsNumber

func (fp *FlowPhysics) CalculateReynoldsNumber(characteristicLength float64) float64

CalculateReynoldsNumber 计算雷诺数

func (*FlowPhysics) GetPhysicsState

func (fp *FlowPhysics) GetPhysicsState() map[string]float64

GetPhysicsState 获取物理状态

type FlowSource

type FlowSource interface {
	// Initialize 初始化流
	Initialize(ctx context.Context) error

	// StartFlow 开始流动
	StartFlow(ctx context.Context) error

	// StopFlow 停止流动
	StopFlow(ctx context.Context) error

	// Transform 状态转换
	Transform(ctx context.Context, newState FlowState) error

	// AdjustEnergy 调节能量
	AdjustEnergy(delta float64) error

	// AdjustDirection 调整方向
	AdjustDirection(direction *FlowDirection) error

	// GetState 获取当前状态
	GetState() FlowState

	// GetEnergy 获取当前能量
	GetEnergy() float64
}

FlowSource 定义流的源接口

type FlowState

type FlowState uint8

FlowState 定义流的状态

const (
	FlowStateVoid         FlowState = iota // 虚无态:初始状态
	FlowStateInactive                      // 未激活态:已创建但未开始流动
	FlowStateFlowing                       // 流动态:正在进行能量流动
	FlowStateStatic                        // 静止态:暂时停止流动
	FlowStateTransforming                  // 转化态:正在进行状态转换
	FlowStateTerminated                    // 终止态:完全停止流动
)

type ForceField

type ForceField struct {
	// contains filtered or unexported fields
}

ForceField 力场定义

type Harmonizer

type Harmonizer struct {
	// contains filtered or unexported fields
}

Harmonizer 和谐器

func NewHarmonizer

func NewHarmonizer() *Harmonizer

NewHarmonizer 创建新的和谐器

func (*Harmonizer) Close

func (h *Harmonizer) Close() error

Close 关闭和谐器

func (*Harmonizer) GetHarmony

func (h *Harmonizer) GetHarmony() float64

GetHarmony 获取总体和谐度

func (*Harmonizer) GetState

func (h *Harmonizer) GetState() HarmonyState

GetState 获取和谐状态

func (*Harmonizer) Initialize

func (h *Harmonizer) Initialize() error

Initialize 初始化和谐器

func (*Harmonizer) SetWeight

func (h *Harmonizer) SetWeight(component string, weight float64)

SetWeight 设置分量权重

func (*Harmonizer) UpdateComponent

func (h *Harmonizer) UpdateComponent(component string, value float64)

UpdateComponent 更新分量和谐度

type HarmonyState

type HarmonyState struct {
	Value      float64            // 和谐值
	Components map[string]float64 // 分项和谐度
}

HarmonyState 和谐状态

type Interaction

type Interaction struct {
	// contains filtered or unexported fields
}

Interaction 相互作用

func NewInteraction

func NewInteraction() *Interaction

NewInteraction 创建新的相互作用

func (*Interaction) GetCoherence

func (i *Interaction) GetCoherence() float64

GetCoherence 获取相干性

func (*Interaction) GetEnergy

func (i *Interaction) GetEnergy() float64

GetEnergy 获取相互作用能量

func (*Interaction) GetStrength

func (i *Interaction) GetStrength() float64

GetStrength 获取作用强度

func (*Interaction) GetType

func (i *Interaction) GetType() InteractionType

GetType 获取相互作用类型

func (*Interaction) Initialize

func (i *Interaction) Initialize() error

Initialize 初始化相互作用

func (*Interaction) Reset

func (i *Interaction) Reset() error

Reset 重置相互作用

func (*Interaction) SetCoupling

func (i *Interaction) SetCoupling(coupling float64) error

SetCoupling 设置耦合强度

func (*Interaction) Update

func (i *Interaction) Update(state1, state2 *QuantumState) error

Update 更新相互作用

type InteractionType

type InteractionType uint8

InteractionType 相互作用类型

const (
	NoInteraction      InteractionType = iota
	WeakInteraction                    // 弱相互作用
	StrongInteraction                  // 强相互作用
	FieldInteraction                   // 场相互作用
	QuantumInteraction                 // 量子相互作用
)

type NetworkNode

type NetworkNode struct {
	ID       string             // 节点标识
	Energy   float64            // 节点能量
	Flows    map[string]float64 // 与其他节点的流动关系
	Capacity float64            // 节点容量
}

NetworkNode 网络节点

type QuantumPattern

type QuantumPattern string

QuantumPattern 量子演化模式

type QuantumState

type QuantumState struct {
	// contains filtered or unexported fields
}

QuantumState 表示一个量子态系统 包含概率幅度、相位以及其他量子特性

func NewQuantumState

func NewQuantumState() *QuantumState

NewQuantumState 创建一个新的量子态

func (*QuantumState) AddEnergy

func (qs *QuantumState) AddEnergy(deltaE float64) error

AddEnergy 增加量子态的能量

func (*QuantumState) Collapse

func (qs *QuantumState) Collapse()

Collapse 量子态坍缩 将量子态坍缩到一个确定态

func (*QuantumState) Evolve

func (qs *QuantumState) Evolve(pattern QuantumPattern) error

Evolve 量子态演化

func (*QuantumState) GetCoherence

func (qs *QuantumState) GetCoherence() float64

GetCoherence 获取量子相干性 相干性与概率幅度和相位的稳定性相关

func (*QuantumState) GetEnergy

func (qs *QuantumState) GetEnergy() float64

GetEnergy 获取能量水平

func (*QuantumState) GetEntropy

func (qs *QuantumState) GetEntropy() float64

GetEntropy 获取系统熵

func (*QuantumState) GetPhase

func (qs *QuantumState) GetPhase() float64

GetPhase 获取量子相位

func (*QuantumState) GetProbability

func (qs *QuantumState) GetProbability() float64

GetProbability 获取概率幅度

func (*QuantumState) Initialize

func (qs *QuantumState) Initialize() error

Initialize 初始化量子态

func (*QuantumState) Reset

func (qs *QuantumState) Reset() error

Reset 重置量子态到初始状态

func (*QuantumState) SetEnergy

func (qs *QuantumState) SetEnergy(energy float64) error

SetEnergy 设置能量水平

func (*QuantumState) SetPhase

func (qs *QuantumState) SetPhase(phase float64) error

SetPhase 设置量子相位

func (*QuantumState) SetProbability

func (qs *QuantumState) SetProbability(p float64) error

SetProbability 设置概率幅度

func (*QuantumState) String

func (qs *QuantumState) String() string

String 返回量子态的字符串表示

func (*QuantumState) Update

func (qs *QuantumState) Update() error

Update 更新量子态

type ResonanceState

type ResonanceState struct {
	Amplitude float64
	Frequency float64
	Phase     float64
	Energy    float64
	Timestamp time.Time
}

ResonanceState 共振状态

type Resonator

type Resonator struct {
	// contains filtered or unexported fields
}

Resonator 共振器

func NewResonator

func NewResonator() *Resonator

NewResonator 创建共振器

func (*Resonator) ApplyResonance

func (r *Resonator) ApplyResonance(state1, state2 *QuantumState, energy float64) error

ApplyResonance 在两个量子态之间应用共振效应

func (*Resonator) GetResonance

func (r *Resonator) GetResonance() float64

GetResonance 获取共振强度

func (*Resonator) Initialize

func (r *Resonator) Initialize() error

Initialize 初始化共振器

func (*Resonator) Update

func (r *Resonator) Update() error

Update 更新共振器状态

type ResonatorConfig

type ResonatorConfig struct {
	BaseFrequency   float64 // 基础频率
	DecayRate       float64 // 衰减率
	CoherenceLength int     // 相干长度
	MaxHistorySize  int     // 历史记录最大长度
}

ResonatorConfig 共振器配置

type Vector3D

type Vector3D struct {
	X, Y, Z float64
}

Vector3D 三维向量

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL