# Problems solving system in xcos

**URL:** <https://scilab.discourse.group/t/problems-solving-system-in-xcos/364>\
**Category:** Xcos\
**Created:** [January 23, 2024, 10:15am UTC](https://scilab.discourse.group/t/problems-solving-system-in-xcos/364 "2024-01-23T10:15:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aljaz.s55al](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@aljaz.s55al](https://scilab.discourse.group/u/aljaz.s55al)\
**Post date:** [January 23, 2024, 10:15am UTC](https://scilab.discourse.group/t/problems-solving-system-in-xcos/364/1 "2024-01-23T10:15:02Z")

</div>

Hello, I need some help with drawing xcos program to give me graphs of system reacting when specific starting force is aplied.  
I am trying to do this problem for 2 days and I am getting algebraic loop error.  
I need your help!  
Thanks

 ![Posnetek zaslona 2024-01-23 111315](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/6aabd1d0fe40f094c499ae2922f820f720054420.png)

---

<div class="post-metadata">

**Author:** ![aljaz.s55al](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@aljaz.s55al](https://scilab.discourse.group/u/aljaz.s55al)\
**Post date:** [January 23, 2024, 10:15am UTC](https://scilab.discourse.group/t/problems-solving-system-in-xcos/364/2 "2024-01-23T10:15:57Z")

</div>

![image](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/d4eb5b0f541d9344b346a9e5b46ca6c6b43b02fe.png)

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [January 25, 2024, 2:22pm UTC](https://scilab.discourse.group/t/problems-solving-system-in-xcos/364/3 "2024-01-25T14:22:39Z")

</div>

Hello,

This only doable with a Modelica block because the system is not an ode but a dae (differential algebraic equation). Here is the zcos file of Xcos diagram below (\phi is red and x\_V is blue in the screenshot): [cart.zcos](https://scilab.discourse.group/uploads/short-url/cVHm56BXXmOnWTriZfpwefV5AFJ.zcos) (3.6 KB)

 ![Screenshot 2024-01-25 at 15.09.29](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/a80822f392e017dcc0e3953956f07048ea20673b.png)  
The most interesting part is the Modelica script (which is in the last dialog of the block).

```javascript
class cart
      //parameters
      Real x_V ;
      Real v_V ;
      Real phi ;
      Real omega ;
      parameter Real m_V;
      parameter Real m_N;
      parameter Real l ;
      parameter Real g ;
      //input variables
      Real F;
      //output variables
      Real xval,phival;
equation
    xval = x_V;
    phival = phi;
    (m_V+m_N)*der(v_V)-m_N*l*der(omega)*cos(phi)+m_N*l*omega^2*sin(phi)=F;
    l*der(omega)-der(v_V)*cos(phi)=g*sin(phi);
    der(phi)=omega;
    der(x_V)=v_V;
end cart;

```

Status of variables (parameters ,states, inputs or outputs) is set in the first dialogs of the block

 ![Screenshot 2024-01-25 at 15.10.04](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/b703d46f896f8b0d18217bba4695b364bf5665b5.png) as well as the name of the system. It can be replaced by the path of a file containing the source of the modelica script. Values of parameters and initial conditions of the states are given in the next dialog. **Warning** : these values always override the values defined in the Modelica script itself (either in the dialog or in a local file):  
 ![Screenshot 2024-01-25 at 15.10.35](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/1867e407a00c12deb724737458eee71e251fe5d0.png)  
When not in a local file the script is entered in the last dialog:  
 ![Screenshot 2024-01-25 at 15.10.47](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/080ce480f5449c897487dca56d935a508a0c5d14.png)

S.
