<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://dna.physics.ox.ac.uk/index.php?action=history&amp;feed=atom&amp;title=How_To_Write_An_Interaction</id>
	<title>How To Write An Interaction - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://dna.physics.ox.ac.uk/index.php?action=history&amp;feed=atom&amp;title=How_To_Write_An_Interaction"/>
	<link rel="alternate" type="text/html" href="https://dna.physics.ox.ac.uk/index.php?title=How_To_Write_An_Interaction&amp;action=history"/>
	<updated>2026-06-08T20:07:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://dna.physics.ox.ac.uk/index.php?title=How_To_Write_An_Interaction&amp;diff=1086&amp;oldid=prev</id>
		<title>Randisi at 11:37, 1 February 2018</title>
		<link rel="alternate" type="text/html" href="https://dna.physics.ox.ac.uk/index.php?title=How_To_Write_An_Interaction&amp;diff=1086&amp;oldid=prev"/>
		<updated>2018-02-01T11:37:58Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:37, 1 February 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l12&quot;&gt;Line 12:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 12:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# &amp;lt;tt&amp;gt;src/Interactions/InteractionFactory.cpp&amp;lt;/tt&amp;gt; Now your file will be compiled, but it&amp;#039;s still disjoint from the rest of the program. In order to make sure that the oxDNA program can use your interaction, you must modify the &amp;lt;tt&amp;gt;InteractionFactory.cpp&amp;lt;/tt&amp;gt; file to use your interaction.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# &amp;lt;tt&amp;gt;src/Interactions/InteractionFactory.cpp&amp;lt;/tt&amp;gt; Now your file will be compiled, but it&amp;#039;s still disjoint from the rest of the program. In order to make sure that the oxDNA program can use your interaction, you must modify the &amp;lt;tt&amp;gt;InteractionFactory.cpp&amp;lt;/tt&amp;gt; file to use your interaction.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;## Add the header file &amp;lt;tt&amp;gt;#include &quot;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;JordanInteraction&lt;/del&gt;.h&quot;&amp;lt;/tt&amp;gt; together with the other interaction header files, at the beginning of the file.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;## Add the header file &amp;lt;tt&amp;gt;#include &quot;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;MyInteraction&lt;/ins&gt;.h&quot;&amp;lt;/tt&amp;gt; together with the other interaction header files, at the beginning of the file.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;## In the function &amp;lt;tt&amp;gt;make_interaction&amp;lt;/tt&amp;gt; there&amp;#039;s a long list of statements that create a different type of interaction depending on the value of the &amp;lt;tt&amp;gt;interaction_type&amp;lt;/tt&amp;gt; string in the oxDNA input file. Add your own interaction there, making sure not to mask any previously defined interactions. The syntax of the code of block might change, but currently it&amp;#039;s just a bunch of lines like &amp;lt;br&amp;gt; &amp;lt;br&amp;gt; &amp;lt;tt&amp;gt;else if(inter_type.compare(&amp;quot;DNA_nomesh&amp;quot;) == 0) return new DNAInteraction_nomesh&amp;lt;number&amp;gt;();&amp;lt;br&amp;gt;  else if(inter_type.compare(&amp;quot;DNA2_nomesh&amp;quot;) == 0) return new DNA2Interaction_nomesh&amp;lt;number&amp;gt;();&amp;lt;br&amp;gt;   else if(inter_type.compare(&amp;quot;LJ&amp;quot;) == 0) return new LJInteraction&amp;lt;number&amp;gt;();&amp;lt;br&amp;gt;  else if(inter_type.compare(&amp;quot;DNA_relax&amp;quot;) == 0) return new DNAInteraction_relax&amp;lt;number&amp;gt;();&amp;lt;br&amp;gt;   else if(inter_type.compare(&amp;quot;RNA&amp;quot;) == 0) return new RNAInteraction&amp;lt;number&amp;gt;();&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt; so you would just add the line &amp;lt;br&amp;gt;&amp;lt;br&amp;gt; &amp;lt;tt&amp;gt;else if(inter_type.compare(&amp;quot;my_interaction&amp;quot;) == 0) return new MyInteraction&amp;lt;number&amp;gt;();&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt; somewhere over there.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;## In the function &amp;lt;tt&amp;gt;make_interaction&amp;lt;/tt&amp;gt; there&amp;#039;s a long list of statements that create a different type of interaction depending on the value of the &amp;lt;tt&amp;gt;interaction_type&amp;lt;/tt&amp;gt; string in the oxDNA input file. Add your own interaction there, making sure not to mask any previously defined interactions. The syntax of the code of block might change, but currently it&amp;#039;s just a bunch of lines like &amp;lt;br&amp;gt; &amp;lt;br&amp;gt; &amp;lt;tt&amp;gt;else if(inter_type.compare(&amp;quot;DNA_nomesh&amp;quot;) == 0) return new DNAInteraction_nomesh&amp;lt;number&amp;gt;();&amp;lt;br&amp;gt;  else if(inter_type.compare(&amp;quot;DNA2_nomesh&amp;quot;) == 0) return new DNA2Interaction_nomesh&amp;lt;number&amp;gt;();&amp;lt;br&amp;gt;   else if(inter_type.compare(&amp;quot;LJ&amp;quot;) == 0) return new LJInteraction&amp;lt;number&amp;gt;();&amp;lt;br&amp;gt;  else if(inter_type.compare(&amp;quot;DNA_relax&amp;quot;) == 0) return new DNAInteraction_relax&amp;lt;number&amp;gt;();&amp;lt;br&amp;gt;   else if(inter_type.compare(&amp;quot;RNA&amp;quot;) == 0) return new RNAInteraction&amp;lt;number&amp;gt;();&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt; so you would just add the line &amp;lt;br&amp;gt;&amp;lt;br&amp;gt; &amp;lt;tt&amp;gt;else if(inter_type.compare(&amp;quot;my_interaction&amp;quot;) == 0) return new MyInteraction&amp;lt;number&amp;gt;();&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt; somewhere over there.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Randisi</name></author>
	</entry>
	<entry>
		<id>https://dna.physics.ox.ac.uk/index.php?title=How_To_Write_An_Interaction&amp;diff=1081&amp;oldid=prev</id>
		<title>Randisi: Creating the guideline</title>
		<link rel="alternate" type="text/html" href="https://dna.physics.ox.ac.uk/index.php?title=How_To_Write_An_Interaction&amp;diff=1081&amp;oldid=prev"/>
		<updated>2018-01-17T14:40:01Z</updated>

		<summary type="html">&lt;p&gt;Creating the guideline&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The oxDNA program is written in such a way to be easily modifiable to perform research in previously unplanned research directions. One of the most common ways of doing so is to write a new interaction, to simulate a different DNA/RNA model or to simulate something else entirely, including patchy particles.&lt;br /&gt;
&lt;br /&gt;
This section (currently a stub) is going to explain briefly what is needed to write such an interaction.&lt;br /&gt;
&lt;br /&gt;
== Files to create ==&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;Interaction Header&amp;#039;&amp;#039;&amp;#039; - this is the header file of your interaction. Contains the C++ header of the interaction, and should be saved in the directory &amp;lt;tt&amp;gt;src/Interactions&amp;lt;/tt&amp;gt; with extension &amp;lt;tt&amp;gt;.h&amp;lt;/tt&amp;gt;. The faster way to write it is probably to copy the one of an existing interaction that is somewhat similar to the interaction you want to write and modify it until you&amp;#039;re happy with it. The name of the file should be as close as the one of the class defining the interaction, with the extension &amp;lt;tt&amp;gt;.h&amp;lt;/tt&amp;gt; common to all header files. Therefore, if your interaction defines the class &amp;lt;tt&amp;gt;MyInteraction&amp;lt;/tt&amp;gt;, the file could be called &amp;lt;tt&amp;gt;MyInteraction.h&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;Interaction Source&amp;#039;&amp;#039;&amp;#039; - this is the source file of your interaction. Like the header, it should be saved in the &amp;lt;tt&amp;gt;src/Interactions&amp;lt;/tt&amp;gt; directory, but it should have extension &amp;lt;tt&amp;gt;.cpp&amp;lt;/tt&amp;gt;. Again, the best way to write one is to look at the &amp;lt;tt&amp;gt;.cpp&amp;lt;/tt&amp;gt; file of an interaction similar to the one you are going to write and modify it as needed. The name should be the same as the header file, with the only difference that the extension should be &amp;lt;tt&amp;gt;.cpp&amp;lt;/tt&amp;gt; instead of &amp;lt;tt&amp;gt;.h&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Files to modify ==&lt;br /&gt;
Here and in the following we are assuming that your interaction defines a class &amp;lt;tt&amp;gt;MyInteraction&amp;lt;/tt&amp;gt;, and is saved in the files &amp;lt;tt&amp;gt;MyInteraction.h&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;MyInteraction.cpp&amp;lt;/tt&amp;gt;. Your interaction will of course have a more informative name, so make sure to modify the following files accordingly.&lt;br /&gt;
# &amp;lt;tt&amp;gt;src/CMakeLists.txt&amp;lt;/tt&amp;gt; - this files contains information on how to compile oxDNA, i.e. which files to use to produce the oxDNA executable and how to do it. The files containing the interactions are listed in the block that starts with &amp;lt;tt&amp;gt; SET(interactions_SOURCES &amp;lt;/tt&amp;gt;. Add a line containing &amp;lt;tt&amp;gt;MyInteraction.cpp&amp;lt;/tt&amp;gt; to the list, so that the source file will be included in the build. The header file will be included by the source file (provided it contains the appropriate &amp;lt;tt&amp;gt;#include&amp;lt;/tt&amp;gt; directive).&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;tt&amp;gt;src/Interactions/InteractionFactory.cpp&amp;lt;/tt&amp;gt; Now your file will be compiled, but it&amp;#039;s still disjoint from the rest of the program. In order to make sure that the oxDNA program can use your interaction, you must modify the &amp;lt;tt&amp;gt;InteractionFactory.cpp&amp;lt;/tt&amp;gt; file to use your interaction.&lt;br /&gt;
## Add the header file &amp;lt;tt&amp;gt;#include &amp;quot;JordanInteraction.h&amp;quot;&amp;lt;/tt&amp;gt; together with the other interaction header files, at the beginning of the file.&lt;br /&gt;
## In the function &amp;lt;tt&amp;gt;make_interaction&amp;lt;/tt&amp;gt; there&amp;#039;s a long list of statements that create a different type of interaction depending on the value of the &amp;lt;tt&amp;gt;interaction_type&amp;lt;/tt&amp;gt; string in the oxDNA input file. Add your own interaction there, making sure not to mask any previously defined interactions. The syntax of the code of block might change, but currently it&amp;#039;s just a bunch of lines like &amp;lt;br&amp;gt; &amp;lt;br&amp;gt; &amp;lt;tt&amp;gt;else if(inter_type.compare(&amp;quot;DNA_nomesh&amp;quot;) == 0) return new DNAInteraction_nomesh&amp;lt;number&amp;gt;();&amp;lt;br&amp;gt;  else if(inter_type.compare(&amp;quot;DNA2_nomesh&amp;quot;) == 0) return new DNA2Interaction_nomesh&amp;lt;number&amp;gt;();&amp;lt;br&amp;gt;   else if(inter_type.compare(&amp;quot;LJ&amp;quot;) == 0) return new LJInteraction&amp;lt;number&amp;gt;();&amp;lt;br&amp;gt;  else if(inter_type.compare(&amp;quot;DNA_relax&amp;quot;) == 0) return new DNAInteraction_relax&amp;lt;number&amp;gt;();&amp;lt;br&amp;gt;   else if(inter_type.compare(&amp;quot;RNA&amp;quot;) == 0) return new RNAInteraction&amp;lt;number&amp;gt;();&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt; so you would just add the line &amp;lt;br&amp;gt;&amp;lt;br&amp;gt; &amp;lt;tt&amp;gt;else if(inter_type.compare(&amp;quot;my_interaction&amp;quot;) == 0) return new MyInteraction&amp;lt;number&amp;gt;();&amp;lt;/tt&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt; somewhere over there.&lt;/div&gt;</summary>
		<author><name>Randisi</name></author>
	</entry>
</feed>