Category Archives: Julia

Announcing JuliaSim Batteries: Advanced Electrochemical Lithium-Ion Battery Simulation

By: Jasmine Chokshi

Re-posted from: https://info.juliahub.com/blog/announcing-juliasim-batteries

JuliaHub is thrilled to announce a game-changing advancement in lithium-ion battery simulation: JuliaSim Batteries. This newly released tool extends state-of-the-art cell models with electrochemical, thermal, and degradation physics to the pack, enabling highly accurate simulations.

Transforming multiple columns in DataFrames.jl

By: Blog by Bogumił Kamiński

Re-posted from: https://bkamins.github.io/julialang/2024/03/15/transforms.html

Introduction

Today I want to comment on a recurring topic that DataFrames.jl users raise.
The question is how one should transform multiple columns of a data frame using
operation specification syntax.

The post was written under Julia 1.10.1 and DataFrames.jl 1.6.1.

What is operation specification syntax?

In DataFrames.jl the combine, select, and transform functions allow
users for passing the requests for data transformation using operation
specification syntax. This syntax is feature-rich, and you can find its
description for example here. Today I want to focus on its principal concept.

In a general form each request for making an operation on data has the (E)xtract-(T)ransform-(L)oad form.
That means that we need to specify:

  • source columns to get data from (the extract part);;
  • the operation to apply to these columns (the transform part);
  • the target columns where we want to store the result of the operation (the load part).

These tree parts are syntactically expressed using the following form:

[source columns specification] => [transformation function] => [target columns specification]

Let me give an example. Assume you have the following data:

julia> using DataFrames

julia> df = DataFrame(reshape(1:15, 5, 3), :auto)
5×3 DataFrame
 Row │ x1     x2     x3
     │ Int64  Int64  Int64
─────┼─────────────────────
   1 │     1      6     11
   2 │     2      7     12
   3 │     3      8     13
   4 │     4      9     14
   5 │     5     10     15

We want to compute the sum of column "x1" and store it in column names "x1_sum"
Since the sum function performs the addition operation the syntax specification should be:

"x1" => sum => "x1_sum"

Let us check it with the combine function:

julia> combine(df, "x1" => sum => "x1_sum")
1×1 DataFrame
 Row │ x1_sum
     │ Int64
─────┼────────
   1 │     15

In this syntax it is important to note two things:

  • the "x1" column as a whole was passed to the sum function (as we want to compute its sum);
  • the "x1" column is a single positional argument passed to the sum function.

Two natural questions that arise are the following:

  • What if I do not want to perform an operation on a whole column, but on its elements (a.k.a. vectorization of operation)?
  • What if I want to pass multiple columns as a source for computations?

We will now investigate these two dimensions.

Vectorization of operations

Vectorization in DataFrames.jl is easy. Just wrap the function you use in the ByRow object. Here is an example:

julia> combine(df, "x1" => string => "x1_str")
1×1 DataFrame
 Row │ x1_str
     │ String
─────┼─────────────────
   1 │ [1, 2, 3, 4, 5]

julia> combine(df, "x1" => ByRow(string) => "x1_strs")
5×1 DataFrame
 Row │ x1_strs
     │ String
─────┼─────────
   1 │ 1
   2 │ 2
   3 │ 3
   4 │ 4
   5 │ 5

Note that "x1" => string => "x1_str" passed the whole "x1" column to the string function so we got a single "[1, 2, 3, 4, 5]"
string in the output.

While writing "x1" => ByRow(string) => "x1_strs" passed each element of "x1" column to the string function individually,
so in the result we got a vector of five string representations of numbers of the numbers from the source.

Passing multiple columns

Now let us have a look at passing multiple columns. There are two ways you can do it.

The first is when your function accepts multiple positional arguments. An example of such function is string see:

julia> string(df.x1, df.x2)
"[1, 2, 3, 4, 5][6, 7, 8, 9, 10]"

If we pass a collection of columns as a source in operation specification syntax we get this behavior:

julia> combine(df, ["x1", "x2"] => string => "x1_x2_str")
1×1 DataFrame
 Row │ x1_x2_str
     │ String
─────┼─────────────────────────────────
   1 │ [1, 2, 3, 4, 5][6, 7, 8, 9, 10]

Naturally, the above combines with vectorization. Therefore since:

julia> string.(df.x1, df.x2)
5-element Vector{String}:
 "16"
 "27"
 "38"
 "49"
 "510"

we also have:

julia> combine(df, ["x1", "x2"] => ByRow(string) => "x1_x2_strs")
5×1 DataFrame
 Row │ x1_x2_strs
     │ String
─────┼────────────
   1 │ 16
   2 │ 27
   3 │ 38
   4 │ 49
   5 │ 510

However, there are cases when we have a function that expects multiple columns to be passed as a single positional argument.
This is handled in DataFrames.jl with the AsTable wrapper, which you can apply to the source columns.
If you use it then instead of getting multiple positional arguments the function will get a single positional argument
that will be a NamedTuple holding the source columns.

To convince ourselves that this is indeed what happens let us create a helper function:

julia> function helper(x)
           @show x
           return string(x.x1, x.x2)
       end
helper (generic function with 1 method)

This helper function first prints us its only argument x and next assumes that it has x1 and x2 fields and applies the string function to them.
Let us first check it in practice:

julia> helper((x1=[1, 2, 3, 4, 5], x2=[6, 7, 8, 9, 10]))
x = (x1 = [1, 2, 3, 4, 5], x2 = [6, 7, 8, 9, 10])
"[1, 2, 3, 4, 5][6, 7, 8, 9, 10]"

Now let us use the helper function with combine:

julia> combine(df, AsTable(["x1", "x2"]) => helper => "x1_x2_str")
x = (x1 = [1, 2, 3, 4, 5], x2 = [6, 7, 8, 9, 10])
1×1 DataFrame
 Row │ x1_x2_str
     │ String
─────┼─────────────────────────────────
   1 │ [1, 2, 3, 4, 5][6, 7, 8, 9, 10]

Indeed, we see that helper got a named tuple holding two columns of the source data frame.

Again, this syntax plays well with ByRow:

julia> combine(df, AsTable(["x1", "x2"]) => ByRow(helper) => "x1_x2_strs")
x = (x1 = 1, x2 = 6)
x = (x1 = 2, x2 = 7)
x = (x1 = 3, x2 = 8)
x = (x1 = 4, x2 = 9)
x = (x1 = 5, x2 = 10)
5×1 DataFrame
 Row │ x1_x2_strs
     │ String
─────┼────────────
   1 │ 16
   2 │ 27
   3 │ 38
   4 │ 49
   5 │ 510

We see that this time helper got a separate named tuple for each row of source data frame.

Conclusions

In summary today we discussed two special operations in DataFrames.jl operation specification syntax:

  • the ByRow which vectorizes the function passed to it;
  • the AsTable which allows us to pass source columns as a single named tuple to the transformation function
    (instead of passing them as consecutive positional arguments, which is the default).

I hope these examples were useful in helping you understand the design of operation specification syntax.

Genie Builder Beta Launch | JuliaHub

By: JuliaHub

Re-posted from: https://info.juliahub.com/blog/newsletter-march-2024-genie-builder-beta-launch-create-web-apps-and-dashboards-easily

Genie Builder Beta Launch: Genie Builder is the new easy way to build and share Web apps and dashboards using JuliaHub. Genie Builder features drag-and-drop UI editing, single-click deployment and hosting and the combined power and ease-of-use of Julia + JuliaHub. Click here for more information.

JuliaHub at International Battery Seminar and Exhibit (IBSE) in Orlando March 12-15: JuliaHub will showcase JuliaSimBatteries at the International Battery Seminar and Exhibit (IBSE) in Orlando, Florida from March 12-15. JuliaSimBatteries is an advanced tool for simulating lithium-ion batteries, integrating electrical, thermal and degradation physics. JuliaHub will also co-sponsor the Volta Foundation Happy Hour on Tuesday March 12. Click here for more information and to register for the International Battery Seminar and Exhibit (IBSE) and click here for more information and to register for the Volta Foundation Happy Hour.

Free Webinars from JuliaHub: JuliaHub provides free one-hour Webinars on a variety of topics. Registration is free but space is limited. Click the links below to register, or watch past Webinars here.

Webinar

Presenter

Date and Time

Register

Revolutionizing Battery Quality: Strategies for Battery Defect Mitigation using JuliaSim

Dr. Marc Berliner, JuliaSim Batteries Lead Developer and Dr. Ranjan Anantharaman, JuliaHub Sales Engineer

Tuesday March 19

1-2 pm Eastern (US)

Link

Mastering Interactive Dash Apps with Dash.jl: A Flight Traffic Visualization Journey on JuliaHub

Maja Gwóźdź, JuliaHub and ETH Zurich

Thursday March 21

1-2 pm Eastern (US)

Link

Hands-On Parallelizing Simulations and Parameter Estimation with JuliaSim

Dr. Ranjan Anantharaman, JuliaHub Sales Engineer

Tuesday March 26

1-2 pm Eastern (US)

Link

Advancements in Acausal Modeling with ModelingToolkit v9

Dr. Chris Rackauckas, JuliaHub VP Modeling and Simulation

Tuesday April 2

1-2 pm Eastern (US)

Link

Comparative Analysis of Cell Chemistries with JuliaSim Batteries

Dr. Marc Berliner, JuliaSim Batteries Lead Developer

Wednesday April 17

1-2 pm Eastern (US)

Link

Time Series Forecasting: Predictive Analytics for Future Insights

Phil Vernes, JuliaHub Sales Engineer

Friday April 26

1-2 pm Eastern (US)

Link

JuliaCon 2024: JuliaCon 2024 takes place from July 9-13 in Eindhoven, Netherlands. Workshops will take place Tuesday July 9, presentations Wednesday July 10 through Friday July 12 and the hackathon will be Saturday July 13. Click here for more information, to register and to take advantage of early bird pricing.

Barcelona Julia Meetup: Adopting Julia – ASML’s Journey and How to Transition from MATLAB will be held Thursday April 11 in Barcelona. Click here to register. Presentations include:

  • ASML’s Julia Journey – Jorge Vieyra, ASML Senior Development Engineer
  • From MATLAB to Julia: Learnings – Gareth Thomas, VersionBay Co-Founder
  • A Beginner’s Intro to Julia – Pere Giménez, Genie Data Science Advocate

JuliaHub Blog Posts: JuliaHub has published several new blog posts. Click below to read.

Symbolic Numerics: Dr. Chris Rackauckas (JuliaHub VP Modeling & Simulation) has also published a new blog post on symbolic numerics. Click here to read Symbolic-Numerics: How Compiler Smarts Can Help Improve the Performance of Numerical Methods (Nonlinear Solvers in Julia).

Semantic Versioning (Semver): Semantic Versioning (Semver) Is Flawed, and Downgrade CI Is Required to Fix It is another new blog post from Dr. Chris Rackauckas (JuliaHub VP Modeling & Simulation). Click here for more.

Physics-Enhanced Deep Surrogates for Partial Differential Equations: MIT and IBM Find Clever AI Ways Around Brute-Force Math is a new article from IEEE Spectrum about Physics-Enhanced Deep Surrogates for Partial Differential Equations, an article co-authored by Dr. Chris Rackauckas (JuliaHub VP Modeling and Simulation) which was published in Nature Machine Intelligence in December.

This Month in Julia World: Stefan Krastanov’s monthly Julia newsletter contains the latest Julia developments and more. Click here to read.

JuliaHub Consulting Services: Would your organization benefit from a 100x increase in simulation speeds? JuliaSim might be the solution you need. Click here for more information about JuliaSim, and to contact us to learn how JuliaSim can help your business succeed.

Free Compute on JuliaHub (20 hours): In addition to the features JuliaHub has always offered for free – Julia ecosystem search, package registration tools, a dedicated package server – the platform now also gives every user 20 hours of free compute. This allows people to seamlessly share Pluto notebooks and IDE projects with others and let them get their feet wet with computing without having to open up their wallets. Click here to get started or check out Deep Datta’s introductory video, “JuliaHub Is a Free Platform to Start Your Technical Computing Journey”, where he explains how and why to start using JuliaHub for cloud computing.

Converting from Proprietary Software to Julia: Are you looking to leverage Julia’s superior speed and ease of use, but limited due to legacy software and code? JuliaHub and our partners can help accelerate replacing your existing proprietary applications, improve performance, reduce development time, augment or replace existing systems and provide an extended trusted team to deliver Julia solutions. Leverage experienced resources from JuliaHub and our partners to get your team up and running quickly. For more information, please contact us.

Careers at JuliaHub: JuliaHub is a fast-growing tech company with fully remote employees in 20 countries on 6 continents. Click here to learn more about exciting careers and internships with JuliaHub.

Julia and JuliaHub in the News

  • IEEE Spectrum: MIT and IBM Find Clever AI Ways Around Brute-Force Math
  • BNN Breaking: Julia Programming Language’s 15-Year Journey: Revolutionizing Technical Computing
  • Built In: 6 Reasons to Learn Julia in 2024‍
  • Analytics Insight: Why You Should Learn Julia in 2024
  • Analytics Insight: R, Python, and Julia: A Comparative Study of Data Science
  • Analytics Insight: Julia vs Python: Which One is Best for Data Science in 2024?
  • DataScientest: Python vs Julia: Which Is the Best Language for Data Science?
  • Outlook: Classroom To Career: Transitioning Tips For Aspiring Programmers

Julia Blog Posts

Upcoming Julia and JuliaHub Events

Recent Julia and JuliaHub Events

Contact Us: Please contact us if you want to:

  • Learn more about JuliaHub, JuliaSim, Pumas, PumasQSP or CedarEDA
  • Obtain pricing for Julia consulting projects for your organization
  • Schedule Julia training for your organization
  • Share information about exciting new Julia case studies or use cases
  • Spread the word about an upcoming online or offline event involving Julia
  • Partner with JuliaHub to organize a Julia event online or offline
  • Submit a Julia internship, fellowship or job posting

About JuliaHub and Julia

JuliaHub is a fast and easy-to-use code-to-cloud platform that accelerates the development and deployment of Julia programs. JuliaHub users include some of the most innovative companies in a range of industries including pharmaceuticals, automotive, energy, manufacturing, and semiconductor design and manufacture.

Julia is a high performance open source programming language that powers computationally demanding applications in modeling and simulation, drug development, design of multi-physical systems, electronic design automation, big data analytics, scientific machine learning and artificial intelligence. Julia solves the two language problem by combining the ease of use of Python and R with the speed of C++. Julia provides parallel computing capabilities out of the box and unlimited scalability with minimal