Giter Club home page Giter Club logo

bmspy's People

Contributors

astrojuanlu avatar ericonr avatar masfaraud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bmspy's Issues

ODE solving

Hi,
I'm playing with your library and I'm lost in ODE.Evaluate and in DynamicSystem.Simulate.
I guess the main reason is that we were doing it differently in our school.
Could you please give me some link where I could read more about the method you used?
Or at least give me the name of your solution.

Where am I aiming to:
My favourite method of testing ODEs is solving move on a circle.
dx/dt = -y
dy/dt = x
x[0] = 1
y[0] = 0
Ideal result should be:
x = cos(t)
y = sin(t)
And the real result depends on size of time-step and also on the method used.
With better method you can use longer time-step.
In our school we were forced to use Runge-Kutta: https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods

Evaluate called once per output

I'm building Blocks with multiple outputs and I think I found a few issues (see #25)

  1. When more than one output, evaluate is called once per output. See the code below, the simplest case I could come up with. I would expect the print statements at the bottom to be all 0s. If implementing a block with more than one output Evaluate should be called only once per iteration and it should be the implementation's responsibility to compute all the outputs.
  2. BTW, evaluate should return a list with Block.n_outputs elements, right now this is not enforced.
class CountBlock(Block):
    def __init__(self, inputs, outputs):
        super(CountBlock, self).__init__(inputs, outputs, 1, 0)
        self.last_it = -1
        self.cnt = 0

    def Evaluate(self, it, ts):
        if it != self.last_it:
            # first time we see this 'it', reset counter
            self.cnt = 0
            self.last_it = it
        else:
            self.cnt += 1
        outputs = [self.cnt for _ in range(self.n_outputs)]
        return outputs

    def Label(self):
        return 'identity'


def test_count():
    input_1 = SignalFunction('input_1', lambda x: np.random.randn())
    input_2 = SignalFunction('input_2', lambda x: np.random.randn())

    output_1 = Variable('output_1')
    output_2 = Variable('output_2')
    output_3 = Variable('output_3')
    output_4 = Variable('output_4')
    output_5 = Variable('output_5')
    output_6 = Variable('output_6')

    counter_1 = CountBlock([input_1, input_2], [output_1])
    counter_2 = CountBlock([input_1, input_2], [output_2, output_3])
    counter_3 = CountBlock([input_1, input_2], [output_4, output_5, output_6])

    te = 10
    ns = 10
    model_1 = bms.DynamicSystem(te, ns, [counter_1])
    model_1.Simulate()
    model_2 = bms.DynamicSystem(te, ns, [counter_2])
    model_2.Simulate()
    model_3 = bms.DynamicSystem(te, ns, [counter_3])
    model_3.Simulate()
    print output_1.values
    print output_2.values
    print output_3.values
    print output_4.values
    print output_5.values
    print output_6.values

pip install and sub-modules?

after a "pip install bms" and trying one example I get:
Traceback (most recent call last):
File "bms_ex1.py", line 9, in
from bms.signals.functions import Ramp
ImportError: No module named signals.functions

could you please check on a fresh install if the pypi package install works? I suspect the init.py files for the submodules need more content.
I am on ubuntu 16.04lts with python 2.7.11

Calculus functions

Wow, great work!
Models I want to run make use of differentiation and integration blocks, and I couldn't find them. Adding them would be very interesting. I made a fork of the project and plan to work on it when I have a better understanding of your code.

Can't find Drag and Drop

Hello. First of all, you are doing an incredible job here! I hope we can have a fully functional Python "Simulink" one day! I'm an electrical engineering student and also a Python fan.

So, talking about my issue, I've read all the documentation, but I haven't found a way to access the Drag & Drop Model drawer. Can you help me?

Cheers,
Douglas

Delay block?

Hi, I just discovered BMS and I'm trying to figure out if this (which looks great) will be useful to me as is.
I would need a 'delay' block. For example if I have signal A and B, I want to sum them but the 'sum' is actually summarizing a real process that actually tokes some time (is not like adding two electrical currents but actually doing some work). Therefore I would like to 'delay' the sum.

As I see it one option is to add a 'delay' block. Another approach is to just add a 'delay' option to some basic blocks (which might default to 0). What are your ideas? Maybe I'm missing something and this is already implemented? If not, if you suggest best approach that fits your philosophy I might be able to submit a PR.

Thanks

GUI idea

Hey man - great work!
If you ever go into a GUI thing here's an awesome project with a beautiful GUI that you can use - Orange Data Mining https://orange.biolab.si/

Keep up the good work!
Branko

Pypi package (bms-0.1.0) incomplete

The Pypi package (python 2.7) seems to be "broken"?

The dependencies are not auto-installing and the bms/physical folder do not exist.

You can check it here: https://pypi.python.org/pypi/bms

Isn't it because of the install script?

BMSpy/setup.py

Lines 14 to 26 in ddc4ce9

setup(name='bms',
version=bms.__version__,# in bms __init__
description='Block-Model Simulator for python',
long_description=readme(),
keywords='block model simulation simulator time',
url='http://github.com/masfaraud/BMSpy/wiki/',
author='Steven Masfaraud',
author_email='[email protected]',
license='Creative Commons Attribution-Share Alike license',
packages=['bms','bms.blocks','bms.signals'],
package_dir={'bms':'bms'},
install_requires=['numpy','matplotlib','networkx','dill'],
classifiers=['Topic :: Scientific/Engineering','Development Status :: 3 - Alpha'])

The packages line should be:

packages=['bms','bms.blocks','bms.signals','bms.physical'], 

License information missing

Thanks a lot for this exciting project! It really looks very promising. Especially for my own control systems library I really needed something like this for a long time. Please let me know if you need a hand on the Dynamic System model parts.

I have to ask though, would you please include the license information or could you clarify which license you have in mind and add it to the repository?


A minor dependency issue : When I run the electric_motor.py example I received the missing module cma error. I see that it is missing from the dependency list in the setup.py

install and plot problems

Hey, this is a great job!!!
I found some problems, however:

  • I have python 3.6.4 (Anaconda3), and tried to install this with pip install bms. It got installed, but it is maybe some older version, for example the physical module is not present at all. When I downloaded it from github, and tried to install manually with python setup.py install, the following appeared:

LookupError: setuptools-scm was unable to detect version for 'c:\BMSpy-master'.
Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the
.git folder) don't contain the necessary metadata and will not work.
For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj

  • The other one is just a little thing: the PlotVariables function opened the plot, but then it disappeared instantly. For this I found a solution: plt.show() of fig.show() (in core.py, line 524).

Thanks a lot, and again, great job!

Upload to conda

Thanks for created this package!
I think it would be nice to distribute via conda or other distribution system.

Nice work! Really appreciated.

pep8?

Any way you guys will consider pep8ing the code? The whole codebase would benefit from use of pep8 linter. Just to mention a few:

  • CamelCase methods (in contrast of not_camel_case_once) are very non pythonian.
  • expand names, abbreviations like 'te', 'it' and 'ts' should be avoided

Create a CONTRIBUTING file (or include contributing info on README)

Hey there, back again!

Seeing as there are at least three different contributors to the project, it would be nice if there was a guideline for contributing to the project, such as docstring styles, formatting, and other stuff. Seeing as you are the owner of the project, I believe it would be best if you decided on it. If you want, I can write one based on what you decide. Making the project follow a certain standard makes it easier for new contributors to get used to the code.

Things like spacing between operators and values, tabs-vs-spaces, maximum number of characters per line, could be included.

Regarding docstrings, I'm partial to the following style, using Google docstring formatting and .. math for displaying formulas:

class Saturation(Block):
    """Defines a saturation block.
    .. math::
        output = 
        \\begin{cases}
            min\_value, & \\textrm{if } input < min\_value
            max\_value, & \\textrm{if } input > max\_value
            input, & \\textrm{if } min\_value \leq input \leq max\_value
        \\end{cases}
    Args:
        input_variable (Variable): This is the input of the block.
        output_variable (Variable): This is the output of the block.
        min_value: This is the lower bound for the output.
        max_value: This is the upper bound for the output.
    """

first_order.py example gives ZeroDivisionError

Traceback (most recent call last):
File "bms_ex1.py", line 23, in
ds.Simulate()
File "build/bdist.linux-x86_64/egg/bms/core.py", line 343, in Simulate
File "build/bdist.linux-x86_64/egg/bms/blocks/continuous.py", line 145, in Solve
File "build/bdist.linux-x86_64/egg/bms/blocks/continuous.py", line 140, in OutputMatrices
File "build/bdist.linux-x86_64/egg/bms/blocks/continuous.py", line 128, in _get_M
ZeroDivisionError: float division by zero

IndexError in "VariablesValues" method

  • I'm submitting a ...

    • bug report
    • feature request
    • performance problem
  • What is the current behavior?
    Indexing error in line 505 and 510 of "bms/core.py" (VariablesValues method)

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem Avoid reference to other packages

import bms
from bms.signals.functions import Step
from bms.blocks.continuous import Gain

te = 10
ns = 500

R = Step(('In', 'R'))
Y = bms.Variable(('Out', 'Y'))

G = Gain(R, Y, 1)

system = bms.DynamicSystem(te, ns, [G])
simulation = system.Simulate()
system.VariablesValues(Y, t=1)
  • What is the expected behavior?

1 (Print a number)

  • What is the motivation / use case for changing the behavior?
    The function dont work

  • Possible fixes
    cast "i" variable in line 505 and 510 like "int(i)"

variables.values[int(i)]*((ti-t)/self.ts+1)+variables.values[i+1]*(t-ti)/self.ts)

  • Please tell us about your environment:

    • branch: master
    • commit: 245d56c
    • python version: Python 3.7.7

'dill' required but not listed in setup.py

The package 'dill' seems to be required, but it is not listed as a requirement in setup.py.
After a 'git clone' of the repo and 'sudo python setup.py install' I get:
import dill
ImportError: No module named dill

Documentation

Bonjour

je suis tombé sur ton package sur la modélisation des systèmes.

j'essaie de construire une documentation simple et progressive pour mes élèves de prépa.

j'ai commencé mais j'ai quelques soucis,

  • dans le cas d'un système bouclé, comment doivent être organisés les blocs dans DynamicSystem()
  • dans l'affichage des courbes (j'utilise jupyter)
  • à quoi correspond WLTP signals

as-tu déja une ébauche de DOC/TP .

L'idée c'est de construire pas à pas une modélisation python du robot Maxpid (je présume que tu connais)

Cordialement

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.