-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #364 from inowas/dev
Merge dev into master
- Loading branch information
Showing
130 changed files
with
4,790 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import {BoundaryCollection, ModflowModel, Soilmodel, VariableDensity} from '../../modflow'; | ||
import {FlopyMt3d} from '../../flopy/packages/mt'; | ||
import {FlopySeawat} from '../../flopy'; | ||
import { IBoundary } from '../../modflow/boundaries/Boundary.type'; | ||
import { IFlopyPackages } from '../../flopy/packages/FlopyPackages.type'; | ||
import {IModflowModel} from '../../modflow/ModflowModel.type'; | ||
import {ISoilmodel} from '../../modflow/soilmodel/Soilmodel.type'; | ||
import { ITransport } from '../../modflow/transport/Transport.type'; | ||
import {IVariableDensity} from '../../modflow/variableDensity/VariableDensity.type'; | ||
import FlopyModflow from '../../flopy/packages/mf/FlopyModflow'; | ||
import FlopyModpath from '../../flopy/packages/mp/FlopyModpath'; | ||
import FlopyPackages from '../../flopy/packages/FlopyPackages'; | ||
import Transport from '../../modflow/transport/Transport'; | ||
|
||
export interface IFullModflowModel extends IModflowModel { | ||
boundaries: IBoundary[]; | ||
soilmodel: ISoilmodel; | ||
transport: ITransport; | ||
variableDensity: IVariableDensity; | ||
packages?: IFlopyPackages; | ||
} | ||
|
||
class FullModflowModel extends ModflowModel { | ||
|
||
constructor( | ||
model: ModflowModel, | ||
soilmodel: Soilmodel, | ||
boundaries: BoundaryCollection, | ||
transport: Transport, | ||
variableDensity: VariableDensity, | ||
packages?: FlopyPackages | ||
) { | ||
super(model.toObject()); | ||
this._props = { | ||
...model.toObject(), | ||
boundaries: boundaries.toObject(), | ||
soilmodel: soilmodel.toObject(), | ||
transport: transport.toObject(), | ||
variableDensity: variableDensity.toObject(), | ||
packages: packages ? packages.toObject() : undefined | ||
}; | ||
} | ||
|
||
protected readonly _props: IFullModflowModel; | ||
|
||
public applyRTModelling(): void { | ||
// this.stressperiods.addStressPeriod() | ||
// this.boundaries.applySPValues | ||
} | ||
|
||
get packages(): FlopyPackages { | ||
if (this._props.packages) { | ||
return FlopyPackages.fromObject(this._props.packages).update( | ||
this, this.soilmodel, this.boundaries, this.transport, this.variableDensity | ||
); | ||
} | ||
|
||
return FlopyPackages.create( | ||
this.id, | ||
FlopyModflow.create(this, this.soilmodel, this.boundaries), | ||
FlopyModpath.create(), | ||
FlopyMt3d.create(this.transport, this.boundaries), | ||
FlopySeawat.create(this.variableDensity) | ||
); | ||
} | ||
|
||
get boundaries(): BoundaryCollection { | ||
return BoundaryCollection.fromObject(this._props.boundaries); | ||
} | ||
|
||
get soilmodel(): Soilmodel { | ||
return Soilmodel.fromObject(this._props.soilmodel); | ||
} | ||
|
||
get transport(): Transport { | ||
return Transport.fromObject(this._props.transport); | ||
} | ||
|
||
get variableDensity(): VariableDensity { | ||
return VariableDensity.fromObject(this._props.variableDensity); | ||
} | ||
} | ||
|
||
export default FullModflowModel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import {EMethodType, ETimeResolution, IRtModelling} from './RTModelling.type'; | ||
|
||
const rtm: IRtModelling = { | ||
id: 'cfc437d8-c3de-4d7b-91c3-dc5e967cb2bb', | ||
name: 'example_project', | ||
description: 'this is an example project', | ||
permissions: 'rwx', | ||
public: true, | ||
tool: 'T20', | ||
data: { | ||
model_id: '65a66f45-b6fd-4d38-a42e-484a2b7dc4e4', | ||
automatic_calculation: true, | ||
start_date_time: '2020-11-01', | ||
time_resolution: ETimeResolution.DAILY, | ||
simulated_times: [1, 2, 3, 4, 5], | ||
head: [ | ||
{ | ||
// WEL | ||
boundary_id: '6d0eeb77-3636-439b-a0cc-89fa885b4c77', | ||
data: [ | ||
{ | ||
method: EMethodType.CONSTANT, | ||
values: [10.59483, 10.59483, 10.59483, 10.59483, 10.59483] | ||
} | ||
] | ||
}, | ||
{ | ||
// CHD | ||
boundary_id: 'e68896f9-e48f-453c-9344-ea68c1f951f4', | ||
data: { | ||
'id_of_op1': [ | ||
// SHead | ||
{ | ||
method: EMethodType.SENSOR, | ||
monitoring_id: '8c95fd88-389f-40d6-bf4f-e387f553b378', | ||
sensor_id: '5c4af919-6a94-43a2-a106-66f9d9d80814', | ||
parameter_id: 'head', | ||
values: [100.3, 100.2, 100.3, 100.2, 100.4] | ||
}, | ||
// EHead | ||
{ | ||
method: EMethodType.CONSTANT, | ||
values: null | ||
} | ||
], | ||
'id_of_op2': [ | ||
// SHead | ||
{ | ||
method: EMethodType.CONSTANT, | ||
values: null | ||
}, | ||
// EHead | ||
{ | ||
method: EMethodType.FUNCTION, | ||
function: 'x + t / 1000', | ||
values: null | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
import { | ||
EMethodType, | ||
ETimeResolution, | ||
IRTModellingHead, | ||
IRtModelling, | ||
IRtModellingData, IRtModellingResults, | ||
RTModellingObservationPoint | ||
} from './RTModelling.type'; | ||
import {GenericObject} from '../../genericObject/GenericObject'; | ||
import {LineBoundary} from '../../modflow/boundaries'; | ||
import BoundaryCollection from '../../modflow/boundaries/BoundaryCollection'; | ||
import _, {cloneDeep} from 'lodash'; | ||
import uuid from 'uuid'; | ||
|
||
class RTModelling extends GenericObject<IRtModelling> { | ||
|
||
get id(): string { | ||
return this._props.id; | ||
} | ||
|
||
set id(value: string) { | ||
this._props.id = value; | ||
} | ||
|
||
get name(): string { | ||
return this._props.name; | ||
} | ||
|
||
set name(value: string) { | ||
this._props.name = value; | ||
} | ||
|
||
get calculationId() { | ||
return this._props.data.calculation_id; | ||
} | ||
|
||
get data(): IRtModellingData { | ||
return this._props.data; | ||
} | ||
|
||
set data(value: IRtModellingData) { | ||
this._props.data = value; | ||
} | ||
|
||
get description(): string { | ||
return this._props.description; | ||
} | ||
|
||
set description(value: string) { | ||
this._props.description = value; | ||
} | ||
|
||
get heads(): IRTModellingHead[] | undefined { | ||
return this._props.data.head; | ||
} | ||
|
||
get permissions(): string { | ||
return this._props.permissions; | ||
} | ||
|
||
set permissions(value: string) { | ||
this._props.permissions = value; | ||
} | ||
|
||
get public(): boolean { | ||
return this._props.public; | ||
} | ||
|
||
set public(value: boolean) { | ||
this._props.public = value; | ||
} | ||
|
||
get results(): IRtModellingResults | null { | ||
if (!this._props.data.results) { | ||
return null; | ||
} | ||
return { | ||
boundaries: this._props.data.results.boundaries, | ||
model: this._props.data.results.model | ||
} | ||
} | ||
|
||
set results(value: IRtModellingResults | null) { | ||
this._props.data.results = value; | ||
} | ||
|
||
get startDate() { | ||
return new Date(this._props.data.start_date_time); | ||
} | ||
|
||
get timeResolution() { | ||
return this._props.data.time_resolution; | ||
} | ||
|
||
get tool(): string { | ||
return this._props.tool; | ||
} | ||
|
||
public static fromDefaults() { | ||
return new RTModelling({ | ||
id: uuid.v4(), | ||
name: 'New Realtime Modelling', | ||
data: { | ||
model_id: null, | ||
automatic_calculation: false, | ||
start_date_time: '', | ||
time_resolution: ETimeResolution.DAILY, | ||
simulated_times: [], | ||
}, | ||
description: '', | ||
permissions: 'rwx', | ||
public: true, | ||
tool: 'T20' | ||
}); | ||
} | ||
|
||
public static fromObject(obj: IRtModelling) { | ||
return new RTModelling(obj); | ||
} | ||
|
||
public toObject(): IRtModelling { | ||
return cloneDeep(this._props); | ||
} | ||
|
||
public toQuery(): IRtModelling { | ||
const p = cloneDeep(this._props); | ||
|
||
return { | ||
...p, | ||
data: { | ||
...p.data, | ||
results: undefined, | ||
head: p.data.head ? p.data.head.map((h) => { | ||
if (Array.isArray(h.data)) { | ||
return { | ||
...h, | ||
data: h.data.map((r) => { | ||
return { | ||
...r, | ||
values: null | ||
}; | ||
}) | ||
}; | ||
} | ||
const keys = Object.keys(h.data); | ||
const data: { [k: string]: any } = {}; | ||
keys.forEach((key) => { | ||
data[key] = (h.data as RTModellingObservationPoint)[key].map((m) => { | ||
return { | ||
...m, | ||
values: null | ||
} | ||
}) | ||
}) | ||
return { | ||
...h, | ||
data | ||
}; | ||
}) : undefined | ||
} | ||
}; | ||
} | ||
|
||
public updateHeadsFromBoundaries = (boundaries: BoundaryCollection) => { | ||
const heads: IRTModellingHead[] = this.heads ? _.cloneDeep(this.heads) : []; | ||
|
||
boundaries.all.forEach((b) => { | ||
const filtered = heads ? heads.filter((h) => h.boundary_id === b.id) : []; | ||
if (filtered.length === 0) { | ||
if (b instanceof LineBoundary) { | ||
const data: RTModellingObservationPoint = {}; | ||
b.observationPoints.forEach((op) => { | ||
data[op.id] = b.valueProperties.map(() => { | ||
return { | ||
method: EMethodType.CONSTANT, | ||
values: null | ||
}; | ||
}); | ||
}); | ||
heads.push({ | ||
boundary_id: b.id, | ||
data | ||
}); | ||
} else { | ||
heads.push({ | ||
boundary_id: b.id, | ||
data: b.valueProperties.map(() => { | ||
return { | ||
method: EMethodType.CONSTANT, | ||
values: null | ||
}; | ||
}) | ||
}); | ||
} | ||
} | ||
}); | ||
|
||
this._props.data.head = heads; | ||
return this; | ||
} | ||
} | ||
|
||
export default RTModelling; |
Oops, something went wrong.