Coder Social home page Coder Social logo

Comments (3)

axsk avatar axsk commented on May 28, 2024 1

I ended up using exactly that approach and it's fine. A little more verbose then a System(oldsys, coordinates=newcoords) but certainly no priority.

I was just surprised that the 'common' approach did not work (and the type parameter list was too long to spot the problem :D) and Accessors failed too. IMHO in the long run compatibility with Accessors or a 're-constructor' would be nice to have, but I'm fine off knowing about it now.

Thanks for the info!

from molly.jl.

jgreener64 avatar jgreener64 commented on May 28, 2024 1

Perhaps there is use for a System constructor that takes in an existing System and keyword arguments for any properties that should be changed, returning a copy.

This is now on master, e.g. System(sys; coords=(sys.coords .* 0.5)).

from molly.jl.

jgreener64 avatar jgreener64 commented on May 28, 2024

The type parameters of System require some calculation and don't map directly to the fields. This is to allow certain properties to be put into the type domain for dispatch and performance. If you are constructing directly with fields... you would need to specify the type parameters, see:

Molly.jl/src/types.jl

Lines 391 to 394 in b172d0d

return System{D, G, T, CU, A, AD, PI, SI, GI, CN, C, V, B, NF, L, F, E, K}(
atoms, atoms_data, pairwise_inters, specific_inter_lists,
general_inters, constraints, coords, vels, boundary, neighbor_finder,
loggers, force_units, energy_units, k_converted)

You can copy a System with deepcopy too. In general, though, I would use the keyword argument constructor for System since it won't be the bottleneck in most code.

Perhaps there is use for a System constructor that takes in an existing System and keyword arguments for any properties that should be changed, returning a copy. At the moment I just do something like:

sys2 = System(
    atoms=sys.atoms,
    coords=sys.coords,
    ...
)

from molly.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.