https://kotlinlang.org logo
#science
Title
# science
a

altavir

10/18/2020, 7:50 PM
I really love kotlin. A hour of work, fifty lines of code and we have dynamic visualization of fully parallel and reactive stream-based simulation of terrestrial gamma-flashes (reactor model). The code is not yet publication-ready, but you can look at it here. Flows are really great for Monte-Carlo simulations (cc @elizarov).
❤️ 1
Try to do that in Python
b

bjonnh

10/19/2020, 1:46 AM
What's the volume of data processed?
a

altavir

10/19/2020, 5:19 AM
It is simulation. It is limited by million events per generation and significantly slower down by adding delay between generations (otherwise it completes emmediately and I can't show the dynamic picture).
b

bjonnh

10/19/2020, 2:13 PM
nice
h

holgerbrandl

11/27/2020, 4:32 PM
What lib are you using here? Letsplot?
a

altavir

11/27/2020, 4:33 PM
Nope, Plotly.kt.
In this regard we are following JB dogfooding practice. I am currently working on a more universal system, which will allow to show not only plots, but more general visual data as well.
h

holgerbrandl

11/27/2020, 5:13 PM
Awesome, what would be most awesome if such a framework would also support controls. E.g. to modulate simulation speed etc. Is there a public repo already?
a

altavir

11/27/2020, 5:18 PM
The controls are planed, yes. The frontend controlls are possible to do in plotlykt-server right now, but I want more general solution. Also you can see JavaFX demo for plotlykt: https://github.com/mipt-npm/plotly.kt/tree/master/fx-demo. It include controls for the plot. The repository for visionforge is here: https://github.com/mipt-npm/visionforge. And demos include custom controls. Right now you need to manually create frontend multiplatform module, but in the end it will be possible to define it on the backend like Dash does on python.
z

zain

12/10/2020, 11:15 AM
Hi @altavir can we use these modules in any of the community editions of the JB tools? If yes can you please name them.
a

altavir

12/10/2020, 11:24 AM
@zain yes, you do not need JB tools for anything. It is just regular kotlin-jvm code. Plotly.kt is ready to public use. VisionForge just got the update, which allows to use the same functionality, namely defining models on JVM and rendering them automatically on the frontend without any Kotlin-JS injections.
z

zain

12/10/2020, 2:14 PM
This is not a library issue but having difficulties integrating the library in Intellij. facing this issues https://stackoverflow.com/q/48988778/4083142 tried all the suggested options but still the compiler is throwing the error. Trying to run this specific implementation.
Copy code
import hep.dataforge.meta.invoke
import kscience.plotly.Plotly
import kscience.plotly.makeFile
import kscience.plotly.models.Pie

/**
 * - basic pie chart
 * - change height and width of the plot
 */
fun main() {
    val values = listOf(19, 26, 55)
    val labels = listOf("Residential", "Non-Residential", "Utility")

    val pie = Pie {
        values(values)
        labels(labels)
    }

    val plot = Plotly.plot {
        traces(pie)
        layout {
            width = 500
            height = 450
        }
    }

    plot.makeFile()
}
Hi @altavir created a question can you please help me out if possible https://stackoverflow.com/q/65237210/4083142
a

altavir

12/10/2020, 4:35 PM
Yes, it is a known problem. You have to use Java 8 as a compiler.
The problem is that Plotly.kt is compiled using JDK 8 (it will be 11 in future releases). And you are trying to use Kotlin 1.6 compiler and calling inline functions. There are two solutions for that: - You can avoid using inline functions (they are there only for convenience). - You can switch the compiled code version to 1.8 via Idea project settings or gradle.
The second question is also about JDK version, so all you need is to use newer JDK and set the bytecode version to 1.8
z

zain

12/11/2020, 2:37 AM
Thanks @altavir it got resolved
5 Views