# How to simulate non-linear components in discrete simulation mode?

**URL:** <https://forum.plexim.com/t/how-to-simulate-non-linear-components-in-discrete-simulation-mode/832>\
**Category:** PLECS\
**Tags:** solver, discrete\
**Created:** [August 10, 2020, 7:48am UTC](https://forum.plexim.com/t/how-to-simulate-non-linear-components-in-discrete-simulation-mode/832 "2020-08-10T07:48:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shichenseu](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@shichenseu](https://forum.plexim.com/u/shichenseu)\
**Post date:** [August 10, 2020, 7:48am UTC](https://forum.plexim.com/t/how-to-simulate-non-linear-components-in-discrete-simulation-mode/832/1 "2020-08-10T07:48:25Z")

</div>

I defined a component by myself and I found that I cannot simulate non-linear components in discrete mode,the error message is as follows:

The ‘Discrete state-space’ method cannot be used with circuits that contain nonlinear feedback loops (i.e. controlled electrical sources that depend on electrical meters). Please switch to the ‘Continuous state-space’ method or break the feedback loops.Below is a list of the meters involved:- [MOV\_RC\_Aug\_10/Plant/Algebraic Component2](denied:component:MOV\_RC\_Aug\_10/Plant/Algebraic  
Component2)

But I want to generate code for RT-BOX and c2000 launchpad ,that means I have to use discrete mode, so how can I manage the problem?

---

<div class="post-metadata">

**Author:** ![Bryan\_Lieblick](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/bryan_lieblick/32/10_2.png) [@Bryan\_Lieblick](https://forum.plexim.com/u/Bryan_Lieblick)\
**Post date:** [August 10, 2020, 5:40pm UTC](https://forum.plexim.com/t/how-to-simulate-non-linear-components-in-discrete-simulation-mode/832/2 "2020-08-10T17:40:43Z")

</div>

Based on the error message you are using an Algebraic Component in your model. By definition the Algebraic Component variations introduce an algebraic loop into the model, and the PLECS Coder does not support code generation for models with algebraic loops.

This is documented in the PLECS Documentation under Code Generation + Unsupported Components.

You’ll have to derive an alternative way to create your custom component using controlled sources and measurements, along with any necessary delays in the feedback path to break resulting algebraic loops. When breaking the algebraic loops, note the Discretization Behavior setting of any controlled sources, which can be configured to be first-order or zero-order holds. Refer to the documentation for a more complete description.

---

<div class="post-metadata">

**Author:** ![shichenseu](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@shichenseu](https://forum.plexim.com/u/shichenseu)\
**Post date:** [August 10, 2020, 9:05pm UTC](https://forum.plexim.com/t/how-to-simulate-non-linear-components-in-discrete-simulation-mode/832/3 "2020-08-10T21:05:00Z")

</div>

Thank U so much!
