Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KinematicViscosity scientific unit #611

Merged
merged 11 commits into from
Jan 10, 2023
138 changes: 138 additions & 0 deletions scientific/api/androidLib/scientific.api

Large diffs are not rendered by default.

138 changes: 138 additions & 0 deletions scientific/api/jvm/scientific.api

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions scientific/src/commonMain/kotlin/PhysicalQuantity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ sealed class PhysicalQuantity : com.splendo.kaluga.base.utils.Serializable {
@Serializable
object Jolt : PhysicalQuantity()
@Serializable
object KinematicViscosity : PhysicalQuantity()
@Serializable
object Length : PhysicalQuantity()
@Serializable
object Luminance : PhysicalQuantity()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Copyright 2021 Splendo Consulting B.V. The Netherlands

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/

package com.splendo.kaluga.scientific.converter.area

import com.splendo.kaluga.base.utils.Decimal
import com.splendo.kaluga.scientific.DefaultScientificValue
import com.splendo.kaluga.scientific.PhysicalQuantity
import com.splendo.kaluga.scientific.ScientificValue
import com.splendo.kaluga.scientific.byMultiplying
import com.splendo.kaluga.scientific.unit.Area
import com.splendo.kaluga.scientific.unit.KinematicViscosity
import com.splendo.kaluga.scientific.unit.Time
import kotlin.jvm.JvmName

@JvmName("areaFromKinematicViscosityAndTimeDefault")
fun <
jtomanik marked this conversation as resolved.
Show resolved Hide resolved
KinematicViscosityUnit : KinematicViscosity,
TimeUnit : Time,
AreaUnit : Area
> AreaUnit.area(
kinematicViscosity: ScientificValue<PhysicalQuantity.KinematicViscosity, KinematicViscosityUnit>,
time: ScientificValue<PhysicalQuantity.Time, TimeUnit>
) = area(kinematicViscosity, time, ::DefaultScientificValue)

@JvmName("areaFromKinematicViscosityAndTime")
fun <
KinematicViscosityUnit : KinematicViscosity,
TimeUnit : Time,
AreaUnit : Area,
Value : ScientificValue<PhysicalQuantity.Area, AreaUnit>
> AreaUnit.area(
kinematicViscosity: ScientificValue<PhysicalQuantity.KinematicViscosity, KinematicViscosityUnit>,
time: ScientificValue<PhysicalQuantity.Time, TimeUnit>,
factory: (Decimal, AreaUnit) -> Value
) = byMultiplying(kinematicViscosity, time, factory)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2021 Splendo Consulting B.V. The Netherlands

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/

package com.splendo.kaluga.scientific.converter.area

import com.splendo.kaluga.scientific.PhysicalQuantity
import com.splendo.kaluga.scientific.ScientificValue
import com.splendo.kaluga.scientific.converter.kinematicViscosity.kinematicViscosity
import com.splendo.kaluga.scientific.unit.Area
import com.splendo.kaluga.scientific.unit.Time
import com.splendo.kaluga.scientific.unit.per
import kotlin.jvm.JvmName

@JvmName("areaDivTime")
chrfilip marked this conversation as resolved.
Show resolved Hide resolved
infix operator fun <AreaUnit : Area> ScientificValue<PhysicalQuantity.Area, AreaUnit>.div(
time: ScientificValue<PhysicalQuantity.Time, Time>
) = (unit per time.unit).kinematicViscosity(this, time)
44 changes: 44 additions & 0 deletions scientific/src/commonMain/kotlin/converter/area/convertToTime.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright 2021 Splendo Consulting B.V. The Netherlands

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/

package com.splendo.kaluga.scientific.converter.area

import com.splendo.kaluga.scientific.PhysicalQuantity
import com.splendo.kaluga.scientific.ScientificValue
import com.splendo.kaluga.scientific.converter.time.time
import com.splendo.kaluga.scientific.unit.Area
import com.splendo.kaluga.scientific.unit.ImperialArea
import com.splendo.kaluga.scientific.unit.ImperialKinematicViscosity
import com.splendo.kaluga.scientific.unit.KinematicViscosity
import com.splendo.kaluga.scientific.unit.MetricArea
import com.splendo.kaluga.scientific.unit.MetricKinematicViscosity
import kotlin.jvm.JvmName

@JvmName("metricAreaDivMetricKinematicViscosity")
chrfilip marked this conversation as resolved.
Show resolved Hide resolved
infix operator fun <AreaUnit : MetricArea> ScientificValue<PhysicalQuantity.Area, AreaUnit>.div(
kinematicViscosity: ScientificValue<PhysicalQuantity.KinematicViscosity, MetricKinematicViscosity>
) = (kinematicViscosity.unit.time).time(this, kinematicViscosity)

@JvmName("imperialAreaDivKinematicViscosity")
infix operator fun <AreaUnit : ImperialArea> ScientificValue<PhysicalQuantity.Area, AreaUnit>.div(
kinematicViscosity: ScientificValue<PhysicalQuantity.KinematicViscosity, ImperialKinematicViscosity>
) = (kinematicViscosity.unit.time).time(this, kinematicViscosity)

@JvmName("areaDivKinematicViscosity")
infix operator fun <AreaUnit : Area, KinematicViscosityUnit : KinematicViscosity> ScientificValue<PhysicalQuantity.Area, AreaUnit>.div(
kinematicViscosity: ScientificValue<PhysicalQuantity.KinematicViscosity, KinematicViscosityUnit>
) = (kinematicViscosity.unit.time).time(this, kinematicViscosity)
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Copyright 2022 Splendo Consulting B.V. The Netherlands

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/

package com.splendo.kaluga.scientific.converter.kinematicViscosity

import com.splendo.kaluga.base.utils.Decimal
import com.splendo.kaluga.scientific.DefaultScientificValue
import com.splendo.kaluga.scientific.PhysicalQuantity
import com.splendo.kaluga.scientific.ScientificValue
import com.splendo.kaluga.scientific.byDividing
import com.splendo.kaluga.scientific.unit.Area
import com.splendo.kaluga.scientific.unit.KinematicViscosity
import com.splendo.kaluga.scientific.unit.Time
import kotlin.jvm.JvmName

@JvmName("kinematicViscosityFromAreaAndTimeDefault")
fun <
KinematicViscosityUnit : KinematicViscosity,
TimeUnit : Time,
AreaUnit : Area
> KinematicViscosityUnit.kinematicViscosity(
area: ScientificValue<PhysicalQuantity.Area, AreaUnit>,
time: ScientificValue<PhysicalQuantity.Time, TimeUnit>
) = kinematicViscosity(area, time, ::DefaultScientificValue)

@JvmName("kinematicViscosityFromAreaAndTime")
fun <
KinematicViscosityUnit : KinematicViscosity,
TimeUnit : Time,
AreaUnit : Area,
Value : ScientificValue<PhysicalQuantity.KinematicViscosity, KinematicViscosityUnit>
> KinematicViscosityUnit.kinematicViscosity(
area: ScientificValue<PhysicalQuantity.Area, AreaUnit>,
time: ScientificValue<PhysicalQuantity.Time, TimeUnit>,
factory: (Decimal, KinematicViscosityUnit) -> Value
) = byDividing(area, time, factory)
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2022 Splendo Consulting B.V. The Netherlands

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/

package com.splendo.kaluga.scientific.converter.kinematicViscosity

import com.splendo.kaluga.scientific.PhysicalQuantity
import com.splendo.kaluga.scientific.ScientificValue
import com.splendo.kaluga.scientific.converter.area.area
import com.splendo.kaluga.scientific.unit.ImperialKinematicViscosity
import com.splendo.kaluga.scientific.unit.KinematicViscosity
import com.splendo.kaluga.scientific.unit.MetricKinematicViscosity
import com.splendo.kaluga.scientific.unit.Time
import kotlin.jvm.JvmName

@JvmName("metricKinematicViscosityTimesTime")
infix operator fun <TimeUnit : Time> ScientificValue<PhysicalQuantity.KinematicViscosity, MetricKinematicViscosity>.times(
time: ScientificValue<PhysicalQuantity.Time, TimeUnit>
) = (unit.area).area(this, time)

@JvmName("imperialKinematicViscosityTimesTime")
infix operator fun <TimeUnit : Time> ScientificValue<PhysicalQuantity.KinematicViscosity, ImperialKinematicViscosity>.times(
time: ScientificValue<PhysicalQuantity.Time, TimeUnit>
) = (unit.area).area(this, time)

@JvmName("kinematicViscosityTimesTime")
infix operator fun <KinematicViscosityUnit : KinematicViscosity, TimeUnit : Time> ScientificValue<PhysicalQuantity.KinematicViscosity, KinematicViscosityUnit>.times(
time: ScientificValue<PhysicalQuantity.Time, TimeUnit>
) = (unit.area).area(this, time)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Copyright 2022 Splendo Consulting B.V. The Netherlands

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/

package com.splendo.kaluga.scientific.converter.kinematicViscosity

// TODO Implement these after this is fixed https://github.com/splendo/kaluga/issues/453
chrfilip marked this conversation as resolved.
Show resolved Hide resolved
// @JvmName("metricKinematicViscosityDivMetricArea")
// infix operator fun <AreaUnit : MetricArea> ScientificValue<PhysicalQuantity.KinematicViscosity, MetricKinematicViscosity>.times(
// area: ScientificValue<PhysicalQuantity.Area, AreaUnit>
// ) = this.unit.time.time(area, this)
//
// @JvmName("imperialKinematicViscosityTimesDivImperialArea")
// infix operator fun <AreaUnit : MetricArea> ScientificValue<PhysicalQuantity.KinematicViscosity, ImperialKinematicViscosity>.times(
// area: ScientificValue<PhysicalQuantity.Area, AreaUnit>
// ) = this.unit.time.time(area, this)
//
// @JvmName("kinematicViscosityTimesDivArea")
// infix operator fun <AreaUnit : MetricArea, KinematicViscosityUnit : KinematicViscosity> ScientificValue<PhysicalQuantity.KinematicViscosity, KinematicViscosityUnit>.times(
// area: ScientificValue<PhysicalQuantity.Area, AreaUnit>
// ) = this.unit.time.time(area, this)
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Copyright 2022 Splendo Consulting B.V. The Netherlands

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/

package com.splendo.kaluga.scientific.converter.time

import com.splendo.kaluga.base.utils.Decimal
import com.splendo.kaluga.scientific.DefaultScientificValue
import com.splendo.kaluga.scientific.PhysicalQuantity
import com.splendo.kaluga.scientific.ScientificValue
import com.splendo.kaluga.scientific.byDividing
import com.splendo.kaluga.scientific.unit.Area
import com.splendo.kaluga.scientific.unit.KinematicViscosity
import com.splendo.kaluga.scientific.unit.Time
import kotlin.jvm.JvmName

@JvmName("timeFromKinematicViscosityAndAreaDefault")
fun <
AreaUnit : Area,
KinematicViscosityUnit : KinematicViscosity,
TimeUnit : Time
> TimeUnit.time(
area: ScientificValue<PhysicalQuantity.Area, AreaUnit>,
kinematicViscosity: ScientificValue<PhysicalQuantity.KinematicViscosity, KinematicViscosityUnit>
) = time(area, kinematicViscosity, ::DefaultScientificValue)

@JvmName("timeFromKinematicViscosityAndArea")
fun <
AreaUnit : Area,
KinematicViscosityUnit : KinematicViscosity,
TimeUnit : Time,
Value : ScientificValue<PhysicalQuantity.Time, TimeUnit>
> TimeUnit.time(
area: ScientificValue<PhysicalQuantity.Area, AreaUnit>,
kinematicViscosity: ScientificValue<PhysicalQuantity.KinematicViscosity, KinematicViscosityUnit>,
factory: (Decimal, TimeUnit) -> Value
) = byDividing(area, kinematicViscosity, factory)
47 changes: 47 additions & 0 deletions scientific/src/commonMain/kotlin/converter/time/convertToArea.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright 2021 Splendo Consulting B.V. The Netherlands

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/

package com.splendo.kaluga.scientific.converter.time

import com.splendo.kaluga.scientific.PhysicalQuantity
import com.splendo.kaluga.scientific.ScientificValue
import com.splendo.kaluga.scientific.converter.area.area
import com.splendo.kaluga.scientific.converter.force.div
import com.splendo.kaluga.scientific.converter.kinematicViscosity.kinematicViscosity
import com.splendo.kaluga.scientific.converter.momentum.div
import com.splendo.kaluga.scientific.invoke
import com.splendo.kaluga.scientific.times
import com.splendo.kaluga.scientific.unit.ImperialKinematicViscosity
import com.splendo.kaluga.scientific.unit.KinematicViscosity
import com.splendo.kaluga.scientific.unit.MetricKinematicViscosity
import com.splendo.kaluga.scientific.unit.Time
import kotlin.jvm.JvmName

@JvmName("timeTimesMetricKinematicViscosity")
infix operator fun <TimeUnit : Time> ScientificValue<PhysicalQuantity.Time, TimeUnit>.times(
kinematicViscosity: ScientificValue<PhysicalQuantity.KinematicViscosity, MetricKinematicViscosity>
) = (kinematicViscosity.unit.area).area(kinematicViscosity, this)

@JvmName("timeTimesImperialKinematicViscosity")
infix operator fun <TimeUnit : Time> ScientificValue<PhysicalQuantity.Time, TimeUnit>.times(
kinematicViscosity: ScientificValue<PhysicalQuantity.KinematicViscosity, ImperialKinematicViscosity>
) = (kinematicViscosity.unit.area).area(kinematicViscosity, this)

@JvmName("timeTimesKinematicViscosity")
infix operator fun <TimeUnit : Time, KinematicViscosityUnit : KinematicViscosity> ScientificValue<PhysicalQuantity.Time, TimeUnit>.times(
kinematicViscosity: ScientificValue<PhysicalQuantity.KinematicViscosity, KinematicViscosityUnit>
) = (kinematicViscosity.unit.area).area(kinematicViscosity, this)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Copyright 2022 Splendo Consulting B.V. The Netherlands

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/

package com.splendo.kaluga.scientific.converter.time

// TODO Implement these after this is fixed https://github.com/splendo/kaluga/issues/453
// @JvmName("timeDivMetricArea")
// infix operator fun <AreaUnit : MetricArea> ScientificValue<PhysicalQuantity.Time, Time>.div(
// area: ScientificValue<PhysicalQuantity.Area, AreaUnit>
// ) = area / this
//
// @JvmName("timeDivImperialArea")
// infix operator fun <AreaUnit : ImperialArea> ScientificValue<PhysicalQuantity.Time, Time>.div(
// area: ScientificValue<PhysicalQuantity.Area, AreaUnit>
// ) = area / this
//
// @JvmName("timeDivArea")
// infix operator fun <AreaUnit : Area> ScientificValue<PhysicalQuantity.Time, Time>.div(
// area: ScientificValue<PhysicalQuantity.Area, AreaUnit>
// ) = area / this
Loading