Beispiel #1
0
        /// <inheritdoc/>
        public override void CreateBehaviors(ISimulation simulation)
        {
            var behaviors = new BehaviorContainer(Name);

            if (Parameters.Entities != null || Parameters.Entities.Count > 0)
            {
                // Create our local simulation and binding context to allow behaviors to do stuff
                var localSim = new ParallelSimulation(simulation, this);
                var context  = new ParallelBindingContext(this, localSim, behaviors);
                Entities.DependencyInjection.DI.Resolve(simulation, this, behaviors, context);

                // Run the simulation
                localSim.Run(Parameters.Entities);

                // Allow the behaviors to fetch the behaviors if they want
                foreach (var behavior in behaviors)
                {
                    if (behavior is IParallelBehavior parallelBehavior)
                    {
                        parallelBehavior.FetchBehaviors(context);
                    }
                }
            }
            simulation.EntityBehaviors.Add(behaviors);
        }
        /// <inheritdoc/>
        public override void CreateBehaviors(ISimulation simulation)
        {
            var behaviors = new BehaviorContainer(Name);

            if (Parameters.Definition != null && Parameters.Definition.Entities.Count > 0)
            {
                // Create our local simulation and binding context to allow our behaviors to do stuff
                var localSim = new SubcircuitSimulation(Name, simulation, Parameters.Definition, NodeMap);
                var context  = new SubcircuitBindingContext(this, localSim, behaviors);
                Entities.DependencyInjection.DI.Resolve(simulation, this, behaviors, context);

                // Run the simulation
                localSim.Run(Parameters.Definition.Entities);

                // Allow the behaviors to fetch the behaviors if they want
                foreach (var behavior in behaviors)
                {
                    if (behavior is ISubcircuitBehavior subcktBehavior)
                    {
                        subcktBehavior.FetchBehaviors(context);
                    }
                }
            }
            simulation.EntityBehaviors.Add(behaviors);
        }
Beispiel #3
0
        /// <summary>
        /// Creates the behaviors and stores them in the specified container.
        /// </summary>
        /// <param name="simulation">The simulation.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="simulation"/> is <c>null</c>.</exception>
        public override void CreateBehaviors(ISimulation simulation)
        {
            var behaviors = new BehaviorContainer(Name);

            simulation.EntityBehaviors.Add(behaviors);
            Entities.DependencyInjection.DI.Resolve(simulation, this, behaviors);
        }
Beispiel #4
0
        public override void CreateBehaviors(ISimulation simulation)
        {
            var eb      = new BehaviorContainer("dF/dx");
            var context = new BindingContext(this, simulation, eb);

            eb.Add(new DerivativeTesterBehavior(context, _reference, _initial, _relTol, _absTol));
            simulation.EntityBehaviors.Add(eb);
        }
            public override void CreateBehaviors(ISimulation simulation)
            {
                var behaviors = new BehaviorContainer(Name);
                var context   = new BindingContext(this, simulation, behaviors);

                behaviors.Add(new Mapper(_nodes, context));
                simulation.EntityBehaviors.Add(behaviors);
            }
Beispiel #6
0
        /// <inheritdoc/>
        public override void CreateBehaviors(ISimulation simulation)
        {
            var behaviors = new BehaviorContainer(Name);
            var context   = new CurrentControlledBindingContext(this, simulation, behaviors);

            behaviors.Build(simulation, context)
            .AddIfNo <ITimeBehavior>(context => new Time(context))
            .AddIfNo <IFrequencyBehavior>(context => new Frequency(context))
            .AddIfNo <IBiasingBehavior>(context => new Biasing(context));
            simulation.EntityBehaviors.Add(behaviors);
        }
Beispiel #7
0
        /// <summary>
        /// Creates the behaviors for the specified simulation and registers them with the simulation.
        /// </summary>
        /// <param name="simulation">The simulation.</param>
        public override void CreateBehaviors(ISimulation simulation)
        {
            var behaviors = new BehaviorContainer(Name);
            var context   = new ComponentBindingContext(this, simulation, behaviors);

            if (simulation.UsesBehaviors <IBiasingBehavior>())
            {
                behaviors.Add(new BiasingBehavior(Name, context));
            }
            simulation.EntityBehaviors.Add(behaviors);
        }
Beispiel #8
0
        /// <inheritdoc/>
        public override void CreateBehaviors(ISimulation simulation)
        {
            var behaviors = new BehaviorContainer(Name);

            if (Parameters.Entities != null || Parameters.Entities.Count > 0)
            {
                // Create our local simulation and binding context to allow behaviors to do stuff
                var localSim = new ParallelSimulation(simulation, this);
                var context  = new ParallelBindingContext(this, localSim, behaviors);

                // Let's create our behaviors
                // Note: we do this first, such that any parallel simulation states can be added to the local simulation
                behaviors.Build(simulation, context)
                .AddIfNo <ITemperatureBehavior>(context => new Temperature(context))
                .AddIfNo <IConvergenceBehavior>(context => new Convergence(context))
                .AddIfNo <IBiasingBehavior>(context => new Biasing(context))
                .AddIfNo <IBiasingUpdateBehavior>(context => new BiasingUpdate(context))
                .AddIfNo <IFrequencyBehavior>(context => new Frequency(context))
                .AddIfNo <IFrequencyUpdateBehavior>(context => new FrequencyUpdate(context))
                .AddIfNo <INoiseBehavior>(context => new ParallelComponents.Noise(context))
                .AddIfNo <ITimeBehavior>(context => new Time(context))
                .AddIfNo <IAcceptBehavior>(context => new Accept(context));

                // Run the simulation
                localSim.Run(Parameters.Entities);

                // Allow the behaviors to fetch the behaviors if they want
                foreach (var behavior in behaviors)
                {
                    if (behavior is IParallelBehavior parallelBehavior)
                    {
                        parallelBehavior.FetchBehaviors(context);
                    }
                }
            }
            simulation.EntityBehaviors.Add(behaviors);
        }
Beispiel #9
0
        /// <inheritdoc/>
        public override void CreateBehaviors(ISimulation simulation)
        {
            var behaviors = new BehaviorContainer(Name);

            if (Parameters.Definition != null && Parameters.Definition.Entities.Count > 0)
            {
                // Create our local simulation and binding context to allow our behaviors to do stuff
                var localSim = new SubcircuitSimulation(Name, simulation, Parameters.Definition, NodeMap);
                var context  = new SubcircuitBindingContext(this, localSim, behaviors);

                // Add the necessary behaviors
                behaviors.Add(new EntitiesBehavior(context));
                behaviors.Build(simulation, context)
                .AddIfNo <ITemperatureBehavior>(context => new Temperature(context))
                .AddIfNo <IAcceptBehavior>(context => new Accept(context))
                .AddIfNo <ITimeBehavior>(context => new Time(context))
                .AddIfNo <IBiasingBehavior>(context => new Biasing(context))
                .AddIfNo <IBiasingUpdateBehavior>(context => new BiasingUpdate(context))
                .AddIfNo <IFrequencyBehavior>(context => new Frequency(context))
                .AddIfNo <IFrequencyUpdateBehavior>(context => new FrequencyUpdate(context))
                .AddIfNo <INoiseBehavior>(context => new Subcircuits.Noise(context));

                // Run the simulation
                localSim.Run(Parameters.Definition.Entities);

                // Allow the behaviors to fetch the behaviors if they want
                foreach (var behavior in behaviors)
                {
                    if (behavior is ISubcircuitBehavior subcktBehavior)
                    {
                        subcktBehavior.FetchBehaviors(context);
                    }
                }
            }
            simulation.EntityBehaviors.Add(behaviors);
        }