Coder Social home page Coder Social logo

pybamm-tea's Issues

Structure

Think about how to structure the code. Some suggestions to get started:

  • A class that does the calculations for a single parameter set (the TEA class)
  • A class that takes a list of parameter_values, loops over them and create a TEA class for each, does the relevant calculations and plots or displays some kind of summary.
  • Think about API for getting economic numbers into the workflow e.g. material prices

Better testing

I think a more robust test would be to create a TEA class from some known parameters and then check all the calculations are correctly compared - then you will catch if anyone accidentally changes a calculation to give the incorrect result.

Packaging

Add folders for source code, docs, and tests. Add .gitignore &pyproject.toml

For a simple example see the BPX repo
For a guide see here

Dict of list instead of list of dicts to populate data frames

Doing

data = {"a": [1, 3], "b": [2, 4], "c": [3, 6]}
pd.DataFrame(data)

is equivalent to (and shorter than) doing

data = [{"a": 1, "b":2 , "c": 3}, {"a": 3, "b":5 , "c": 6}]
data = [{"a": 1, "b":2 , "c": 3}, {"a": 3, "b":5 , "c": 6}]

This can be used to clean up a bunch of code in TEA, e.g.

        stack_ed = self.stack_energy_densities
        data = [
            {
                "Parameter": "Volumetric energy density",
                "Unit": "Wh.L-1",
                "Value": stack_ed.get("Volumetric stack energy density [Wh.L-1]"),
            },
            {
                "Parameter": "Gravimetric energy density",
                "Unit": "Wh.kg-1",
                "Value": stack_ed.get("Gravimetric stack energy density [Wh.kg-1]"),
            },
            {
                "Parameter": "Stack average OCP",
                "Unit": "V",
                "Value": stack_ed.get("Stack average OCP [V]"),
            },
            {
                "Parameter": "Capacity",
                "Unit": "mA.h.cm-2",
                "Value": stack_ed.get("Capacity [mA.h.cm-2]"),
            },
            {
                "Parameter": "(Single-) stack thickness",
                "Unit": "um",
                "Value": 10**6 * stack_ed.get("Stack thickness [m]"),
            },
            {
                "Parameter": "Stack density",
                "Unit": "kg.L-1",
                "Value": 10**-3 * stack_ed.get("Stack density [kg.m-3]"),
            },
        ]
        # Create the DataFrame from the list of dictionaries
        df = pd.DataFrame(data)

could be much shorter and more readable.

Testing

Add tests and infrastructure

Set inputs in the class init

Set the inputs when you make an instance of the class instead of on the methods. This will ensure consistency across calculations.

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.