Physikal – Using
Kotlin for Clean Energy
Werner Keil, Director,
Creative Arts & Technologies
Kotlin User Group Munich
June 20, 2018
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
Agenda
1. Introduction
2. Tenkiv Nexus
3. JSR 363
4. Physikal
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
Who am I?
Werner Keil
• Consultant – Coach
• Creative Cosmopolitan
• Open Source Evangelist
• Software Architect
• Spec Lead – JSR385
• Eclipse UOMo Project Lead
[www.linkedin.com/in/catmedia]
Twitter @wernerkeil
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
Save Water
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
Water Crisis
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
The Globe
2.5 billion people across the globe
lack access to clean water.
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
Developing Nations
In places like Afghanistan,
lack of access to water sanitation leads to a
1 in 5 child mortality rate.
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
California
98% of California is experiencing
severe drought, placing major stress
on our water infrastructure.
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
South Africa
Cape Town is experiencing a severe drought.
It could only avoid running out of water by
restricting water usage to 50 litre
per person and day.
In 2016, average daily per capita use
in California was 321 litres.
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
What is Tenkiv Nexus?
The Tenkiv Nexus is a fully modular renewable energy system. It uses heat
from the sun in order to power anything for 1/13th the cost of existing solar
panels and 1/5th the cost of fossil fuels without any subsidies. It’s the
breakthrough the world’s been waiting for that finally enables us to truly
utilize the most abundant source of power available on earth: the sun.
Tenkiv started deployment of the Tenkiv Nexus for water purification, but
over time will replace more and more of the world's dying energy
infrastructure with this new, more powerful, cost-effective, and completely
clean energy nexus.
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
Tenkiv Nexus
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
What is JSR-363?
Munich
San Francisco
5,858 miles
A Quantity
A Unit
9428 km
Distance between
Munich and
San Francisco
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
Why do we need JSR-363?
There are no specifications or standards for handling units in Java.
The current solution is to use primitives, that don’t provide any Type
Safety.
The errors are difficult to find using unit testing:
Interface and Internationalization (e.g. radian/degree, meters/feet);
Arithmetic operations (e.g. overflow);
Conversion between units (e.g. from same domain);
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
5,858 miles
A Quantity
A Unit
9428 km
Distance between
Munich and
San Francisco
What is the problem, in code?
int distance = 5858; //in miles
float speed = airplane.getSpeed(); //in km/h
System.out.println(“TTD: “ + (distance/speed) + “ h”);
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
What is JSR-363, in code?
Quantity<Length> distance = Quantities.getQuantity(5858,
USCustomary.MILE);
Quantity<Speed> airplaneSpeed = airplane.getSpeed();
System.out.println(airplane + " flying at " +
airplaneSpeed);
Quantity<Time> timeToDest =
distance.divide(airplaneSpeed).asType(Time.class);
System.out.println(“TTD: “ + timeToDest.to(Units.HOUR));
Airplane [A380] flying at 945 km/h
TTD: 9.97622180949874 h
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
The SI Standard will be revised in May 2019
The General Conference on Weights and Measures (CGPM) is expected
to approve SI reforms in November 2018
SI Roadmap
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
• JFK was elected US President
• Real Madrid won European Cup
7:3 against Eintracht Frankfurt
• Brasilia becomes Capital
of Brazil
1960
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
• Because the new SI Revision is the most significant
change to the Metric System since it was introduced
in its current form 1960, this was a key reason to
increase the version number to Unit API 2.0.
• Another argument is adopting to a rapidly changing
Java Platform and Runtime which itself tends to
increase the major version of the JDK twice a year
now.
• Time and the community will tell new requirements
beyond that, but it is likely Units of Measurement 2.x
should be the standard for at least the 2020s or
beyond.
Motivation for JSR-385
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
What is Physikal?
Library providing Kotlin extensions and ease of use functions for Java
Units of Measurement libraries based on JSR-363.
Contains
• Core - Basic Metric units.
• SI-Units - SI units.
• Complete-Units - All units including US or Imperial.
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
What is Physikal, in code?
Create Units
val added = 10.metre + 1.kilo.metre
>> 1010.0 m
val small = 10.metre
val large = 10.kilo.metre
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
What is Physikal, in more code?
Includes all operators
val added = 10.metre + 1.kilo.metre
>> 1010.0 m
val speed = added/10.minute
>> 101 m/min
var aFewSeconds = 5.second
aFewSeconds++
>> 6.0 s
10.peta.watt > 2.watt
>> true
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
What is Physikal, in more code?
Using different units (SI units & other units)
5.gram + 2.pound
>> 912.18474 g
(13.kilo.gram + 20.pound) convertTo STONE
>> 3.47572100600243466674378 st
© 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI
Links
Public JSR-385/363 mailing list(s) and/or forum(s)
Units-Dev on Google Groups
Units-Users on Google Groups
JSR-385 page: https://jcp.org/en/jsr/detail?id=385…
Project Website: http://unitsofmeasurement.github.io on GitHub
Tenkiv: https://tenkiv.com
Physikal: https://github.com/Tenkiv/Physikal
@YourTwitterHandle#DVXFR14{session hashtag} © 2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI

Physikal - Using Kotlin for Clean Energy - KUG Munich

  • 1.
    Physikal – Using Kotlinfor Clean Energy Werner Keil, Director, Creative Arts & Technologies Kotlin User Group Munich June 20, 2018
  • 2.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI Agenda 1. Introduction 2. Tenkiv Nexus 3. JSR 363 4. Physikal
  • 3.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI Who am I? Werner Keil • Consultant – Coach • Creative Cosmopolitan • Open Source Evangelist • Software Architect • Spec Lead – JSR385 • Eclipse UOMo Project Lead [www.linkedin.com/in/catmedia] Twitter @wernerkeil
  • 4.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI Save Water
  • 5.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI Water Crisis
  • 6.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI The Globe 2.5 billion people across the globe lack access to clean water.
  • 7.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI Developing Nations In places like Afghanistan, lack of access to water sanitation leads to a 1 in 5 child mortality rate.
  • 8.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI California 98% of California is experiencing severe drought, placing major stress on our water infrastructure.
  • 9.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI South Africa Cape Town is experiencing a severe drought. It could only avoid running out of water by restricting water usage to 50 litre per person and day. In 2016, average daily per capita use in California was 321 litres.
  • 10.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI What is Tenkiv Nexus? The Tenkiv Nexus is a fully modular renewable energy system. It uses heat from the sun in order to power anything for 1/13th the cost of existing solar panels and 1/5th the cost of fossil fuels without any subsidies. It’s the breakthrough the world’s been waiting for that finally enables us to truly utilize the most abundant source of power available on earth: the sun. Tenkiv started deployment of the Tenkiv Nexus for water purification, but over time will replace more and more of the world's dying energy infrastructure with this new, more powerful, cost-effective, and completely clean energy nexus.
  • 11.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI Tenkiv Nexus
  • 12.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI What is JSR-363? Munich San Francisco 5,858 miles A Quantity A Unit 9428 km Distance between Munich and San Francisco
  • 13.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI Why do we need JSR-363? There are no specifications or standards for handling units in Java. The current solution is to use primitives, that don’t provide any Type Safety. The errors are difficult to find using unit testing: Interface and Internationalization (e.g. radian/degree, meters/feet); Arithmetic operations (e.g. overflow); Conversion between units (e.g. from same domain);
  • 14.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI 5,858 miles A Quantity A Unit 9428 km Distance between Munich and San Francisco What is the problem, in code? int distance = 5858; //in miles float speed = airplane.getSpeed(); //in km/h System.out.println(“TTD: “ + (distance/speed) + “ h”);
  • 15.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI What is JSR-363, in code? Quantity<Length> distance = Quantities.getQuantity(5858, USCustomary.MILE); Quantity<Speed> airplaneSpeed = airplane.getSpeed(); System.out.println(airplane + " flying at " + airplaneSpeed); Quantity<Time> timeToDest = distance.divide(airplaneSpeed).asType(Time.class); System.out.println(“TTD: “ + timeToDest.to(Units.HOUR)); Airplane [A380] flying at 945 km/h TTD: 9.97622180949874 h
  • 16.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI The SI Standard will be revised in May 2019 The General Conference on Weights and Measures (CGPM) is expected to approve SI reforms in November 2018 SI Roadmap
  • 17.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI • JFK was elected US President • Real Madrid won European Cup 7:3 against Eintracht Frankfurt • Brasilia becomes Capital of Brazil 1960
  • 18.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI • Because the new SI Revision is the most significant change to the Metric System since it was introduced in its current form 1960, this was a key reason to increase the version number to Unit API 2.0. • Another argument is adopting to a rapidly changing Java Platform and Runtime which itself tends to increase the major version of the JDK twice a year now. • Time and the community will tell new requirements beyond that, but it is likely Units of Measurement 2.x should be the standard for at least the 2020s or beyond. Motivation for JSR-385
  • 19.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI What is Physikal? Library providing Kotlin extensions and ease of use functions for Java Units of Measurement libraries based on JSR-363. Contains • Core - Basic Metric units. • SI-Units - SI units. • Complete-Units - All units including US or Imperial.
  • 20.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI
  • 21.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI What is Physikal, in code? Create Units val added = 10.metre + 1.kilo.metre >> 1010.0 m val small = 10.metre val large = 10.kilo.metre
  • 22.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI What is Physikal, in more code? Includes all operators val added = 10.metre + 1.kilo.metre >> 1010.0 m val speed = added/10.minute >> 101 m/min var aFewSeconds = 5.second aFewSeconds++ >> 6.0 s 10.peta.watt > 2.watt >> true
  • 23.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI What is Physikal, in more code? Using different units (SI units & other units) 5.gram + 2.pound >> 912.18474 g (13.kilo.gram + 20.pound) convertTo STONE >> 3.47572100600243466674378 st
  • 24.
    © 2017-2018 CreativeArts & Technologies and others. All rights reserved.#Physikal @UnitAPI Links Public JSR-385/363 mailing list(s) and/or forum(s) Units-Dev on Google Groups Units-Users on Google Groups JSR-385 page: https://jcp.org/en/jsr/detail?id=385… Project Website: http://unitsofmeasurement.github.io on GitHub Tenkiv: https://tenkiv.com Physikal: https://github.com/Tenkiv/Physikal
  • 25.
    @YourTwitterHandle#DVXFR14{session hashtag} ©2017-2018 Creative Arts & Technologies and others. All rights reserved.#Physikal @UnitAPI