Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

** Community Tip** - New to the community? Learn how to post a question and get help from PTC and industry experts!
X

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Apr 18, 2021
09:12 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 18, 2021
09:12 PM

Square Wave as ODE Forcing Function

hi,

i wanted to use a square wave to drive a mass spring damper system. i usually use the state space solver, as it has worked better than the other solvers. however, in this case, i get an error. note, the worksheet isn't fully setup yet, due to the error. i was trying to make an example, since there aren't any quick sheets for a square wave.

thanks,

anthony

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

Apr 18, 2021
11:44 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

6 REPLIES 6

Apr 18, 2021
10:48 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 18, 2021
10:48 PM

Hi,

See enclosed working file with comment in blue.

Cheers

Terry

Apr 18, 2021
11:44 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 19, 2021
05:19 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 19, 2021
05:19 AM

hi terry,

thanks. your second post is what i was going for. that's a strange quirk. i tried something similar, before i posted the question, but it didn't work for me. it's working now though. you're help has allowed me to move forward with the example. once i get it finished, i'll post the file.

anthony

Apr 19, 2021
09:19 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 19, 2021
09:19 AM

so i'm still having some weird things happen. i attached an updated file. there are three questions in the file.

the state space solver help doesn't say what the last column of the solution is. i'm thinking it might be velocity but i'm not sure about that. i can't plot the square wave using time for some reason. also if you try to see what it is, it comes back as a constant, which makes no sense.

to avoid confusion from my original post, i made u1 the cosine wave and u2 the square wave. there is no problem with the cosine wave. the point of this example was to try and use a square wave. luc had previously posted an interesting solution for creating a square wave. i made some slight modifications to what luc posted. however, there seems to be a lot of problems actually using the square wave with the state space solver.

i figured out the answer to two of the questions. for some reason, you have to use the vectorize feature on the square wave but not the cosine wave. so the only remaining question is what is the last column of the state space solution matrix.

Apr 19, 2021
01:35 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 19, 2021
01:35 PM

Hi,

Plot u2 now OK.

u2(t) is not a constant?

not sure about velocity?

enclosed file.

Cheers

Terry

Apr 19, 2021
08:13 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 19, 2021
08:13 PM

it looks like the last column of the state space output might be velocity. however, i get a lot of error when using the time and displacement output to calculate velocity and acceleration. if the last column is velocity, there doesn't seem to be a way to confirm it. i'm trying odesolve instead. it makes it easy to calculate v, a, and kinetic energy. however, it also introduces other problems. lastly, the state space results and the odesolve results are drastically different. so running into a lot of problems.

update; i found the problem with the state space solver not matching odesolve. it had to do with how the quick sheets i used were setup. there is still the problem of the velocity from the state space solver being different than if you manually calculate it. there is no information on how it is calculated. therefore, odesolve would be better in that regard.