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

Optimade namespace #35

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deploy-to-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:

- uses: hyoo-ru/mam_build@master2
with:
package: mpds/cifplayer
package: optimade/cifplayer
modules: app

- uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: mpds/cifplayer/app/-
folder: optimade/cifplayer/app/-
2 changes: 1 addition & 1 deletion app/app.view.css.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace $.$$ {

$mol_style_define( $mpds_cifplayer_app, {
$mol_style_define( $optimade_cifplayer_app, {

contain: 'none', // otherwise in fullscreen 'fixed' positions plot relative to parent is not in the viewport

Expand Down
4 changes: 2 additions & 2 deletions app/app.view.tree
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$mpds_cifplayer_app $mol_drop
$optimade_cifplayer_app $mol_drop
receive? <=> drop_file? null
Sub <= Book $mol_book2
plugins /
Expand All @@ -25,7 +25,7 @@ $mpds_cifplayer_app $mol_drop
<= Data_text $mol_textarea
value? <=> data_str?
hint \or paste here...
<= Player $mpds_cifplayer_player
<= Player $optimade_cifplayer_player
data <= data_str? \
vibrate? => vibrate?
unvibrate => unvibrate
Expand Down
2 changes: 1 addition & 1 deletion app/app.view.web.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace $.$$ {
export class $mpds_cifplayer_app extends $.$mpds_cifplayer_app {
export class $optimade_cifplayer_app extends $.$optimade_cifplayer_app {

@ $mol_mem
pages(): readonly any[] {
Expand Down
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="apple-mobile-web-app-capable" content="yes">
</head>
<body mol_view_root>
<div mol_view_root="$mpds_cifplayer_app"></div>
<div mol_view_root="$optimade_cifplayer_app"></div>
<script src="web.js" charset="utf-8"></script>
</body>
</html>
6 changes: 3 additions & 3 deletions demo/demo.view.tree
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
$mpds_cifplayer_demo $mol_book2_catalog
$optimade_cifplayer_demo $mol_book2_catalog
plugins /
<= Theme $mol_theme_auto
menu_title \Demo
Placeholder null
spreads *
app <= App $mpds_cifplayer_app
app <= App $optimade_cifplayer_app
title \App
phonons <= Phonons $mpds_cifplayer_phonons
phonons <= Phonons $optimade_cifplayer_phonons
title \Phonons example
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="apple-mobile-web-app-capable" content="yes">
</head>
<body mol_view_root>
<div mol_view_root="$mpds_cifplayer_demo"></div>
<div mol_view_root="$optimade_cifplayer_demo"></div>
<script src="web.js" charset="utf-8"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion lib/cif/cif.meta.tree
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require \/mpds/cifplayer/lib/cif/_cif.js
require \/optimade/cifplayer/lib/cif/_cif.js
4 changes: 2 additions & 2 deletions lib/cif/cif.web.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace $ {

export class $mpds_cifplayer_lib_cif extends $mol_object2 {
export class $optimade_cifplayer_lib_cif extends $mol_object2 {

@ $mol_mem
static all() {
return require( '../mpds/cifplayer/lib/cif/_cif.js' ) as typeof import( './_cif' )
return require( '../optimade/cifplayer/lib/cif/_cif.js' ) as typeof import( './_cif' )
}

@ $mol_mem
Expand Down
2 changes: 1 addition & 1 deletion lib/math/math.meta.tree
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require \/mpds/cifplayer/lib/math/_math.js
require \/optimade/cifplayer/lib/math/_math.js
2 changes: 1 addition & 1 deletion lib/math/math.web.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace $ {

export const $mpds_cifplayer_lib_math = require( '../mpds/cifplayer/lib/math/_math.js' ) //as typeof import( './build/_math' )
export const $optimade_cifplayer_lib_math = require( '../optimade/cifplayer/lib/math/_math.js' ) //as typeof import( './build/_math' )

}
2 changes: 1 addition & 1 deletion lib/spacegroups/spacegroups.meta.tree
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require \/mpds/cifplayer/lib/spacegroups/_spacegroups.js
require \/optimade/cifplayer/lib/spacegroups/_spacegroups.js
4 changes: 2 additions & 2 deletions lib/spacegroups/spacegroups.web.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace $ {

export const $mpds_cifplayer_lib_spacegroups = require( '../mpds/cifplayer/lib/spacegroups/_spacegroups.js' ) as typeof import( './_spacegroups' )
export type $mpds_cifplayer_lib_spacegroups_info = import( './_spacegroups' ).SpaceGroupInfo
export const $optimade_cifplayer_lib_spacegroups = require( '../optimade/cifplayer/lib/spacegroups/_spacegroups.js' ) as typeof import( './_spacegroups' )
export type $optimade_cifplayer_lib_spacegroups_info = import( './_spacegroups' ).SpaceGroupInfo

}
2 changes: 1 addition & 1 deletion lib/three/three.meta.tree
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require \/mpds/cifplayer/lib/three/_three.js
require \/optimade/cifplayer/lib/three/_three.js
2 changes: 1 addition & 1 deletion lib/three/three.web.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace $ {

export const $mpds_cifplayer_lib_three = require( '../mpds/cifplayer/lib/three/_three.js' ) as typeof import( './_three' )
export const $optimade_cifplayer_lib_three = require( '../optimade/cifplayer/lib/three/_three.js' ) as typeof import( './_three' )

}
2 changes: 1 addition & 1 deletion lib/three/view/view.view.css.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace $.$$ {

$mol_style_define( $mpds_cifplayer_lib_three_view, {
$mol_style_define( $optimade_cifplayer_lib_three_view, {

flex: {
grow: 1,
Expand Down
2 changes: 1 addition & 1 deletion lib/three/view/view.view.tree
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$mpds_cifplayer_lib_three_view $mol_view
$optimade_cifplayer_lib_three_view $mol_view
sub /
<= canvas null
scene null
Expand Down
10 changes: 5 additions & 5 deletions lib/three/view/view.view.web.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace $.$$ {

const THREE = $mpds_cifplayer_lib_three
const THREE = $optimade_cifplayer_lib_three
type THREE = typeof THREE

export class $mpds_cifplayer_lib_three_view extends $.$mpds_cifplayer_lib_three_view {
export class $optimade_cifplayer_lib_three_view extends $.$optimade_cifplayer_lib_three_view {

@ $mol_mem
start_render_loop() {
Expand Down Expand Up @@ -40,7 +40,7 @@ namespace $.$$ {
}

remove_object( obj: any ) {
$mpds_cifplayer_lib_three_view_dispose_deep( obj )
$optimade_cifplayer_lib_three_view_dispose_deep( obj )
this.scene()?.remove( obj )
}

Expand Down Expand Up @@ -125,7 +125,7 @@ namespace $.$$ {
}

destructor(): void {
$mpds_cifplayer_lib_three_view_dispose_deep( this.scene() )
$optimade_cifplayer_lib_three_view_dispose_deep( this.scene() )
this.renderer()?.dispose()
}

Expand All @@ -138,7 +138,7 @@ namespace $.$$ {
* @param object Object3D, BufferGeometry, Material or Texture
* @param disposeMedia If set to true will dispose of the texture image or video element, default false
*/
export function $mpds_cifplayer_lib_three_view_dispose_deep(
export function $optimade_cifplayer_lib_three_view_dispose_deep(
object: InstanceType< THREE["Object3D"] > | InstanceType< THREE["BufferGeometry"] > | InstanceType< THREE["Material"] > | InstanceType< THREE["Texture"] >
) {
const dispose = ( object: InstanceType< THREE["BufferGeometry"] > | InstanceType< THREE["Material"] > | InstanceType< THREE["Texture"] > ) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/tween/tween.meta.tree
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require \/mpds/cifplayer/lib/tween/_tween.js
require \/optimade/cifplayer/lib/tween/_tween.js
2 changes: 1 addition & 1 deletion lib/tween/tween.web.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace $ {

export const $mpds_cifplayer_lib_tween = require( '../mpds/cifplayer/lib/tween/_tween.js' ) as typeof import( './_tween' )
export const $optimade_cifplayer_lib_tween = require( '../optimade/cifplayer/lib/tween/_tween.js' ) as typeof import( './_tween' )

}
8 changes: 4 additions & 4 deletions matinfio/cell/cell.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace $ {

const math = $mpds_cifplayer_lib_math
const math = $optimade_cifplayer_lib_math

function unit( vec: number[] ): number[] {
return math.divide( vec, math.norm( vec ) )
}

export type $mpds_cifplayer_matinfio_cell = {
export type $optimade_cifplayer_matinfio_cell = {
a: number,
b: number,
c: number,
Expand All @@ -16,7 +16,7 @@ namespace $ {
}

/** Crystalline cell parameters to 3x3 matrix */
export function $mpds_cifplayer_matinfio_cell_to_matrix( this : $, cell: $mpds_cifplayer_matinfio_cell ): number[][] {
export function $optimade_cifplayer_matinfio_cell_to_matrix( this : $, cell: $optimade_cifplayer_matinfio_cell ): number[][] {
const { a, b, c, alpha, beta, gamma } = cell
if( !a || !b || !c || !alpha || !beta || !gamma ) {
return this.$mol_fail( new $mol_data_error('Error: invalid cell definition') )
Expand All @@ -43,7 +43,7 @@ namespace $ {
}

/** 3x3 matrix to crystalline cell parameters */
export function $mpds_cifplayer_matinfio_cell_params_from_matrix( matrix: number[][] ) {
export function $optimade_cifplayer_matinfio_cell_params_from_matrix( matrix: number[][] ) {
const norms: number[] = matrix.map( vec => math.norm( vec ) )
const angles = []
let j = -1
Expand Down
18 changes: 9 additions & 9 deletions matinfio/cif/cif.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
namespace $ {

const math = $mpds_cifplayer_lib_math
const math = $optimade_cifplayer_lib_math

export function $mpds_cifplayer_matinfio_cif_to_obj( this: $, str: string ): $mpds_cifplayer_matinfio_internal_obj {
export function $optimade_cifplayer_matinfio_cif_to_obj( this: $, str: string ): $optimade_cifplayer_matinfio_internal_obj {
const structures = []
let symops = []
let atprop_seq: any[] = []
let lines = str.toString().replace( /(\r\n|\r)/gm, "\n" ).split( "\n" )
let cur_structure: any | $mpds_cifplayer_matinfio_internal_obj = {
let cur_structure: any | $optimade_cifplayer_matinfio_internal_obj = {
cell: {},
atoms: [],
cartesian: false,
Expand Down Expand Up @@ -45,7 +45,7 @@ namespace $ {
const chem_element_idxs = [ 0, 1 ]
let overlayed_idxs = []

for( let oprop in $mpds_cifplayer_matinfio_custom_atom_loop_props ) {
for( let oprop in $optimade_cifplayer_matinfio_custom_atom_loop_props ) {
overlayed_idxs.push( loop_vals.length )
loop_vals.push( oprop )
}
Expand Down Expand Up @@ -127,7 +127,7 @@ namespace $ {
}
line_data = cur_line.replace( /\t/g, " " ).split( " " ).filter( function( o ) { return o ? true : false } )

const atom: any | $mpds_cifplayer_matinfio_internal_obj_atom = { overlays: {} }
const atom: any | $optimade_cifplayer_matinfio_internal_obj_atom = { overlays: {} }

for( let j = 0; j < atprop_seq.length; j++ ) { // TODO handle in-loop mismatch
const atom_index = loop_vals.indexOf( atprop_seq[ j ] )
Expand All @@ -148,7 +148,7 @@ namespace $ {
atom.overlays.label = atom.label
if( !atom.symbol ) atom.symbol = atom.label.replace( /[0-9]/g, '' )
}
if( !( $mpds_cifplayer_matinfio_chemical_elements.JmolColors as any )[ atom.symbol ]
if( !( $optimade_cifplayer_matinfio_chemical_elements.JmolColors as any )[ atom.symbol ]
&& atom.symbol
&& atom.symbol.length > 1
) {
Expand Down Expand Up @@ -187,18 +187,18 @@ namespace $ {


/** Convert internal repr into CIF */
export function $mpds_cifplayer_matinfio_cif_from_obj( this: $, crystal: any ) {
export function $optimade_cifplayer_matinfio_cif_from_obj( this: $, crystal: any ) {

let cif_str = "data_matinfio\n"
let cell_abc
let cell_mat

if( Object.keys( crystal.cell ).length == 6 ) {
cell_abc = crystal.cell
cell_mat = this.$mpds_cifplayer_matinfio_cell_to_matrix( crystal.cell )
cell_mat = this.$optimade_cifplayer_matinfio_cell_to_matrix( crystal.cell )
// cell_mat = this.cell2vec( ...( crystal.cell as [ number, number, number, number, number, number ] ) )
} else {
cell_abc = $mpds_cifplayer_matinfio_cell_params_from_matrix( crystal.cell )
cell_abc = $optimade_cifplayer_matinfio_cell_params_from_matrix( crystal.cell )
cell_mat = crystal.cell
}
cif_str += "_cell_length_a " + cell_abc[ 0 ].toFixed( 6 ) + "\n"
Expand Down
6 changes: 3 additions & 3 deletions matinfio/flatten/flatten.web.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
namespace $ {

/** Convert internal repr into a flattened C-alike structure */
export function $mpds_cifplayer_matinfio_flatten_from_obj( this: $, crystal: any ) {
if( crystal.symops ) this.$mpds_cifplayer_matinfio_log.warning( "Reading of symmetry operations is not implemented, expect errors" )
export function $optimade_cifplayer_matinfio_flatten_from_obj( this: $, crystal: any ) {
if( crystal.symops ) this.$optimade_cifplayer_matinfio_log.warning( "Reading of symmetry operations is not implemented, expect errors" )

const cell = Object.keys( crystal.cell ).length == 6
? this.$mpds_cifplayer_matinfio_cell_to_matrix( crystal.cell ) // for CIF
? this.$optimade_cifplayer_matinfio_cell_to_matrix( crystal.cell ) // for CIF
: crystal.cell // for POSCAR

const xyzatoms = []
Expand Down
Loading
Loading