Student of group 214-19 Olimov Jaloliddin Working with sum product and gain blocks in simulnik package. Independent work I



Yüklə 304,26 Kb.
səhifə2/2
tarix15.04.2023
ölçüsü304,26 Kb.
#98511
1   2
comp1independent work


particular, the compiler
• Evaluates the model’s block parameter expressions to determine their
values.
• Determines signal attributes, e.g., name, data type, numeric type, and
dimensionality, not explicitly specified by the model and checks that each
block can accept the signals connected to its inputs.
• Simulink uses a process called attribute propagation to determine
unspecified attributes. This process entails propagating the attributes of a
source signal to the inputs of the blocks that it drives.
• Performs block reduction optimizations.
• Flattens the model hierarchy by replacing virtual subsystems with the
blocks that they contain (see “Solvers” on page 2-17).
• Sorts the blocks into the order in which they need to be executed during the
execution phase (see “Solvers” on page 2-17).
• Determines the sample times of all blocks in the model whose sample times
you did not explicitly specify.
Determining Block Update Order
During a simulation, Simulink updates the states and outputs of a model’s
blocks once per time step. The order in which the blocks are updated is
therefore critical to the validity of the results. In particular, if a block’s outputs
are a function of its inputs at the current time step, the block must be updated
after the blocks that drive its inputs. Otherwise, the block’s outputs will be
invalid. Simulink sorts the blocks into the correct order during the model
initialization phase.
Direct-Feedthrough Ports. In order to create a valid update ordering, Simulink
categorizes a block’s input ports according to the relationship of outputs to
inputs. An input port whose current value determines the current value of one
of the block’s outputs is called a direct-feedthrough port. Examples of blocks
that have direct-feedthrough ports include the Gain, Product, and Sum blocks.
Examples of blocks that have non-direct-feedthrough inputs include the
Integrator block (its output is a function purely of its state), the Constant block
(it does not have an input), and the Memory block (its output is dependent on
its input in the previous time step).
Block Sorting Rules. Simulink uses the following basic update rules to sort the
blocks:
• Each block must be updated before any of the blocks whose
direct-feedthrough ports it drives.
This rule ensures that the direct-feedthrough inputs to blocks will be valid
when the blocks are updated.
• Blocks that do not have direct feedthrough inputs can be updated in any
order as long as they are updated before any blocks whose direct-feedthrough
inputs they drive.
Putting all blocks that do not have direct-feedthrough ports at the head of
the update list in any order satisfies this rule. It thus allows Simulink to
ignore these blocks during the sorting process.
The result of applying these rules is an update list in which blocks without
direct feedthrough ports appear at the head of the list in no particular order
followed by blocks with direct-feedthrough ports in the order required to supply
valid inputs to the blocks they drive.
During the sorting process, Simulink checks for and flags the occurrence of
algebraic loops, that is, signal loops in which a direct-feedthrough output of a
block is connected directly or indirectly to the corresponding
direct-feedthrough input of the block. Such loops seemingly create a deadlock
condition, because Simulink needs the value of the direct-feedthrough input to
compute the output. However, an algebraic loop can represent a set of
simultaneous algebraic equations (hence the name) where the block’s input
and output are the unknowns. Further, these equations can have valid
solutions at each time step. Accordingly, Simulink assumes that loops
involving direct-feedthrough ports do, in fact, represent a solvable set of
algebraic equations and attempts to solve them each time the block is updated
during a simulation. For more information, see “Algebraic Loops” on page 2-24.
Link Phase
In this phase, the Simulink Engine allocates memory needed for working areas
(signals, states, and run-time parameters) for execution of the block diagram.
It also allocates and initializes memory for data structures that store run-time
information for each block. For built-in blocks, the principal run-time data
structure for a block is called the SimBlock. It stores pointers to a block’s input
and output buffers and state and work vectors.
Method Execution Lists
In the Link phase, the Simulink engine also creates method execution lists.
These lists list the most efficient order in which to execute a model’s block
methods to compute its outputs. Simulink uses the sorted lists generated
during the Compile phase to construct the method execution lists.
Block Priorities
Simulink allows you to assign update priorities to blocks (see “Assigning Block
Priorities” on page 5-20). Simulink executes the output methods of higher
priority blocks before those of lower priority blocks. Simulink honors the
priorities only if they are consistent with its block sorting rules.
Simulation Loop Phase
The simulation now enters the simulation loop phase. In this phase, the
Simulink engine successively computes the states and outputs of the system at
intervals from the simulation start time to the finish time, using information
provided by the model. The successive time points at which the states and
outputs are computed are called time steps. The length of time between steps
is called the step size. The step size depends on the type of solver (see “Solvers”
on page 2-17) used to compute the system’s continuous states, the system’s
fundamental sample time (see “Modeling and Simulating Discrete Systems” on
page 2-31), and whether the system’s continuous states have discontinuities
(see “Zero-Crossing Detection” on page 2-19).
The Simulation Loop phase has two subphases: the Loop Initialization phase
and the Loop Iteration phase. The initialization phase occurs once, at the start
of the loop. The iteration phase is repeated once per time step from the
simulation start time to the simulation stop time.
At the start of the simulation, the model specifies the initial states and outputs
of the system to be simulated. At each step, Simulink computes new values for
the system’s inputs, states, and outputs and updates the model to reflect the
computed values. At the end of the simulation, the model reflects the final
values of the system’s inputs, states, and outputs. Simulink provides data
display and logging blocks. You can display and/or log intermediate results by
including these blocks in your model.
Loop Iteration
At each time step, the Simulink Engine
1 Computes the model’s outputs.
The Simulink Engine initiates this step by invoking the Simulink model
Outputs method.The model Outputs method in turn invokes the model
system Outputs method, which invokes the Outputs methods of the blocks
that the model contains in the order specified by the Outputs method
execution lists generated in the Link phase of the simulation (see “Solvers”
on page 2-17).
The system Outputs method passes the following arguments to each block
Outputs method: a pointer to the block’s data structure and to its SimBlock
structure. The SimBlock data structures point to information that the
Outputs method needs to compute the block’s outputs, including the location
of its input buffers and its output buffers.
2 Computes the model’s states.
The Simulink Engine computes a model’s states by invoking a solver. Which
solver it invokes depends on whether the model has no states, only discrete
states, only continuous states, or both continuous and discrete states.
If the model has only discrete states, the Simulink Engine invokes the
discrete solver selected by the user. The solver computes the size of the time
step needed to hit the model’s sample times. It then invokes the Update
method of the model. The model Update method invokes the Update method
of its system, which invokes the Update methods of each of the blocks that
the system contains in the order specified by the Update method lists
generated in the Link phase.
If the model has only continuous states, the Simulink Engine invokes the
continuous solver specified by the model. Depending on the solver, the solver
either in turn calls the Derivatives method of the model once or enters a
subcycle of minor time steps where the solver repeatedly calls the model’s
Outputs methods and Derivatives methods to compute the model’s outputs
and derivatives at successive intervals within the major time step. This is
done to increase the accuracy of the state computation. The model Outputs
method and Derivatives methods in turn invoke their corresponding system
methods, which invoke the block Outputs and Derivatives in the order
specified by the Outputs and Derivatives methods execution lists generated
in the Link phase.
3 Optionally checks for discontinuities in the continuous states of blocks.
Simulink uses a technique called zero-crossing detection to detect
discontinuities in continuous states. See “Zero-Crossing Detection” on page 2-19 for more information.
4 Computes the time for the next time step.
Simulink repeats steps 1 through 4 until the simulation stop time is reached.
Solvers
Simulink simulates a dynamic system by computing its states at successive
time steps over a specified time span, using information provided by the model.
The process of computing the successive states of a system from its model is
known as solving the model. No single method of solving a model suffices for all
systems. Accordingly, Simulink provides a set of programs, known as solvers,
that each embody a particular approach to solving a model. The Configuration
Parameters dialog box allows you to choose the solver most suitable for your
model (see “Choosing a Solver Type” on page 10-7).
Simulink solvers fall into two basic categories: fixed-step and variable-step.
Fixed-step solvers solve the model at regular time intervals from the beginning
to the end of the simulation. The size of the interval is known as the step size.
You can specify the step size or let the solver choose the step size. Generally,
decreasing the step size increases the accuracy of the results while increasing
the time required to simulate the system.
Variable-step solvers vary the step size during the simulation, reducing the
step size to increase accuracy when a model’s states are changing rapidly and
increasing the step size to avoid taking unnecessary steps when the model’s
states are changing slowly. Computing the step size adds to the computational
overhead at each step but can reduce the total number of steps, and hence
simulation time, required to maintain a specified level of accuracy for models
with rapidly changing or piecewise continuous states.
Continuous Versus Discrete Solvers
Simulink provides both continuous and discrete solvers.
Continuous solvers use numerical integration to compute a model’s continuous
states at the current time step from the states at previous time steps and the
state derivatives. Continuous solvers rely on the model’s blocks to compute the
values of the model’s discrete states at each time step.
Mathematicians have developed a wide variety of numerical integration
techniques for solving the ordinary differential equations (ODEs) that
represent the continuous states of dynamic systems. Simulink provides an
extensive set of fixed-step and variable-step continuous solvers, each
implementing a specific ODE solution method (see “Choosing a Solver Type” on).
Discrete solvers exist primarily to solve purely discrete models. They compute
the next simulation time step for a model and nothing else. They do not
compute continuous states and they rely on the model’s blocks to update the
model’s discrete states.
Tunable Parameters
Many block parameters are tunable. A tunable parameter is a parameter whose
value can change while Simulink is executing a model. For example, the gain
parameter of the Gain block is tunable. You can alter the block’s gain while a
simulation is running. If a parameter is not tunable and the simulation is
running, Simulink disables the dialog box control that sets the parameter.
Simulink allows you to specify that all parameters in your model are
nontunable except for those that you specify. This can speed up execution of
large models and enable generation of faster code from your model. See “Model
Parameter Configuration Dialog Box” on page 10-47 for more information.
Block Sample Times
Every Simulink block is considered to have a sample time, even continuous
blocks (e.g., blocks that define continuous states, such as the Integrator block)
and blocks that do not define states, such as the Gain block. Discrete blocks
allows you to specify their sample times via a Sample Time parameter.
Continuous blocks are considered to have an infinitesimal sample time called
a continuous sample time. A block that is neither discrete or continuous is said
signal(t) = ConstantValue
to have an implicit sample time that it inherits from its inputs. The implicit
sample time is continuous if any of the block’s inputs are continuous.
Otherwise, the implicit sample time is discrete. An implicit discrete sample
time is equal to the shortest input sample time if all the input sample times are
integer multiples of the shortest time. Otherwise, the implicit sample time is
equal to the fundamental sample time of the inputs, where the fundamental
sample time of a set of sample times is defined as the greatest integer divisor
of the set of sample times.
Simulink can optionally color code a block diagram to indicate the sample times
of the blocks it contains, e.g., black (continuous), magenta (constant), yellow
(hybrid), red (fastest discrete), and so on. See “Mixed Continuous and Discrete

Yüklə 304,26 Kb.

Dostları ilə paylaş:
1   2




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin