Continuous system simulation in Python
Hello, I'm looking for any work/paper/ressource about continuous system simulation using Python or any similar object oriented languages (or even UML theory !). I'm aware of SimPy for discrete event simulation, but I haven't found any work about continuous system. I would like to develop a generic continous system simulator, and so would be eager to join any open source effort on the subject. For instance, it would be useful for modelling an airplane with all the dynamics (flight simulator). Python is my language of choice because of the keyword 'generic'. Being an object oriented dynamic language, it's perfect for such a task. Unfortunately I'm a novice when it comes to object oriented design and development, so I would prefer to start from something already existent instead of starting from scratch. If you had any idea on the subject, I would be really glad to discuss it with you. Thanks in advance, P.S. : for email, replace nowhere by yahoo -- http://mail.python.org/mailman/listinfo/python-list
Re: Continuous system simulation in Python
Hello Phil, Yes I have considered Octave. In fact I'm already using Matlab and decided to 'reject' it for Python + Numeric/numarray + SciPy because I think you could do more in Python and in more simple ways. Problem is that neither Octave, Matlab and Python offer today a framework to build continuous system simulator (in fact Matlab with Simulink and SimMechanics, do propose, but I was not convinced at all). Regards, *** REPLY SEPARATOR *** On 7 Oct 2005 11:00:54 -0700, [EMAIL PROTECTED] wrote : > Nicholas, > > Have you looked at Octave? It is not Python, but I believe it can talk > to Python. > Octave is comparable to Matlab for many things, including having ODE > solvers. I have successfully used it to model and simulate simple > systems. Complex system would be easy to model as well, provided that > you model your dynamic elements with (systems of) differential > equations. > -- http://mail.python.org/mailman/listinfo/python-list
Re: Continuous system simulation in Python
On Thu, 06 Oct 2005 22:30:00 -0700, Robert Kern <[EMAIL PROTECTED]> wrote : > Dennis Lee Bieber wrote: > > On Fri, 7 Oct 2005 01:12:22 +0200, Nicolas Pernetty > > <[EMAIL PROTECTED]> declaimed the following in > > comp.lang.python: > > > > > I'm aware of SimPy for discrete event simulation, but I haven't > > > found any work about continuous system. > > > I would like to develop a generic continous system simulator, and > > > so would be eager to join any open source effort on the subject. > > > > > >For instance, it would be useful for modelling an airplane with all > > > the dynamics (flight simulator). > > > > Unless that flight simulator is running on some big ugly ANALOG > > computer (the ones that used rheostats, transformers, and > > amplifiers), they all are really using discrete time intervals and > > computing values at those time points. Such computation may require > > integration of continuous functions from previous time step to > > current time step. > > I think Nicolas means "(discrete event) simulation" as opposed to > "discrete (event simulation)" and "(continuous system) simulation" as > opposed to "continuous (system simulation)". The methods used in SimPy > to model (discrete events) don't apply terribly well to simulating > many (continuous systems) like airplane dynamics. For example, an ODE > integrator would probably want to adaptively select its timesteps as > opposed to laying out a uniform discretization upfront. > Yes you are absolutely right. That's what I wanted to mean. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Continuous system simulation in Python
Thanks, but what is really difficult is not to understand how to design the program which solve a specific problem but to design a generic framework for solving all these kinds of problem. And in a simple enough way for basic programmers (but good scientists !) to handle it. *** REPLY SEPARATOR *** On 6 Oct 2005 17:04:01 -0700, "hrh1818" <[EMAIL PROTECTED]> wrote : > A good starting point is the book "Python Scripting for Computational > Science" by Hans Petter Langtangen. The book covers topics that go > from simulating second order mechanical systems to solving partial > differentail equations. > > Howard > > Nicolas Pernetty wrote: > > Hello, > > > > I'm looking for any work/paper/ressource about continuous system > > simulation using Python or any similar object oriented languages (or > > even UML theory !). > > > > I'm aware of SimPy for discrete event simulation, but I haven't > > found any work about continuous system. > > I would like to develop a generic continous system simulator, and so > > would be eager to join any open source effort on the subject. > > > > For instance, it would be useful for modelling an airplane with all > > the dynamics (flight simulator). > > > > Python is my language of choice because of the keyword 'generic'. > > Being an object oriented dynamic language, it's perfect for such a > > task. Unfortunately I'm a novice when it comes to object oriented > > design and development, so I would prefer to start from something > > already existent instead of starting from scratch. > > > > If you had any idea on the subject, I would be really glad to > > discuss it with you. > > > > Thanks in advance, > > > > P.S. : for email, replace nowhere by yahoo > -- http://mail.python.org/mailman/listinfo/python-list
Re: Continuous system simulation in Python
Simulink is well fitted for small simulators, but when you run into big projects, I find many shortcomings appears which made the whole thing next to unusable for our kind of projects. That's why I'm interested in Python by the way, it is not a simple clone like Scilab/Scicos. It is a real language which bring its own advantages, and its own shortcomings, which I find well suited for our activity. If you want, I can send you a paper I wrote last year, detailing all Simulink shortcomings. I doubt that this mailing list is interested in such things...(and it's in French...). Concerning Scilab/Scicos, I'm not really interested in a technology primarily developed (INRIA and ENSPC) and used by France. Python and all its libraries and communities are so much more dynamic ! And also I've heard that Scilab was developed in Fortran in a way which make it rigid and that the sources are poorly documented, not a good sign for an open source software (and Scilab isn't 'Free' for the FSF). Regards, *** REPLY SEPARATOR *** On 8 Oct 2005 11:06:25 -0700, "Sébastien Boisgérault" <[EMAIL PROTECTED]> wrote : > > Simulink is a framework widely used by the control engineers ... > It is not *perfect* but the ODEs piece is probably the best > part of the simulator. Why were you not convinced ? > > You may also have a look at Scicos and Ptolemy II. These > simulators are open-source ... but not based on Python. > > Cheers, > > SB > > > > > > Nicolas Pernetty a écrit : > > > Hello Phil, > > > > Yes I have considered Octave. In fact I'm already using Matlab and > > decided to 'reject' it for Python + Numeric/numarray + SciPy because > > I think you could do more in Python and in more simple ways. > > > > Problem is that neither Octave, Matlab and Python offer today a > > framework to build continuous system simulator (in fact Matlab with > > Simulink and SimMechanics, do propose, but I was not convinced at > > all). > > > > Regards, > > > > *** REPLY SEPARATOR *** > > > > On 7 Oct 2005 11:00:54 -0700, [EMAIL PROTECTED] wrote : > > > > > Nicholas, > > > > > > Have you looked at Octave? It is not Python, but I believe it can > > > talk to Python. > > > Octave is comparable to Matlab for many things, including having > > > ODE solvers. I have successfully used it to model and simulate > > > simple systems. Complex system would be easy to model as well, > > > provided that you model your dynamic elements with (systems of) > > > differential equations. > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Continuous system simulation in Python
Hello Phil, I'm currently looking to see if I can build upon SimPy, thus making it an hybrid system simulator. That would be a great step for the community. Main difficulty would be to build a framework which isn't clumsy, like you said. I have close to no experience in Python and object oriented development, but I'm fairly advanced in C and procedural development, and of course in continuous sytem simulator. I'll keep you informed of my investigations... I've downloaded your zip files, but unfortunately I have no access to Windows. Are you able to send me only the sources ? Thanks in advance, *** REPLY SEPARATOR *** On 8 Oct 2005 21:36:05 -0700, [EMAIL PROTECTED] wrote : > Nicholas, > > I have a particular interest in this subject as well. I've also used > the Python/Scipy combination, and it is a tantalizing combination, but > I found it to be a bit more clumsy than I'd like. Plus, my need for > continuous-time simulation is not as great as it has been in the past. > > That said, I've been down this path before (see > http://custom.lab.unb.br/pub/asme/DYNAMICS/BUFORD1.zip), and I would > be interested in helping to develop something. I agree that Python > would be a great foundation to build upon. > -- http://mail.python.org/mailman/listinfo/python-list
Re: Continuous system simulation in Python
> I am aware of some shortcomings and design flaws of Simulink, > especially in the code generation area. I am interested by > your paper nonetheless, please send me copy. Ok no problem. Let me just a few days to strip any irrelevant data on it... > However, Simulink is used by many people on a day-to-day basis > in the context of big, industrial projects. The claim that it > is "next to unusable" is, in my book, an overstatement ... Well the exact sentence is "next to unusable for our kind of projects". You'll see the details on the paper, but I'm not joking. For instance, under Simulink, our model is so big (well not so, but too big for Simulink obviously), that you may have a loss of up to 40x in performance compared to the model in C (how to optimize the Simulink model is a whole other subject in itself). So to make it usable, we have to use automatic code generation wich bring a whole new set of problems... BUT our work is *very* specific, and I'm not talking about Simulink in general. It may be perfect suited for others, it's just that for us it's far from perfect... > Scicos is not perfect either but you can hardly say that is > is a simple clone of Simulink. No time and space to go into > the details ... I wasn't in charge of evaluating Scilab/Scicos, so I can only talk about the conclusion : main motives to switch to Scilab/Scicos would be because it's free, that's all. Report said that next to almost everything Scilab/Scicos does, Matlab/Simulink can do, and more often than not, do it much better. So if you have a different report, I would be happy to read and transmit it... > Obviously, the python community is very dynamic, but how much > support will you get in the very specific topic of continuous > time systems simulation ? Well some people already offered me their help. But I believe that someone _has_ to begin alone some day... Otherwise people who work on continuous system simulation would never be interested in Python. That's the beauty of open source : do what you can, but do it ! and hope that someone else will come one day and use your work to build upon it. Step by step you will have something usable (in theory). > IMHO, an hybrid approach, such as the development of bridge > to include Python components into Simulink/Scicos/Ptolemy/ > Modelica/pick_your_favorite_simulator may grant you more > interest from the simulation community. I already know some bridges like pymat or mlabwrap and I agree that a way to include Python to Matlab/Simulink would be a great step. But : 1) I think that it's Mathworks job to do it, and if they don't want to do it, we'll never have a very good integration. 2) For our kind of projects and our kind of developers (mainly non-IT engineers), I'm very reluctant to introduce too many different technologies in a project. If we decided to go for Python, fine, let's do the entire thing in Python/C. If we decided to go for Simulink, fine, let's do the whole thing in Simulink/Matlab/C. Matlab, for algorithms, can do almost the same things than Python and sometimes much better, so if you have already Simulink (and so have the license) why go for Python and struggle to have a good integration ? Regards, > > Cheers, > > SB > > > > Nicolas Pernetty wrote: > > Simulink is well fitted for small simulators, but when you run into > > big projects, I find many shortcomings appears which made the whole > > thing next to unusable for our kind of projects. > > That's why I'm interested in Python by the way, it is not a simple > > clone like Scilab/Scicos. It is a real language which bring its own > > advantages, and its own shortcomings, which I find well suited for > > our activity. > > > > If you want, I can send you a paper I wrote last year, detailing all > > Simulink shortcomings. I doubt that this mailing list is interested > > in such things...(and it's in French...). > > Concerning Scilab/Scicos, I'm not really interested in a technology > > primarily developed (INRIA and ENSPC) and used by France. Python and > > all its libraries and communities are so much more dynamic ! > > And also I've heard that Scilab was developed in Fortran in a way > > which make it rigid and that the sources are poorly documented, not > > a good sign for an open source software (and Scilab isn't 'Free' for > > the FSF). > > > > Regards, > > > > > > *** REPLY SEPARATOR *** > > > > On 8 Oct 2005 11:06:25 -0700, "Sébastien Boisgérault" > > <[EMAIL PROTECTED]> wrote : > > > > > > > > Simulink is a framework widely used by the control engineers ... > > >
Re: Continuous system simulation in Python
I was implicitly referring to Python/C model for this. I'm aware that Python can be very slow on heavy computations (it's a _documented_ shortcoming), sometimes much slower than Simulink. I believe that no current technology can meet the needs of both rapid prototyping (for projects in their infancy) and performance (for projects in their industrial cycle). That's why, as it is _documented_ and _recommended_ on the Python website, I intend to first prototype with Python then slowly migrate some critical parts to C/C++ as we refine and stabilize the specs. Ideally, at the end of the project, we'll have the best of both worlds. Note that it's the first time that I try this, I may be a perfectly wrong approach for continuous system simulation... *** REPLY SEPARATOR *** On 10 Oct 2005 17:48:39 -0700, "hrh1818" <[EMAIL PROTECTED]> wrote : > In your simulator how much do you want Python to do? I ask this > because your subject title implies you want to write your simulation > code in Python but a simulator written entirely in Python would be > very slow. Python is an interpreted language and pure Python code is > not suitable for simulating big continuous systems. Hence to me it > appears you have two distinct proplems. One is developing a front end, > a user interface, that is easy to use. The other is either finding or > writing a good code compiler that wlll produce fast simulation code or > writing an interface to existing optimize simulation code. Although > most likely not suitable for your applicaion but a good example of > this type of program is Mathematica. It is written in two parts a user > interface and a kernel that does all of the high power math. > > Howard > > > Nicolas Pernetty wrote: > > > I am aware of some shortcomings and design flaws of Simulink, > > > especially in the code generation area. I am interested by > > > your paper nonetheless, please send me copy. > > > > Ok no problem. Let me just a few days to strip any irrelevant data > > on it... > > > > > However, Simulink is used by many people on a day-to-day basis > > > in the context of big, industrial projects. The claim that it > > > is "next to unusable" is, in my book, an overstatement ... > > > > Well the exact sentence is "next to unusable for our kind of > > projects". You'll see the details on the paper, but I'm not joking. > > For instance, under Simulink, our model is so big (well not so, but > > too big for Simulink obviously), that you may have a loss of up to > > 40x in performance compared to the model in C (how to optimize the > > Simulink model is a whole other subject in itself). So to make it > > usable, we have to use automatic code generation wich bring a whole > > new set of problems... BUT our work is *very* specific, and I'm not > > talking about Simulink in general. It may be perfect suited for > > others, it's just that for us it's far from perfect... > > > > > Scicos is not perfect either but you can hardly say that is > > > is a simple clone of Simulink. No time and space to go into > > > the details ... > > > > I wasn't in charge of evaluating Scilab/Scicos, so I can only talk > > about the conclusion : main motives to switch to Scilab/Scicos would > > be because it's free, that's all. Report said that next to almost > > everything Scilab/Scicos does, Matlab/Simulink can do, and more > > often than not, do it much better. > > So if you have a different report, I would be happy to read and > > transmit it... > > > > > Obviously, the python community is very dynamic, but how much > > > support will you get in the very specific topic of continuous > > > time systems simulation ? > > > > Well some people already offered me their help. But I believe > > that someone _has_ to begin alone some day... > > Otherwise people who work on continuous system simulation would > > never be interested in Python. > > > > That's the beauty of open source : do what you can, but do it ! and > > hope that someone else will come one day and use your work to build > > upon it. Step by step you will have something usable (in theory). > > > > > IMHO, an hybrid approach, such as the development of bridge > > > to include Python components into Simulink/Scicos/Ptolemy/ > > > Modelica/pick_your_favorite_simulator may grant you more > > > interest from the simulation community. > > > > I already know some bridges like pymat or mlabwrap and I agree that > > a way to include Python t
Numeric array equivalent of index ?
Hello, I'm trying to find a clear and fast equivalent to the index method of plain python list : >> a = [5,1,4,3,4] >> a.index(4) 2 I have to use it on a Numeric array, so the best I've come up with is (rather ugly I think) : >> from Numeric import array, equal, nonzero >> a = array([5,1,4,3,4]) >> nonzero(equal(a,4))[0] 2 Does someone know of a more Pythonic way ? Thanks, -- http://mail.python.org/mailman/listinfo/python-list
Examples of Python code compared to other languages
Hello, I'm looking (without success so far) for code sources for common problems in different languages, but especially Python, C, Fortran, Ada and Matlab. It would help people coming from other languages to understand the 'python way of thinking'. Priority is clean code, performance is not an issue here because it often leads to obscure code. Ideally code for Python would extensively use the standard library ("don't reinvent the wheel"). I've already checked the following sites, but they were not suited for what I'm looking for : These ones are too focused on performance : http://shootout.alioth.debian.org/ http://dada.perl.it/shootout/ This one don't include C or Fortran : http://pleac.sourceforge.net/ This one is ok but rather limited : http://www.kochandreas.com/home/language/lang.htm If there is a site which regroup very good ('Pythonic') code examples which make extensively use of standard library to resolve common problems, I would be happy to help and try to contribute by giving the equivalent in C code. Regards, -- http://mail.python.org/mailman/listinfo/python-list
Re: Examples of Python code compared to other languages
On 29 Oct 2005 21:27:39 -0700, [EMAIL PROTECTED] wrote : > http://pleac.sourceforge.net/ probably is what you're looking for. It > shows how to to stuff from the perl cookbook in a plethora of other > languages, including Python. > > Kind regards Terji Petersen > Hello, As mentioned in the original message, this site is good but doesn't include C or Fortran. Of course I can try to contribute with C code... Thanks anyway, -- http://mail.python.org/mailman/listinfo/python-list