Skip to content

Commit

Permalink
Merge branch 'main' of github.com:OrbitalCalculations/AstroSolution
Browse files Browse the repository at this point in the history
  • Loading branch information
astrotuna201 committed Dec 4, 2021
2 parents 0932334 + fef24a9 commit b173cb7
Show file tree
Hide file tree
Showing 17 changed files with 642 additions and 297 deletions.
3 changes: 0 additions & 3 deletions Bundle/888591c69c11fb71.wasm

This file was deleted.

1 change: 0 additions & 1 deletion Bundle/a64d3a9e6ca5786f.js

This file was deleted.

3 changes: 1 addition & 2 deletions MyIndex.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<p><a href="https://doi.org/10.5281/zenodo.5736416">Heiko Pälike. (2021). OrbitalCalculations/AstroSolution: Zenodo Release v0.0.2
(0.0.2). https://doi.org/10.5281/zenodo.5736416</a></p>
<p><a href="https://doi.org/10.5281/zenodo.5741358">Heiko Pälike. (2021). OrbitalCalculations/AstroSolution: Zenodo Release v0.0.4. https://doi.org/10.5281/zenodo.5741358</a></p>
</body>
</html>

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let package = Package(
.product(name: "TokamakShim", package: "Tokamak"),
"JavaScriptKit",
.product(name: "JavaScriptEventLoop", package: "JavaScriptKit"),
.product(name: "LNTBinaryCoding", package: "CommonCoding")
.product(name: "LNTBinaryCoding", package: "CommonCoding"),
],
resources: [
.copy("Resources/precomputedList.json"),
Expand Down
51 changes: 51 additions & 0 deletions Sources/TokamakHTML/Computation/pAModelling.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// File.swift
//
//
// Created by wiggles on 03/12/2021.
//

import Foundation

struct pAModelling {
static func pAPrediction(fgam: Double, cmar: Double) -> ([Double], [Double]) {

let cp1_0 = 37.52660322621579069846
let cp2_0 = -0.00156517316835090223
let cp3_0 = 0.00008260292831613919
let cp4_0 = 34.81861759592058547241


let oldestYear = -50000000.0
let rdsc = 206264.80624709e0 // 180 * 3600 / π
let aml = 17325593.437360e0/rdsc
let om = 474659981.59713733/rdsc
let cmar0 = -4.6e-18
let eps0 = 0.40666
let S0 = 0.5007
let coseps0 = cos(eps0) //0.91844705998496
let sineps0 = sin(eps0) //0.395543926770445
let nu0 = 0.150019
let p0 = 50.467718
let p1 = -13.526564e-9
let phi0 = 171.424

let cp1 = cp1_0*fgam
let cp2 = cp2_0*fgam
let cp3 = cp3_0*fgam*fgam
let cp4 = cp4_0*fgam

let ak2 = cmar0 * 86400.0 * 365.25 * cmar
let ak1 = 51.0 * ak2 * aml / om


let x = Array(stride(from: 0.0, through: oldestYear, by: -500000.0))

let y = x.map { years -> Double in
let cor1 = 1.0 + ak1 * years
let cor2 = 1.0 + 2.0 * ak2 * years
return cor1 * (cor2 * (cp1 * coseps0 + cp2 * (2.0 * coseps0*coseps0 - 1.0)/sineps0 + cor2 * cp3 * (6.0 * coseps0*coseps0-1.0)) + cp4 * S0 * coseps0)
}
return (x,y)
}
}
53 changes: 45 additions & 8 deletions Sources/TokamakHTML/MainProg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,26 @@ import WASILibc
let IPRT = 0

struct AstroSolutionApp: App {
var body: some Scene {
init(){
let _ = setupPlotly()
}

func setupPlotly() {
#if os(WASI)
let document = JSObject.global.document
//let script = document.createElement("script")
//let _ = script.setAttribute("src",
// "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js")
//let _ = document.head.appendChild(script)

let script2 = document.createElement("script")
let _ = script2.setAttribute("src", "https://cdn.plot.ly/plotly-latest.min.js")
let _ = document.head.appendChild(script2)

#endif
}

var body: some TokamakShim.Scene {
WindowGroup("AstroSolution WebApp") {
ContentView()
}
Expand All @@ -47,8 +66,8 @@ struct ContentView: View {

@StateObject var environment = AppEnvironment()


var body: some View {

let solutionProxy = Binding(
get: { solutionSelection },
set: { newValue in
Expand All @@ -64,21 +83,39 @@ struct ContentView: View {
Text("Computation Tool for Astronomical Solutions")
.bold()
.font(.headline)


HStack {
AstroSolutionView(selection: solutionProxy)
//TooltipView("Different astronomical solutions can be selected here. Please note that some are not (yet) available (La2004/La2011), as their orbital elements have not been published yet, and are therefore irreproducible.")
}
Group {
AstroSolutionView(selection: solutionProxy)
CustomDivider()
startMyrSelectionView()

StartMyrSelectionView()
CustomDivider()

FgamCmarSelectionView()
CustomDivider()

ComputationButton(solutionSelection: solutionProxy)
.buttonStyle(BorderedProminentButtonStyle())

}
CustomDivider()
StatusView()
CustomDivider()

Button("Preview general precession in longitude plot"){
print("Plotly")
let plotly = JSObject.global.Plotly.object!
let (x,y) = pAModelling.pAPrediction(fgam: environment.fgam, cmar: environment.cmar)

let _ = plotly.react!(
"66154CE9-D203-4126-89F4-837930B5EF87",
JSObject.global.JSON.object!.parse!(
PlotlySupport.chartStudioTemplate(x: x, y: y))
)

}
PlotlyView()

}.environmentObject(environment)
.padding(10)
.background(.gray)
Expand Down
24 changes: 6 additions & 18 deletions Sources/TokamakHTML/Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,12 @@ public struct AstroSolutions: Codable {

let jsonAstroSolutions = """
[
{
"name": "La1993", "versions": []
},
{
"name": "La2004", "versions": []
},
{
"name": "La2010", "versions": ["a", "b", "c", "d"]
},
{
"name": "La2011", "versions": []
},
{
"name": "ZB2017", "versions": ["e"]
},
{
"name": "ZB2018", "versions": ["a"],
}
{"name": "La1993", "versions": []},
{"name": "La2004", "versions": []},
{"name": "La2010", "versions": ["a", "b", "c", "d"]},
{"name": "La2011", "versions": []},
{"name": "ZB2017", "versions": ["e"]},
{"name": "ZB2018", "versions": ["a"],}
]
"""

Expand Down
128 changes: 128 additions & 0 deletions Sources/TokamakHTML/PlotlySupport.swift

Large diffs are not rendered by default.

Loading

0 comments on commit b173cb7

Please sign in to comment.