Giter VIP home page Giter VIP logo

Comments (2)

armantekinalp avatar armantekinalp commented on June 22, 2024

Hello,

Yes you can apply torque in a certain time interval. For that I suggest you to write your own forcing class. Below I am also adding an example code for you.

class MyNewTorqueClass(NoForces):
    def __init__(self, torque_mag: float, torque_direction, time_start: float, time_end: float):

        self.torque_mag = torque_mag 
        self.torque_direction = torque_direction # defined in global frame, shape(3,1)
        self.time_start = time_start
        self.time_end = time_end

   def apply_forces(self, system, time: np.float = 0.0):
        return

   def apply_torques(self, system, time: np.float = 0.0):
       
        if time > self.time_start and time < self.time_end:
               torque_vector = self.torque_mag * self.torque_direction 
        else:
               torque_vector = np.array([0., 0., 0.]).reshape(3,1)

        system.external_torques += _batch_matvec(
            system.director_collection, torque_vector
        )

There are couple of example forcing classes in elastica/external_forces.py, check them out as well. Let me know if you have more questions.

from pyelastica.

pcsong33 avatar pcsong33 commented on June 22, 2024

Thank you for your help!

from pyelastica.

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.